diff --git a/include/Nazara/Audio/Sound.hpp b/include/Nazara/Audio/Sound.hpp index 0fd4e4e05..3a24ca2cb 100644 --- a/include/Nazara/Audio/Sound.hpp +++ b/include/Nazara/Audio/Sound.hpp @@ -32,7 +32,6 @@ namespace Nz bool IsLooping() const override; bool IsPlayable() const; - bool IsPlaying() const; bool LoadFromFile(const std::filesystem::path& filePath, const SoundBufferParams& params = SoundBufferParams()); bool LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params = SoundBufferParams()); diff --git a/include/Nazara/Audio/SoundEmitter.hpp b/include/Nazara/Audio/SoundEmitter.hpp index 169567a0e..f6dcb676f 100644 --- a/include/Nazara/Audio/SoundEmitter.hpp +++ b/include/Nazara/Audio/SoundEmitter.hpp @@ -37,6 +37,7 @@ namespace Nz float GetVolume() const; virtual bool IsLooping() const = 0; + inline bool IsPlaying() const; bool IsSpatialized() const; virtual void Pause() = 0; @@ -67,4 +68,7 @@ namespace Nz unsigned int m_source; }; } + +#include + #endif // NAZARA_SOUNDEMITTER_HPP diff --git a/include/Nazara/Audio/SoundEmitter.inl b/include/Nazara/Audio/SoundEmitter.inl new file mode 100644 index 000000000..a125e8c20 --- /dev/null +++ b/include/Nazara/Audio/SoundEmitter.inl @@ -0,0 +1,20 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Audio module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + /*! + * \brief Checks whether the sound is playing + * \return true if it is the case + */ + bool SoundEmitter::IsPlaying() const + { + return GetStatus() == SoundStatus::Playing; + } +} + +#include diff --git a/src/Nazara/Audio/Formats/sndfileLoader.cpp b/src/Nazara/Audio/Formats/sndfileLoader.cpp index 91202c6f9..4bf577a37 100644 --- a/src/Nazara/Audio/Formats/sndfileLoader.cpp +++ b/src/Nazara/Audio/Formats/sndfileLoader.cpp @@ -308,7 +308,7 @@ namespace Nz std::shared_ptr LoadSoundStreamStream(Stream& stream, const SoundStreamParams& parameters) { - std::unique_ptr soundStream(new sndfileStream); + std::shared_ptr soundStream = std::make_shared(); if (!soundStream->Open(stream, parameters.forceMono)) { NazaraError("Failed to open music stream"); diff --git a/src/Nazara/Audio/Music.cpp b/src/Nazara/Audio/Music.cpp index 1eaa067e7..cc2615906 100644 --- a/src/Nazara/Audio/Music.cpp +++ b/src/Nazara/Audio/Music.cpp @@ -497,9 +497,9 @@ namespace Nz void Music::StopThread() { if (m_impl->streaming) - { m_impl->streaming = false; + + if (m_impl->thread.joinable()) m_impl->thread.join(); - } } } diff --git a/src/Nazara/Audio/Sound.cpp b/src/Nazara/Audio/Sound.cpp index 23ee721ae..5e02f8dfa 100644 --- a/src/Nazara/Audio/Sound.cpp +++ b/src/Nazara/Audio/Sound.cpp @@ -119,15 +119,6 @@ namespace Nz return m_buffer != nullptr; } - /*! - * \brief Checks whether the sound is playing - * \return true if it is the case - */ - bool Sound::IsPlaying() const - { - return GetStatus() == SoundStatus::Playing; - } - /*! * \brief Loads the sound from file * \return true if loading is successful