decoder/Client: new interface which wraps struct Decoder

Prepare for a Decoder API redesign based on an abstract class with
virtual methods.
This commit is contained in:
Max Kellermann
2016-11-18 07:13:35 +01:00
parent 595d1942cb
commit fd77acc217
46 changed files with 460 additions and 407 deletions

View File

@@ -30,13 +30,13 @@
FLAC__StreamDecoderReadStatus
FlacInput::Read(FLAC__byte buffer[], size_t *bytes)
{
size_t r = decoder_read(decoder, input_stream, (void *)buffer, *bytes);
size_t r = decoder_read(client, input_stream, (void *)buffer, *bytes);
*bytes = r;
if (r == 0) {
if (input_stream.LockIsEOF() ||
(decoder != nullptr &&
decoder_get_command(*decoder) != DecoderCommand::NONE))
(client != nullptr &&
decoder_get_command(*client) != DecoderCommand::NONE))
return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
else
return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
@@ -83,17 +83,17 @@ FlacInput::Length(FLAC__uint64 *stream_length)
FLAC__bool
FlacInput::Eof()
{
return (decoder != nullptr &&
decoder_get_command(*decoder) != DecoderCommand::NONE &&
decoder_get_command(*decoder) != DecoderCommand::SEEK) ||
return (client != nullptr &&
decoder_get_command(*client) != DecoderCommand::NONE &&
decoder_get_command(*client) != DecoderCommand::SEEK) ||
input_stream.LockIsEOF();
}
void
FlacInput::Error(FLAC__StreamDecoderErrorStatus status)
{
if (decoder == nullptr ||
decoder_get_command(*decoder) != DecoderCommand::STOP)
if (client == nullptr ||
decoder_get_command(*client) != DecoderCommand::STOP)
LogWarning(flac_domain,
FLAC__StreamDecoderErrorStatusString[status]);
}