Make Sound FilesystemAppComponent-compliant
This commit is contained in:
parent
4199582a52
commit
e306a66956
|
|
@ -17,6 +17,8 @@ namespace Nz
|
|||
class NAZARA_AUDIO_API Sound final : public SoundEmitter
|
||||
{
|
||||
public:
|
||||
using Params = SoundBufferParams;
|
||||
|
||||
using SoundEmitter::SoundEmitter;
|
||||
Sound();
|
||||
Sound(AudioDevice& audioDevice, std::shared_ptr<SoundBuffer> soundBuffer);
|
||||
|
|
@ -36,9 +38,9 @@ namespace Nz
|
|||
bool IsLooping() const override;
|
||||
bool IsPlayable() 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());
|
||||
bool LoadFromStream(Stream& stream, const SoundBufferParams& params = SoundBufferParams());
|
||||
static std::shared_ptr<Sound> LoadFromFile(const std::filesystem::path& filePath, const Params& params = {});
|
||||
static std::shared_ptr<Sound> LoadFromMemory(const void* data, std::size_t size, const Params& params = {});
|
||||
static std::shared_ptr<Sound> LoadFromStream(Stream& stream, const Params& params = {});
|
||||
|
||||
void Pause() override;
|
||||
void Play() override;
|
||||
|
|
|
|||
|
|
@ -141,17 +141,18 @@ namespace Nz
|
|||
*
|
||||
* \remark Produces a NazaraError if loading failed
|
||||
*/
|
||||
bool Sound::LoadFromFile(const std::filesystem::path& filePath, const SoundBufferParams& params)
|
||||
std::shared_ptr<Sound> Sound::LoadFromFile(const std::filesystem::path& filePath, const Params& params)
|
||||
{
|
||||
std::shared_ptr<SoundBuffer> buffer = SoundBuffer::LoadFromFile(filePath, params);
|
||||
if (!buffer)
|
||||
{
|
||||
NazaraErrorFmt("failed to load buffer from file ({0})", filePath);
|
||||
return false;
|
||||
return {};
|
||||
}
|
||||
|
||||
SetBuffer(std::move(buffer));
|
||||
return true;
|
||||
std::shared_ptr<Sound> sound = std::make_shared<Sound>();
|
||||
sound->SetBuffer(std::move(buffer));
|
||||
return sound;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -164,17 +165,18 @@ namespace Nz
|
|||
*
|
||||
* \remark Produces a NazaraError if loading failed
|
||||
*/
|
||||
bool Sound::LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params)
|
||||
std::shared_ptr<Sound> Sound::LoadFromMemory(const void* data, std::size_t size, const Params& params)
|
||||
{
|
||||
std::shared_ptr<SoundBuffer> buffer = SoundBuffer::LoadFromMemory(data, size, params);
|
||||
if (!buffer)
|
||||
{
|
||||
NazaraErrorFmt("failed to load buffer from memory ({0})", PointerToString(data));
|
||||
return false;
|
||||
return {};
|
||||
}
|
||||
|
||||
SetBuffer(std::move(buffer));
|
||||
return true;
|
||||
std::shared_ptr<Sound> sound = std::make_shared<Sound>();
|
||||
sound->SetBuffer(std::move(buffer));
|
||||
return sound;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -186,17 +188,18 @@ namespace Nz
|
|||
*
|
||||
* \remark Produces a NazaraError if loading failed
|
||||
*/
|
||||
bool Sound::LoadFromStream(Stream& stream, const SoundBufferParams& params)
|
||||
std::shared_ptr<Sound> Sound::LoadFromStream(Stream& stream, const Params& params)
|
||||
{
|
||||
std::shared_ptr<SoundBuffer> buffer = SoundBuffer::LoadFromStream(stream, params);
|
||||
if (!buffer)
|
||||
{
|
||||
NazaraError("failed to load buffer from stream");
|
||||
return false;
|
||||
return {};
|
||||
}
|
||||
|
||||
SetBuffer(std::move(buffer));
|
||||
return true;
|
||||
std::shared_ptr<Sound> sound = std::make_shared<Sound>();
|
||||
sound->SetBuffer(std::move(buffer));
|
||||
return sound;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
Loading…
Reference in New Issue