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
+12 -2
View File
@@ -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