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,22 +10,50 @@
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Audio/Config.hpp>
#include <Nazara/Audio/Enums.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/Resource.hpp>
#include <Nazara/Core/ResourceLoader.hpp>
#include <Nazara/Core/ResourceParameters.hpp>
namespace Nz
{
class NAZARA_AUDIO_API SoundStream
struct SoundStreamParams : public ResourceParameters
{
bool forceMono = false;
bool IsValid() const;
};
class Mutex;
class SoundStream;
using SoundStreamLoader = ResourceLoader<SoundStream, SoundStreamParams>;
using SoundStreamRef = Nz::ObjectRef<SoundStream>;
class NAZARA_AUDIO_API SoundStream : public RefCounted, public Resource
{
friend SoundStreamLoader;
public:
SoundStream() = default;
virtual ~SoundStream();
virtual UInt32 GetDuration() const = 0;
virtual AudioFormat GetFormat() const = 0;
virtual Mutex& GetMutex() = 0;
virtual UInt64 GetSampleCount() const = 0;
virtual UInt32 GetSampleRate() const = 0;
virtual UInt64 Read(void* buffer, UInt64 sampleCount) = 0;
virtual void Seek(UInt64 offset) = 0;
virtual UInt64 Tell() = 0;
static SoundStreamRef OpenFromFile(const String& filePath, const SoundStreamParams& params = SoundStreamParams());
static SoundStreamRef OpenFromMemory(const void* data, std::size_t size, const SoundStreamParams& params = SoundStreamParams());
static SoundStreamRef OpenFromStream(Stream& stream, const SoundStreamParams& params = SoundStreamParams());
private:
static SoundStreamLoader::LoaderList s_loaders;
};
}