Update Music to use correct Resource API

This commit is contained in:
SweetId
2024-03-11 17:15:27 -04:00
parent cc91b8d3b9
commit cc2c36c75d
2 changed files with 31 additions and 16 deletions

View File

@@ -240,12 +240,17 @@ namespace Nz
* \param filePath Path to the file
* \param params Parameters for the music
*/
bool Music::OpenFromFile(const std::filesystem::path& filePath, const SoundStreamParams& params)
std::shared_ptr<Music> Music::OpenFromFile(const std::filesystem::path& filePath, const Params& params)
{
std::shared_ptr<Music> music = std::make_shared<Music>();
if (std::shared_ptr<SoundStream> soundStream = SoundStream::OpenFromFile(filePath, params))
return Create(std::move(soundStream));
else
return false;
{
std::shared_ptr<Music> music = std::make_shared<Music>();
if (music->Create(std::move(soundStream)))
return music;
}
return {};
}
/*!
@@ -258,12 +263,16 @@ namespace Nz
*
* \remark The memory pointer must stay valid (accessible) as long as the music is playing
*/
bool Music::OpenFromMemory(const void* data, std::size_t size, const SoundStreamParams& params)
std::shared_ptr<Music> Music::OpenFromMemory(const void* data, std::size_t size, const Params& params)
{
if (std::shared_ptr<SoundStream> soundStream = SoundStream::OpenFromMemory(data, size, params))
return Create(std::move(soundStream));
else
return false;
{
std::shared_ptr<Music> music = std::make_shared<Music>();
if (music->Create(std::move(soundStream)))
return music;
}
return {};
}
/*!
@@ -275,12 +284,16 @@ namespace Nz
*
* \remark The stream must stay valid as long as the music is playing
*/
bool Music::OpenFromStream(Stream& stream, const SoundStreamParams& params)
std::shared_ptr<Music> Music::OpenFromStream(Stream& stream, const Params& params)
{
if (std::shared_ptr<SoundStream> soundStream = SoundStream::OpenFromStream(stream, params))
return Create(std::move(soundStream));
else
return false;
{
std::shared_ptr<Music> music = std::make_shared<Music>();
if (music->Create(std::move(soundStream)))
return music;
}
return {};
}
/*!
@@ -439,7 +452,7 @@ namespace Nz
break; // We have reached the end of the stream, there is no use to add new buffers
}
}
catch (const std::exception&)
catch (const std::exception& e)
{
err = std::current_exception();