diff options
author | Max Kellermann <max@duempel.org> | 2008-04-12 04:20:25 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-04-12 04:20:25 +0000 |
commit | 3db2b987183d0c325825ce70f0f1c343d22839d4 (patch) | |
tree | 752291fb8a7b08ab14eb06d5b8a212a3c152a93f /src | |
parent | a91f2a1f05acd217032f22964ade58af8cb474dd (diff) | |
download | mpd-3db2b987183d0c325825ce70f0f1c343d22839d4.tar.gz mpd-3db2b987183d0c325825ce70f0f1c343d22839d4.tar.xz mpd-3db2b987183d0c325825ce70f0f1c343d22839d4.zip |
read num_channels once
Read frame->header.channels once, and pass only this integer to
flac_convert().
git-svn-id: https://svn.musicpd.org/mpd/trunk@7329 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/inputPlugins/flac_plugin.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c index 350e47047..8f4c96884 100644 --- a/src/inputPlugins/flac_plugin.c +++ b/src/inputPlugins/flac_plugin.c @@ -207,7 +207,7 @@ static void flacMetadata(const flac_decoder * dec, } static void flac_convert(unsigned char *dest, - const FLAC__Frame * frame, + unsigned int num_channels, unsigned int bytes_per_sample, const FLAC__int32 * const buf[], unsigned int position, unsigned int end) @@ -217,7 +217,7 @@ static void flac_convert(unsigned char *dest, unsigned char *uc; for (; position < end; ++position) { - for (c_chan = 0; c_chan < frame->header.channels; c_chan++) { + for (c_chan = 0; c_chan < num_channels; c_chan++) { u16 = buf[c_chan][position]; uc = (unsigned char *)&u16; for (i = 0; i < bytes_per_sample; i++) { @@ -235,6 +235,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec, FlacData *data = (FlacData *) vdata; FLAC__uint32 samples = frame->header.blocksize; unsigned int c_samp; + const unsigned int num_channels = frame->header.channels; const unsigned int bytes_per_sample = (data->dc->audioFormat.bits / 8); const unsigned int bytes_per_channel = bytes_per_sample * frame->header.channels; @@ -266,7 +267,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec, num_samples = max_samples; flac_convert(data->chunk + data->chunk_length, - frame, bytes_per_sample, buf, + num_channels, bytes_per_sample, buf, c_samp, c_samp + num_samples); data->chunk_length = num_samples; |