From 6ef5ff6e52f1104c4cc1c6b7ea064b5fb0a5a422 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Fri, 30 May 2008 08:29:41 -0700 Subject: [PATCH] winemp3: Try to find a valid header instead of failing immediately --- dlls/winemp3.acm/common.c | 8 +++++--- dlls/winemp3.acm/interface.c | 10 ++++++++-- dlls/winemp3.acm/mpegl3.c | 6 ++++-- 3 files changed, 17 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..ca1a414 100644 --- a/dlls/winemp3.acm/interface.c +++ b/dlls/winemp3.acm/interface.c @@ -174,8 +174,14 @@ int decodeMP3(struct mpstr *mp,const unsigned char *in,int isize,unsigned char * return MP3_NEED_MORE; } read_head(mp); - if (decode_header(&mp->fr,mp->header) == 0) { - return MP3_ERR; + while (!decode_header(&mp->fr,mp->header) && mp->bsize >= 4) + { + mp->header = mp->header << 8; + mp->header |= read_buf_byte(mp); + } + + if(mp->bsize < 4) { + 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); -- 1.5.4.1