Maarten Lankhorst : winemp3: Try to find a valid header instead of failing immediately.

Alexandre Julliard julliard at winehq.org
Thu Jun 19 06:37:24 CDT 2008


Module: wine
Branch: master
Commit: 586d9e140e3934e0a88979fe269e41aeddb04b35
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=586d9e140e3934e0a88979fe269e41aeddb04b35

Author: Maarten Lankhorst <m.b.lankhorst at gmail.com>
Date:   Tue Jun 10 16:52:06 2008 +0200

winemp3: Try to find a valid header instead of failing immediately.

After seeking there might be some initial garbage, this makes it ignore it.

---

 dlls/winemp3.acm/common.c    |    8 +++++---
 dlls/winemp3.acm/interface.c |   11 +++++++++--
 dlls/winemp3.acm/mpegl3.c    |    6 ++++--
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/dlls/winemp3.acm/common.c b/dlls/winemp3.acm/common.c
index 5a02c13..2943fd8 100644
--- a/dlls/winemp3.acm/common.c
+++ b/dlls/winemp3.acm/common.c
@@ -71,7 +71,7 @@ int head_check(unsigned long head)
 
 
 /*
- * the code a header and write the information
+ * decode a header and write the information
  * into the frame structure
  */
 int decode_header(struct frame *fr,unsigned long newhead)
@@ -127,10 +127,11 @@ int decode_header(struct frame *fr,unsigned long newhead)
         fr->framesize  = (long) tabsel_123[fr->lsf][0][fr->bitrate_index] * 12000;
         fr->framesize /= freqs[fr->sampling_frequency];
         fr->framesize  = ((fr->framesize+fr->padding)<<2)-4;
+        break;
 #else
         FIXME("Layer 1 not supported!\n");
+        return 0;
 #endif
-        break;
       case 2:
 #ifdef LAYER2
 #if 0
@@ -140,10 +141,11 @@ int decode_header(struct frame *fr,unsigned long newhead)
         fr->framesize = (long) tabsel_123[fr->lsf][1][fr->bitrate_index] * 144000;
         fr->framesize /= freqs[fr->sampling_frequency];
         fr->framesize += fr->padding - 4;
+        break;
 #else
         FIXME("Layer 2 not supported!\n");
+        return 0;
 #endif
-        break;
       case 3:
 #if 0
         fr->do_layer = do_layer3;
diff --git a/dlls/winemp3.acm/interface.c b/dlls/winemp3.acm/interface.c
index a1d09f2..1511cbb 100644
--- a/dlls/winemp3.acm/interface.c
+++ b/dlls/winemp3.acm/interface.c
@@ -170,12 +170,19 @@ int decodeMP3(struct mpstr *mp,const unsigned char *in,int isize,unsigned char *
 
 	/* First decode header */
 	if(mp->framesize == 0) {
+		int ret;
 		if(mp->bsize < 4) {
 			return MP3_NEED_MORE;
 		}
 		read_head(mp);
-		if (decode_header(&mp->fr,mp->header) == 0) {
-			return MP3_ERR;
+		while (!(ret = decode_header(&mp->fr,mp->header)) && mp->bsize)
+		{
+			mp->header = mp->header << 8;
+			mp->header |= read_buf_byte(mp);
+		}
+
+		if (!ret) {
+			return MP3_NEED_MORE;
 		}
 		mp->framesize = mp->fr.framesize;
 	}
diff --git a/dlls/winemp3.acm/mpegl3.c b/dlls/winemp3.acm/mpegl3.c
index 5020783..5ad4433 100644
--- a/dlls/winemp3.acm/mpegl3.c
+++ b/dlls/winemp3.acm/mpegl3.c
@@ -167,6 +167,8 @@ static void mp3_horse(PACMDRVSTREAMINSTANCE adsi,
     buffered_during = get_num_buffered_bytes(&amd->mp);
     if (ret != MP3_OK)
     {
+        if (ret == MP3_ERR)
+            FIXME("Error occured during decoding!\n");
         *ndst = *nsrc = 0;
         return;
     }
@@ -394,7 +396,7 @@ static	LRESULT	MPEG3_FormatSuggest(PACMDRVFORMATSUGGEST adfs)
  *           MPEG3_Reset
  *
  */
-static	void	MPEG3_Reset(PACMDRVSTREAMINSTANCE adsi, AcmMpeg3Data* aad)
+static void MPEG3_Reset(PACMDRVSTREAMINSTANCE adsi, AcmMpeg3Data* aad)
 {
     ClearMP3Buffer(&aad->mp);
     InitMP3(&aad->mp);
@@ -540,7 +542,7 @@ static LRESULT MPEG3_StreamConvert(PACMDRVSTREAMINSTANCE adsi, PACMDRVSTREAMHEAD
      */
     if ((adsh->fdwConvert & ACM_STREAMCONVERTF_START))
     {
-	MPEG3_Reset(adsi, aad);
+        MPEG3_Reset(adsi, aad);
     }
 
     aad->convert(adsi, adsh->pbSrc, &nsrc, adsh->pbDst, &ndst);




More information about the wine-cvs mailing list