Fill the whole output buffer at a time by using dither_buffer()'s
ability to decode blocks. Calculate how many samples fit into the
output buffer before each invocation.
---
src/inputPlugins/mp3_plugin.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c
index 2a6346b..0a99cab 100644
--- a/src/inputPlugins/mp3_plugin.c
+++ b/src/inputPlugins/mp3_plugin.c
@@ -932,12 +932,18 @@ static int mp3Read(mp3DecodeData * data, struct decoder
*decoder,
pcm_length -= data->dropSamplesAtEnd;
}
- for (; i < pcm_length; i++) {
- unsigned int num_samples;
+ while (i < pcm_length) {
+ unsigned int num_samples =
+ (data->outputBufferEnd - data->outputPtr) /
+ (2 * MAD_NCHANNELS(&(data->frame).header));
+ if (num_samples > pcm_length - i)
+ num_samples = pcm_length - i;
+
+ i += num_samples;
num_samples = dither_buffer((mpd_sint16 *)
data->outputPtr,
&data->synth, &data->dither,
- i, i + 1,
+ i - num_samples, i,
MAD_NCHANNELS(&(data->frame).header));
data->outputPtr += 2 * num_samples;
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Musicpd-dev-team mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team