aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-04-12 04:20:19 +0000
committerEric Wong <normalperson@yhbt.net>2008-04-12 04:20:19 +0000
commita91f2a1f05acd217032f22964ade58af8cb474dd (patch)
treee8346126fc05312724caaf103e3eb13c47e2c53a /src
parentca1090f93b10c87a5ae3d7234688699569af5b01 (diff)
downloadmpd-a91f2a1f05acd217032f22964ade58af8cb474dd.tar.gz
mpd-a91f2a1f05acd217032f22964ade58af8cb474dd.tar.xz
mpd-a91f2a1f05acd217032f22964ade58af8cb474dd.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/inputPlugins/flac_plugin.c7
1 files changed, 3 insertions, 4 deletions
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