diff --git a/include/RaZ/Audio/Microphone.hpp b/include/RaZ/Audio/Microphone.hpp index 8513513d..0c82e02d 100644 --- a/include/RaZ/Audio/Microphone.hpp +++ b/include/RaZ/Audio/Microphone.hpp @@ -17,8 +17,7 @@ class Microphone { /// \param duration Amount of time to record, in seconds. This is a minimum; the actual available duration may exceed this value. /// \param deviceName Name of the audio capture device to open; if empty, will use the default one. /// \see Microphone::recoverDevices() - Microphone(AudioFormat format, unsigned int frequency, float duration, const std::string& deviceName = {}) { openDevice(format, frequency, - duration, deviceName); } + Microphone(AudioFormat format, unsigned int frequency, float duration, const std::string& deviceName = {}); Microphone(const Microphone&) = delete; Microphone(Microphone&&) = delete; diff --git a/src/RaZ/Audio/AudioSystem.cpp b/src/RaZ/Audio/AudioSystem.cpp index b8fd252b..1eb8ab66 100644 --- a/src/RaZ/Audio/AudioSystem.cpp +++ b/src/RaZ/Audio/AudioSystem.cpp @@ -6,6 +6,8 @@ #include "RaZ/Physics/RigidBody.hpp" #include "RaZ/Utils/Logger.hpp" +#include "tracy/Tracy.hpp" + #include #include @@ -37,6 +39,8 @@ inline void checkError(void* device, const std::string& errorMsg) { } // namespace AudioSystem::AudioSystem(const std::string& deviceName) { + ZoneScopedN("AudioSystem::AudioSystem"); + registerComponents(); openDevice(deviceName); @@ -63,6 +67,8 @@ std::vector AudioSystem::recoverDevices() { } void AudioSystem::openDevice(const std::string& deviceName) { + ZoneScopedN("AudioSystem::openDevice"); + Logger::debug("[AudioSystem] Opening " + (!deviceName.empty() ? + "device '" + deviceName + '\'' : "default device") + "..."); destroy(); @@ -95,6 +101,8 @@ std::string AudioSystem::recoverCurrentDevice() const { } bool AudioSystem::update(const FrameTimeInfo&) { + ZoneScopedN("AudioSystem::update"); + #if defined(RAZ_CONFIG_DEBUG) // Checking that only one Listener exists bool hasOneListener = false; @@ -147,6 +155,8 @@ bool AudioSystem::update(const FrameTimeInfo&) { } void AudioSystem::destroy() { + ZoneScopedN("AudioSystem::destroy"); + if (m_context == nullptr && m_device == nullptr) return; diff --git a/src/RaZ/Audio/Microphone.cpp b/src/RaZ/Audio/Microphone.cpp index 9901f8e9..2c9b8617 100644 --- a/src/RaZ/Audio/Microphone.cpp +++ b/src/RaZ/Audio/Microphone.cpp @@ -2,6 +2,8 @@ #include "RaZ/Audio/Sound.hpp" #include "RaZ/Utils/Logger.hpp" +#include "tracy/Tracy.hpp" + #include #include @@ -83,6 +85,11 @@ constexpr int recoverFrameSize(AudioFormat format) { } // namespace +Microphone::Microphone(AudioFormat format, unsigned int frequency, float duration, const std::string& deviceName) { + ZoneScopedN("Microphone::Microphone"); + openDevice(format, frequency, duration, deviceName); +} + std::vector Microphone::recoverDevices() { if (!alcIsExtensionPresent(nullptr, "ALC_ENUMERATE_ALL_EXT")) // If the needed extension is unsupported, return an empty vector return {}; @@ -102,6 +109,8 @@ std::vector Microphone::recoverDevices() { } void Microphone::openDevice(AudioFormat format, unsigned int frequency, float duration, const std::string& deviceName) { + ZoneScopedN("Microphone::openDevice"); + Logger::debug("[Microphone] Opening capture " + (!deviceName.empty() ? + "device '" + deviceName + '\'' : "default device") + "..."); destroy(); @@ -169,6 +178,8 @@ std::vector Microphone::recoverData(float maxDuration) const { } void Microphone::recoverData(std::vector& data, float maxDuration) const { + ZoneScopedN("Microphone::recoverData"); + data.clear(); if (maxDuration == 0.f) @@ -189,6 +200,8 @@ void Microphone::recoverData(std::vector& data, float maxDuration) cons } Sound Microphone::recoverSound(float maxDuration) const { + ZoneScopedN("Microphone::recoverSound"); + Sound sound; sound.m_format = m_format; @@ -200,6 +213,8 @@ Sound Microphone::recoverSound(float maxDuration) const { } void Microphone::destroy() { + ZoneScopedN("Microphone::destroy"); + if (m_device == nullptr) return; diff --git a/src/RaZ/Audio/Sound.cpp b/src/RaZ/Audio/Sound.cpp index f7607e32..f7b24ad5 100644 --- a/src/RaZ/Audio/Sound.cpp +++ b/src/RaZ/Audio/Sound.cpp @@ -3,6 +3,8 @@ #include "RaZ/Math/Vector.hpp" #include "RaZ/Utils/Logger.hpp" +#include "tracy/Tracy.hpp" + #include #if !defined(RAZ_PLATFORM_EMSCRIPTEN) #include @@ -34,6 +36,8 @@ inline void checkError(const std::string& errorMsg) { } // namespace void Sound::init() { + ZoneScopedN("Sound::init"); + Logger::debug("[Sound] Initializing..."); alGetError(); // Flushing errors @@ -54,6 +58,8 @@ void Sound::init() { } void Sound::load() { + ZoneScopedN("Sound::load"); + stop(); // Making sure the sound isn't paused or currently playing alSourcei(m_source, AL_BUFFER, 0); // Detaching the previous buffer (if any) from the source @@ -197,6 +203,8 @@ float Sound::recoverElapsedTime() const noexcept { } void Sound::destroy() { + ZoneScopedN("Sound::destroy"); + if (!m_source.isValid() && !m_buffer.isValid()) return; diff --git a/src/RaZ/Audio/SoundEffect.cpp b/src/RaZ/Audio/SoundEffect.cpp index 10fd9b95..d5a2a321 100644 --- a/src/RaZ/Audio/SoundEffect.cpp +++ b/src/RaZ/Audio/SoundEffect.cpp @@ -2,6 +2,8 @@ #include "RaZ/Utils/CompilerUtils.hpp" #include "RaZ/Utils/Logger.hpp" +#include "tracy/Tracy.hpp" + #include #include @@ -65,6 +67,8 @@ inline bool loadFunctions() noexcept { } // namespace void SoundEffect::init() { + ZoneScopedN("SoundEffect::init"); + if (!alcIsExtensionPresent(alcGetContextsDevice(alcGetCurrentContext()), "ALC_EXT_EFX")) { Logger::error("[SoundEffect] Sound effects are unavailable."); return; @@ -200,6 +204,8 @@ void SoundEffect::reset() { } void SoundEffect::destroy() { + ZoneScopedN("SoundEffect::destroy"); + if (!m_index.isValid()) return; diff --git a/src/RaZ/Audio/SoundEffectSlot.cpp b/src/RaZ/Audio/SoundEffectSlot.cpp index 9cab821d..0a42bd22 100644 --- a/src/RaZ/Audio/SoundEffectSlot.cpp +++ b/src/RaZ/Audio/SoundEffectSlot.cpp @@ -3,6 +3,8 @@ #include "RaZ/Utils/CompilerUtils.hpp" #include "RaZ/Utils/Logger.hpp" +#include "tracy/Tracy.hpp" + #include #if !defined(RAZ_PLATFORM_EMSCRIPTEN) #include @@ -68,6 +70,8 @@ inline bool loadFunctions() noexcept { } // namespace void SoundEffectSlot::init() { + ZoneScopedN("SoundEffectSlot::init"); + if (!alcIsExtensionPresent(alcGetContextsDevice(alcGetCurrentContext()), "ALC_EXT_EFX")) { Logger::error("[SoundEffectSlot] Sound effects are unavailable."); return; @@ -88,11 +92,15 @@ void SoundEffectSlot::init() { } void SoundEffectSlot::loadEffect(const SoundEffect& effect) const noexcept { + ZoneScopedN("SoundEffectSlot::loadEffect"); + alAuxiliaryEffectSloti(m_index, AL_EFFECTSLOT_EFFECT, static_cast(effect.getIndex())); checkError("Failed to load the sound effect"); } void SoundEffectSlot::destroy() { + ZoneScopedN("SoundEffectSlot::destroy"); + if (!m_index.isValid()) return;