From 0c934f9d363c1d3568f53835af860dfead83385f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 23 Sep 2008 23:59:55 +0200 Subject: flac: merged flacSendChunk() into flac_common_write() Since flacSendChunk() is a trivial function and is only used in one location, move the code there. The advantage is that calling decoder_data() directly returns the decoder_command value, so we can eliminate one decoder_get_command() call. --- src/inputPlugins/_flac_common.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'src/inputPlugins') diff --git a/src/inputPlugins/_flac_common.c b/src/inputPlugins/_flac_common.c index 508a68b8f..39baeff3c 100644 --- a/src/inputPlugins/_flac_common.c +++ b/src/inputPlugins/_flac_common.c @@ -196,19 +196,6 @@ void flac_error_common_cb(const char *plugin, } } -/* keep this inlined, this is just macro but prettier :) */ -static inline int flacSendChunk(FlacData * data) -{ - if (decoder_data(data->decoder, data->inStream, - 1, data->chunk, - data->chunk_length, data->time, - data->bitRate, - data->replayGainInfo) == DECODE_COMMAND_STOP) - return -1; - - return 0; -} - static void flac_convert_stereo16(int16_t *dest, const FLAC__int32 * const buf[], unsigned int position, unsigned int end) @@ -301,6 +288,7 @@ flac_common_write(FlacData *data, const FLAC__Frame * frame, bytes_per_sample * frame->header.channels; const unsigned int max_samples = FLAC_CHUNK_SIZE / bytes_per_channel; unsigned int num_samples; + enum decoder_command cmd; if (bytes_per_sample != 1 && bytes_per_sample != 2 && bytes_per_sample != 4) @@ -319,12 +307,23 @@ flac_common_write(FlacData *data, const FLAC__Frame * frame, data->chunk_length = num_samples * bytes_per_channel; - if (flacSendChunk(data) < 0) { + cmd = decoder_data(data->decoder, data->inStream, + 1, data->chunk, + data->chunk_length, data->time, + data->bitRate, + data->replayGainInfo); + data->chunk_length = 0; + + switch (cmd) { + case DECODE_COMMAND_NONE: + case DECODE_COMMAND_START: + break; + + case DECODE_COMMAND_STOP: return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - data->chunk_length = 0; - if (decoder_get_command(data->decoder) == DECODE_COMMAND_SEEK) { + + case DECODE_COMMAND_SEEK: return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; } -- cgit v1.2.3