diff --git a/src/client/sound/al_helpers.cpp b/src/client/sound/al_helpers.cpp index 3b104a0b917d..3db3c6f61459 100644 --- a/src/client/sound/al_helpers.cpp +++ b/src/client/sound/al_helpers.cpp @@ -24,6 +24,8 @@ with this program; ifnot, write to the Free Software Foundation, Inc., #include "al_helpers.h" +namespace sound { + /* * RAIIALSoundBuffer */ @@ -51,3 +53,5 @@ RAIIALSoundBuffer RAIIALSoundBuffer::generate() noexcept alGenBuffers(1, &buf); return RAIIALSoundBuffer(buf); } + +} // namespace sound diff --git a/src/client/sound/al_helpers.h b/src/client/sound/al_helpers.h index 8e12db673fd6..5f0ba0089096 100644 --- a/src/client/sound/al_helpers.h +++ b/src/client/sound/al_helpers.h @@ -45,6 +45,8 @@ with this program; ifnot, write to the Free Software Foundation, Inc., #include +namespace sound { + inline const char *getAlErrorString(ALenum err) noexcept { switch (err) { @@ -116,3 +118,5 @@ struct RAIIALSoundBuffer final // > [...] the NULL buffer (i.e., 0) which can always be queued. ALuint m_buffer = 0; }; + +} // namespace sound diff --git a/src/client/sound/ogg_file.cpp b/src/client/sound/ogg_file.cpp index 729cf7d53b75..46c3427defaa 100644 --- a/src/client/sound/ogg_file.cpp +++ b/src/client/sound/ogg_file.cpp @@ -26,6 +26,8 @@ with this program; ifnot, write to the Free Software Foundation, Inc., #include // memcpy +namespace sound { + /* * OggVorbisBufferSource struct */ @@ -177,3 +179,5 @@ RAIIALSoundBuffer RAIIOggFile::loadBuffer(const OggFileDecodeInfo &decode_info, return snd_buffer_id; } + +} // namespace sound diff --git a/src/client/sound/ogg_file.h b/src/client/sound/ogg_file.h index fe41239e0d0b..177357337a09 100644 --- a/src/client/sound/ogg_file.h +++ b/src/client/sound/ogg_file.h @@ -29,6 +29,8 @@ with this program; ifnot, write to the Free Software Foundation, Inc., #include #include +namespace sound { + /** * For vorbisfile to read from our buffer instead of from a file. */ @@ -92,3 +94,5 @@ struct RAIIOggFile { RAIIALSoundBuffer loadBuffer(const OggFileDecodeInfo &decode_info, ALuint pcm_start, ALuint pcm_end); }; + +} // namespace sound diff --git a/src/client/sound/playing_sound.cpp b/src/client/sound/playing_sound.cpp index 033020e9ba70..11aee80e3735 100644 --- a/src/client/sound/playing_sound.cpp +++ b/src/client/sound/playing_sound.cpp @@ -28,6 +28,8 @@ with this program; ifnot, write to the Free Software Foundation, Inc., #include #include +namespace sound { + PlayingSound::PlayingSound(ALuint source_id, std::shared_ptr data, bool loop, f32 volume, f32 pitch, f32 start_time, const std::optional> &pos_vel_opt) @@ -239,3 +241,5 @@ f32 PlayingSound::getGain() noexcept gain *= 1.0f/3.0f; return gain; } + +} // namespace sound diff --git a/src/client/sound/playing_sound.h b/src/client/sound/playing_sound.h index 066e1af4284e..1fbf37e3ecab 100644 --- a/src/client/sound/playing_sound.h +++ b/src/client/sound/playing_sound.h @@ -26,6 +26,8 @@ with this program; ifnot, write to the Free Software Foundation, Inc., #include "sound_data.h" +namespace sound { + /** * A sound that is currently played. * Can be streaming. @@ -105,3 +107,5 @@ class PlayingSound final play(); } }; + +} // namespace sound diff --git a/src/client/sound/proxy_sound_manager.cpp b/src/client/sound/proxy_sound_manager.cpp index 81077650203f..ede603e67805 100644 --- a/src/client/sound/proxy_sound_manager.cpp +++ b/src/client/sound/proxy_sound_manager.cpp @@ -21,6 +21,8 @@ with this program; ifnot, write to the Free Software Foundation, Inc., #include "filesys.h" +namespace sound { + ProxySoundManager::MsgResult ProxySoundManager::handleMsg(SoundManagerMsgToProxy &&msg) { using namespace sound_manager_messages_to_proxy; @@ -161,3 +163,5 @@ void ProxySoundManager::updateSoundPosVel(sound_handle_t sound, const v3f &pos_, { send(sound_manager_messages_to_mgr::UpdateSoundPosVel{sound, pos_, vel_}); } + +} // namespace sound diff --git a/src/client/sound/proxy_sound_manager.h b/src/client/sound/proxy_sound_manager.h index 4f376d635719..53299e045296 100644 --- a/src/client/sound/proxy_sound_manager.h +++ b/src/client/sound/proxy_sound_manager.h @@ -21,6 +21,8 @@ with this program; ifnot, write to the Free Software Foundation, Inc., #include "sound_manager.h" +namespace sound { + /* * The public ISoundManager interface */ @@ -69,3 +71,5 @@ class ProxySoundManager final : public ISoundManager void fadeSound(sound_handle_t soundid, f32 step, f32 target_gain) override; void updateSoundPosVel(sound_handle_t sound, const v3f &pos_, const v3f &vel_) override; }; + +} // namespace sound diff --git a/src/client/sound/sound_constants.h b/src/client/sound/sound_constants.h index b16f5204fcad..94d74b86c1f0 100644 --- a/src/client/sound/sound_constants.h +++ b/src/client/sound/sound_constants.h @@ -100,6 +100,8 @@ with this program; ifnot, write to the Free Software Foundation, Inc., * */ +namespace sound { + // constants // in seconds @@ -117,3 +119,5 @@ static_assert(MIN_STREAM_BUFFER_LENGTH > STREAM_BIGSTEP_TIME * 2.0f, "See [Streaming of sounds]."); static_assert(SOUND_DURATION_MAX_SINGLE >= MIN_STREAM_BUFFER_LENGTH * 2.0f, "There's no benefit in streaming if we can't queue more than 2 buffers."); + +} // namespace sound diff --git a/src/client/sound/sound_data.cpp b/src/client/sound/sound_data.cpp index 258bf8836060..f0cbc6dbf2a6 100644 --- a/src/client/sound/sound_data.cpp +++ b/src/client/sound/sound_data.cpp @@ -26,6 +26,8 @@ with this program; ifnot, write to the Free Software Foundation, Inc., #include "sound_constants.h" +namespace sound { + /* * ISoundDataOpen struct */ @@ -229,3 +231,5 @@ std::tuple SoundDataOpenStream::loadBufferAt(ALuint offs return {it->m_buffers[new_buf_i].m_buffer.get(), new_buf_end, offset - new_buf_start}; } + +} // namespace sound diff --git a/src/client/sound/sound_data.h b/src/client/sound/sound_data.h index f2c06b939043..36052c161748 100644 --- a/src/client/sound/sound_data.h +++ b/src/client/sound/sound_data.h @@ -28,6 +28,8 @@ with this program; ifnot, write to the Free Software Foundation, Inc., #include #include +namespace sound { + /** * Stores sound pcm data buffers. */ @@ -171,3 +173,5 @@ struct SoundDataOpenStream final : ISoundDataOpen std::tuple loadBufferAt(ALuint offset, std::vector::iterator after_it); }; + +} // namespace sound diff --git a/src/client/sound/sound_manager.cpp b/src/client/sound/sound_manager.cpp index 0791995c4599..fcc3559a5121 100644 --- a/src/client/sound/sound_manager.cpp +++ b/src/client/sound/sound_manager.cpp @@ -29,6 +29,8 @@ with this program; ifnot, write to the Free Software Foundation, Inc., #include "filesys.h" #include "porting.h" +namespace sound { + void OpenALSoundManager::stepStreams(f32 dtime) { // spread work across steps @@ -521,3 +523,5 @@ void *OpenALSoundManager::run() return nullptr; } + +} // namespace sound diff --git a/src/client/sound/sound_manager.h b/src/client/sound/sound_manager.h index b69bbf870666..7da18ccbfb4c 100644 --- a/src/client/sound/sound_manager.h +++ b/src/client/sound/sound_manager.h @@ -31,13 +31,16 @@ with this program; ifnot, write to the Free Software Foundation, Inc., #include "threading/thread.h" #include "util/container.h" // MutexedQueue +namespace sound { + class SoundManagerSingleton; /* * The SoundManager thread * * It's not an ISoundManager. It doesn't allocate ids, and doesn't accept id 0. - * All sound loading and interaction with OpenAL happens in this thread. + * All sound loading and interaction with OpenAL happens in this thread, and in + * SoundManagerSingleton. * Access from other threads happens via ProxySoundManager. * * See sound_constants.h for more details. @@ -169,3 +172,5 @@ class OpenALSoundManager final : public Thread send(sound_manager_messages_to_proxy::ReportRemovedSound{id}); } }; + +} // namespace sound diff --git a/src/client/sound/sound_manager_messages.h b/src/client/sound/sound_manager_messages.h index 14d254c98f75..41f4ffac1bfb 100644 --- a/src/client/sound/sound_manager_messages.h +++ b/src/client/sound/sound_manager_messages.h @@ -23,6 +23,8 @@ with this program; ifnot, write to the Free Software Foundation, Inc., #include "../../sound.h" #include +namespace sound { + namespace sound_manager_messages_to_mgr { struct PauseAll {}; struct ResumeAll {}; @@ -78,3 +80,5 @@ using SoundManagerMsgToProxy = std::variant< sound_manager_messages_to_proxy::Stopped >; + +} // namespace sound diff --git a/src/client/sound/sound_openal.cpp b/src/client/sound/sound_openal.cpp index 5d5d46a95975..89f4b57ad915 100644 --- a/src/client/sound/sound_openal.cpp +++ b/src/client/sound/sound_openal.cpp @@ -40,5 +40,5 @@ std::shared_ptr createSoundManagerSingleton() std::unique_ptr createOpenALSoundManager(SoundManagerSingleton *smg, std::unique_ptr fallback_path_provider) { - return std::make_unique(smg, std::move(fallback_path_provider)); + return std::make_unique(smg, std::move(fallback_path_provider)); }; diff --git a/src/client/sound/sound_openal.h b/src/client/sound/sound_openal.h index 431919ac670c..bae4fbd79f0b 100644 --- a/src/client/sound/sound_openal.h +++ b/src/client/sound/sound_openal.h @@ -20,10 +20,11 @@ with this program; if not, write to the Free Software Foundation, Inc., #pragma once #include "client/sound.h" - #include -class SoundManagerSingleton; +namespace sound { class SoundManagerSingleton; } +using sound::SoundManagerSingleton; + extern std::shared_ptr g_sound_manager_singleton; std::shared_ptr createSoundManagerSingleton(); diff --git a/src/client/sound/sound_singleton.cpp b/src/client/sound/sound_singleton.cpp index 26264fe76d61..4a600243ccd6 100644 --- a/src/client/sound/sound_singleton.cpp +++ b/src/client/sound/sound_singleton.cpp @@ -24,6 +24,8 @@ with this program; ifnot, write to the Free Software Foundation, Inc., #include "sound_singleton.h" +namespace sound { + bool SoundManagerSingleton::init() { if (!(m_device = unique_ptr_alcdevice(alcOpenDevice(nullptr)))) { @@ -67,3 +69,5 @@ SoundManagerSingleton::~SoundManagerSingleton() { infostream << "Audio: Global Deinitialized." << std::endl; } + +} // namespace sound diff --git a/src/client/sound/sound_singleton.h b/src/client/sound/sound_singleton.h index a3eb2dfa31ab..5168c1c9becd 100644 --- a/src/client/sound/sound_singleton.h +++ b/src/client/sound/sound_singleton.h @@ -26,6 +26,8 @@ with this program; ifnot, write to the Free Software Foundation, Inc., #include "al_helpers.h" +namespace sound { + /** * Class for the openal device and context */ @@ -58,3 +60,5 @@ class SoundManagerSingleton ~SoundManagerSingleton(); }; + +} // namespace sound