[FFmpeg-devel] [PATCH] ffplay's primary function is not to trigger OOM killer
Michael Niedermayer
michaelni
Thu Feb 19 23:04:50 CET 2009
On Thu, Feb 19, 2009 at 10:00:10PM +0100, Aurelien Jacobs wrote:
> Hi,
>
> Commit r16484 introduced an infinite loop allocating memory in ffplay.
> This is very efficient at filling memory and triggering the OOM killer.
> The relevant part of the main loop now looks like this:
>
> for(;;) {
> [...]
> if(url_feof(ic->pb)) {
> av_init_packet(pkt);
> [...]
> packet_queue_put(&is->videoq, pkt);
> continue;
> }
> ret = av_read_frame(ic, pkt);
> if (ret < 0) {
> [...]
> break;
> }
> [...]
> packet_queue_put(&is->videoq, pkt);
> }
>
> So when the demuxer read the last frame of the stream, the ByteIOContext
> reaches EOF but av_read_frame() correctly return a positive value as it
> actually read a full frame.
> Then at next iteration of the main loop url_feof() is triggered, which
> allocate a new packet and go back to the start of the loop, and
> triggers url_feof() again, and so on.
try to RTFS again and harder, these kind of bug analysis and fixes is what
leds projects to become what mplayer did ...
see, straight before the eof case:
/* if the queue are full, no need to read more */
if (is->audioq.size > MAX_AUDIOQ_SIZE ||
is->videoq.size > MAX_VIDEOQ_SIZE ||
is->subtitleq.size > MAX_SUBTITLEQ_SIZE) {
/* wait 10 ms */
SDL_Delay(10);
continue;
}
thus the NULL packets are only inserted if the que is not full, this
effectively limits the size and cannot trigger OOM (in theory ...)
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090219/fe84842f/attachment.pgp>
More information about the ffmpeg-devel
mailing list