From a91f2a1f05acd217032f22964ade58af8cb474dd Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 12 Apr 2008 04:20:19 +0000 Subject: assume the buffer is empty in flacWrite() flacWrite() is the only function which sets data->chunk_length. If we flush the buffer before we return, we can assume that it is always empty upon entering flacWrite(). git-svn-id: https://svn.musicpd.org/mpd/trunk@7328 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/inputPlugins/flac_plugin.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c index 8e2dbf6be..350e47047 100644 --- a/src/inputPlugins/flac_plugin.c +++ b/src/inputPlugins/flac_plugin.c @@ -238,7 +238,8 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec, const unsigned int bytes_per_sample = (data->dc->audioFormat.bits / 8); const unsigned int bytes_per_channel = bytes_per_sample * frame->header.channels; - unsigned int num_samples, max_samples; + const unsigned int max_samples = FLAC_CHUNK_SIZE / bytes_per_channel; + unsigned int num_samples; float timeChange; FLAC__uint64 newPosition = 0; @@ -261,15 +262,13 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec, for (c_samp = 0; c_samp < frame->header.blocksize; c_samp += num_samples) { num_samples = frame->header.blocksize - c_samp; - max_samples = (FLAC_CHUNK_SIZE - data->chunk_length) / - bytes_per_channel; if (num_samples > max_samples) num_samples = max_samples; flac_convert(data->chunk + data->chunk_length, frame, bytes_per_sample, buf, c_samp, c_samp + num_samples); - data->chunk_length += num_samples; + data->chunk_length = num_samples; if (flacSendChunk(data) < 0) { return -- cgit v1.2.3