Refactor the way resources are loaded (#191)

* WIP

* WIP

* Font works

* WIP: Only Music remains

* Looks like it's working

* Fix oopsie

* Core/ObjectRef: Add cast functions

* Update ChangeLog.md

* Audio/SoundStream: Make sound stream thread-safe
This commit is contained in:
Jérôme Leclercq
2018-10-28 01:53:11 +02:00
committed by GitHub
parent fa7cbc21e5
commit ed46c87781
64 changed files with 1058 additions and 1071 deletions

View File

@@ -10,31 +10,15 @@
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Audio/Enums.hpp>
#include <Nazara/Audio/SoundEmitter.hpp>
#include <Nazara/Audio/SoundStream.hpp>
#include <Nazara/Core/MovablePtr.hpp>
#include <Nazara/Core/Resource.hpp>
#include <Nazara/Core/ResourceLoader.hpp>
#include <Nazara/Core/ResourceParameters.hpp>
namespace Nz
{
struct MusicParams : ResourceParameters
{
bool forceMono = false;
bool IsValid() const;
};
class Music;
class SoundStream;
using MusicLoader = ResourceLoader<Music, MusicParams>;
struct MusicImpl;
class NAZARA_AUDIO_API Music : public Resource, public SoundEmitter
{
friend MusicLoader;
public:
Music() = default;
Music(const Music&) = delete;
@@ -55,9 +39,9 @@ namespace Nz
bool IsLooping() const override;
bool OpenFromFile(const String& filePath, const MusicParams& params = MusicParams());
bool OpenFromMemory(const void* data, std::size_t size, const MusicParams& params = MusicParams());
bool OpenFromStream(Stream& stream, const MusicParams& params = MusicParams());
bool OpenFromFile(const String& filePath, const SoundStreamParams& params = SoundStreamParams());
bool OpenFromMemory(const void* data, std::size_t size, const SoundStreamParams& params = SoundStreamParams());
bool OpenFromStream(Stream& stream, const SoundStreamParams& params = SoundStreamParams());
void Pause() override;
void Play() override;
@@ -75,8 +59,6 @@ namespace Nz
bool FillAndQueueBuffer(unsigned int buffer);
void MusicThread();
void StopThread();
static MusicLoader::LoaderList s_loaders;
};
}