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:
@@ -29,13 +29,16 @@ namespace sound
|
||||
|
||||
love::Type Decoder::type("Decoder", &Object::type);
|
||||
|
||||
Decoder::Decoder(Data *data, int bufferSize)
|
||||
: data(data)
|
||||
Decoder::Decoder(Stream *stream, int bufferSize)
|
||||
: stream(stream)
|
||||
, bufferSize(bufferSize)
|
||||
, sampleRate(DEFAULT_SAMPLE_RATE)
|
||||
, buffer(0)
|
||||
, eof(false)
|
||||
{
|
||||
if (!stream->isReadable() || !stream->isSeekable())
|
||||
throw love::Exception("Decoder input stream must be readable and seekable.");
|
||||
|
||||
buffer = new char[bufferSize];
|
||||
}
|
||||
|
||||
@@ -65,5 +68,12 @@ bool Decoder::isFinished()
|
||||
return eof;
|
||||
}
|
||||
|
||||
STRINGMAP_CLASS_BEGIN(Decoder, Decoder::StreamSource, Decoder::STREAM_MAX_ENUM, streamSource)
|
||||
{
|
||||
{ "memory", Decoder::STREAM_MEMORY },
|
||||
{ "file", Decoder::STREAM_FILE },
|
||||
}
|
||||
STRINGMAP_CLASS_END(Decoder, Decoder::StreamSource, Decoder::STREAM_MAX_ENUM, streamSource)
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
Reference in New Issue
Block a user