From 586d9e140e3934e0a88979fe269e41aeddb04b35 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Tue, 10 Jun 2008 16:52:06 +0200 Subject: [PATCH] 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 5a02c13fb96..2943fd857dc 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 a1d09f25427..1511cbb9f05 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 5020783afa1..5ad44334053 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);