Audio source decoding improvements.

- Streaming sources now also stream the file contents instead of loading it into memory, by default. Added a new stream type enum parameter to newSource ("file" or "memory").
- Audio file decoding now chooses the most appropriate decoder based on the file contents instead of the file extension.
- Videos now stream audio from the file instead of loading all of the video file into memory for use with audio decoding.
This commit is contained in:
Alex Szpakowski
2022-04-21 19:57:32 -03:00
parent d5865e160c
commit c09fef8e79
20 changed files with 318 additions and 468 deletions
+14 -5
View File
@@ -23,7 +23,8 @@
// LOVE
#include "common/Object.h"
#include "filesystem/File.h"
#include "common/Stream.h"
#include "common/StringMap.h"
#include <string>
@@ -39,9 +40,16 @@ class Decoder : public Object
{
public:
enum StreamSource
{
STREAM_MEMORY,
STREAM_FILE,
STREAM_MAX_ENUM
};
static love::Type type;
Decoder(Data *data, int bufferSize);
Decoder(Stream *stream, int bufferSize);
virtual ~Decoder();
/**
@@ -143,11 +151,12 @@ public:
**/
virtual double getDuration() = 0;
STRINGMAP_CLASS_DECLARE(StreamSource);
protected:
// The encoded data. This should be replaced with buffered file
// reads in the future.
StrongRef<Data> data;
// A readable stream containing the encoded data.
StrongRef<Stream> stream;
// When the decoder decodes data incrementally, it writes
// this many bytes at a time (at most).