From e9b1adff1747fb16d6a0806861f491cfb4254ea9 Mon Sep 17 00:00:00 2001 From: uau Date: Sun, 13 Aug 2006 23:09:17 +0000 Subject: [PATCH] Change pcm decode_audio to return data based on minlen instead of maxlen to avoid demuxing unnecessarily much at once. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@19389 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/ad_pcm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libmpcodecs/ad_pcm.c b/libmpcodecs/ad_pcm.c index db2670cf1b..e9cbadcaef 100644 --- a/libmpcodecs/ad_pcm.c +++ b/libmpcodecs/ad_pcm.c @@ -120,7 +120,11 @@ static int control(sh_audio_t *sh,int cmd,void* arg, ...) static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen) { unsigned len = sh_audio->channels*sh_audio->samplesize; - len = maxlen - maxlen % len; // sample align + len = (minlen + len - 1) / len * len; + if (len > maxlen) + // if someone needs hundreds of channels adjust audio_out_minsize + // based on channels in preinit() + return -1; len=demux_read_data(sh_audio->ds,buf,len); return len; }