winemp3: Try to find a valid header instead of failing immediately.
After seeking there might be some initial garbage, this makes it ignore it.
This commit is contained in:
parent
1328150193
commit
586d9e140e
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue