aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:13 +0200
committerMax Kellermann <max@duempel.org>2008-08-26 08:27:13 +0200
commit2a9608536c83373ae43c395176c5b41c5a5b5dec (patch)
tree8972e6415f4d6728ec95fec7d5b618fa2618311e /src/inputPlugins
parent3f55b5a1e42eb6e1d60292bada5697ecf7112feb (diff)
downloadmpd-2a9608536c83373ae43c395176c5b41c5a5b5dec.tar.gz
mpd-2a9608536c83373ae43c395176c5b41c5a5b5dec.tar.xz
mpd-2a9608536c83373ae43c395176c5b41c5a5b5dec.zip
mp3: moved num_samples calculation out of the loop
The previous patch removed all loop specific dependencies from the num_samples formula; we can now calculate it before entering the loop.
Diffstat (limited to 'src/inputPlugins')
-rw-r--r--src/inputPlugins/mp3_plugin.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c
index cba201817..beb59ea7e 100644
--- a/src/inputPlugins/mp3_plugin.c
+++ b/src/inputPlugins/mp3_plugin.c
@@ -830,7 +830,7 @@ static int openMp3FromInputStream(InputStream * inStream, mp3DecodeData * data,
static int mp3Read(mp3DecodeData * data, struct decoder *decoder,
ReplayGainInfo ** replayGainInfo)
{
- unsigned int pcm_length;
+ unsigned int pcm_length, max_samples;
unsigned int i;
int ret;
int skip;
@@ -922,12 +922,14 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder,
pcm_length -= data->dropSamplesAtEnd;
}
+ max_samples = sizeof(data->outputBuffer) /
+ (2 * MAD_NCHANNELS(&(data->frame).header));
+
while (i < pcm_length) {
enum decoder_command cmd;
- unsigned int num_samples = sizeof(data->outputBuffer) /
- (2 * MAD_NCHANNELS(&(data->frame).header));
- if (num_samples > pcm_length - i)
- num_samples = pcm_length - i;
+ unsigned int num_samples = pcm_length - i;
+ if (num_samples > max_samples)
+ num_samples = max_samples;
i += num_samples;