mirror of
https://github.com/love2d/love.git
synced 2026-08-18 03:34:23 +02:00
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:
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user