diff options
author | Max Kellermann <max@duempel.org> | 2008-09-23 23:59:55 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-23 23:59:55 +0200 |
commit | 0c934f9d363c1d3568f53835af860dfead83385f (patch) | |
tree | cc1257fed272827f3d7455142cc2fbe478183290 /src | |
parent | eeb30110708b507d254827d0c6a0577ddafa3b74 (diff) | |
download | mpd-0c934f9d363c1d3568f53835af860dfead83385f.tar.gz mpd-0c934f9d363c1d3568f53835af860dfead83385f.tar.xz mpd-0c934f9d363c1d3568f53835af860dfead83385f.zip |
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.
Diffstat (limited to '')
-rw-r--r-- | src/inputPlugins/_flac_common.c | 33 |
1 files changed, 16 insertions, 17 deletions
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; } |