[MPlayer-dev-eng] [PATCH] MP3 early EOF
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Thu Sep 8 15:50:08 CEST 2005
Hi,
On Wed, Sep 07, 2005 at 08:10:50PM -0700, RC wrote:
> MPlayer exits prematurely when playing a small MP3 file that grows
> during playback. It seems to be hitting the EOF early. This was
> discussed on mplayer-users:
>
> Message-Id: <200508270834.58405.kdekorte at yahoo.com>
> http://mplayerhq.hu/pipermail/mplayer-users/2005-August/055297.html
>
> This simple patch fixes the problem.
Try the attached patch. I'm not absolutely sure this is the best way,
but it will ignore the movi_end unless there is an error.
The unless there is an error part is because of the ID3 tag that can be
at the end...
I guess in some very rare cases it might still cause some garbled
output, but I added an additional check for stream_read to hopefully make
that even less likely.
Any comments?
Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpdemux/demux_audio.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_audio.c,v
retrieving revision 1.38
diff -u -r1.38 demux_audio.c
--- libmpdemux/demux_audio.c 2 Sep 2005 08:32:32 -0000 1.38
+++ libmpdemux/demux_audio.c 8 Sep 2005 13:47:50 -0000
@@ -404,7 +416,7 @@
priv = demux->priv;
s = demux->stream;
- if(s->eof || (demux->movi_end && stream_tell(s) >= demux->movi_end) )
+ if(s->eof)
return 0;
switch(priv->frmt) {
@@ -412,15 +424,18 @@
while(1) {
uint8_t hdr[4];
stream_read(s,hdr,4);
- if (s->eof || (demux->movi_end && stream_tell(s) >= demux->movi_end))
+ if (s->eof)
return 0;
l = mp_decode_mp3_header(hdr);
if(l < 0) {
+ if (demux->movi_end && stream_tell(s) >= demux->movi_end)
+ return 0; // might be ID3 tag, i.e. EOF
stream_skip(s,-3);
} else {
dp = new_demux_packet(l);
memcpy(dp->buffer,hdr,4);
- stream_read(s,dp->buffer + 4,l-4);
+ if (stream_read(s,dp->buffer + 4,l-4) != l-4)
+ return 0;
priv->last_pts = priv->last_pts < 0 ? 0 : priv->last_pts + sh_audio->audio.dwScale/(float)sh_audio->samplerate;
break;
}
More information about the MPlayer-dev-eng
mailing list