changeset 19157:597866a6793d

the value returned by decode_audio() must be the amount of _decoded_ bytes (finally it's beginning t work: no more toomanypackets... message)
author nicodvb
date Sat, 22 Jul 2006 22:14:14 +0000
parents 79e011974b0d
children 6373c98ada45
files libmpcodecs/ad_hwmpa.c
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/ad_hwmpa.c	Sat Jul 22 18:57:56 2006 +0000
+++ b/libmpcodecs/ad_hwmpa.c	Sat Jul 22 22:14:14 2006 +0000
@@ -59,7 +59,7 @@
 
 static int preinit(sh_audio_t *sh)
 {
-	sh->audio_out_minsize = 48;//check
+	sh->audio_out_minsize = 4608;//check
 	sh->audio_in_minsize = 4608;//check
 	sh->sample_format = AF_FORMAT_MPEG2;
 	return 1;
@@ -85,13 +85,14 @@
 {
 	int len, start, tot;
 	int chans, srate, spf, mpa_layer, br;
+	int tot2;
 
-	tot = 0;
+	tot = tot2 = 0;
 
-	while(tot < minlen)
+	while(tot2 < maxlen)
 	{
 		start = mpa_sync(sh, 1, &len, &chans, &srate, &spf, &mpa_layer, &br);
-		if(start < 0 || tot + len > maxlen)
+		if(start < 0 || tot2 + spf * 2 * chans > maxlen)
 			break;
 
 		if(start + len > sh->a_in_buffer_len)
@@ -110,9 +111,10 @@
 
 		sh->a_in_buffer_len -= start + len;
 		memmove(sh->a_in_buffer, &(sh->a_in_buffer[start + len]), sh->a_in_buffer_len);
+		tot2 += spf * 2 * chans;
 	}
 
-	return tot;
+	return tot2;
 }