diff options
author | Martin Storsjö <martin@martin.st> | 2012-07-03 22:57:19 +0300 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2012-07-04 11:11:08 +0300 |
commit | 296d0da8bd3b5bc5220a3b062d387bf9fa4584c5 (patch) | |
tree | 0b75d25b09666b416e2ab8f47ec8856611bfc395 | |
parent | 1c840fa227527c47f5e5b5954eab2b72d6b20632 (diff) | |
download | ffmpeg-296d0da8bd3b5bc5220a3b062d387bf9fa4584c5.tar.gz |
avplay: Add an option for not limiting the input buffer size
For reading from normal files on disk, the queue limits for
demuxed data work fine, but for reading data from realtime
streams, they mean we're not reading from the input stream
at all once the queue limit has been reached. For TCP streams,
this means that writing to the socket from the peer side blocks
(potentially leading to the peer dropping data), and for UDP
streams it means that our kernel might drop data.
For some protocols/servers, the server initially sends a
large burst with data to fill client side buffers, but once
filled, we should keep reading to avoid dropping data.
For all realtime streams, it IMO makes sense to just buffer
as much as we get (rather in buffers in avplay.c than in
OS level buffers). With this option set, the input thread
should always be blocking waiting for more input data,
never sleeping waiting for the decoder to consume data.
Signed-off-by: Martin Storsjö <martin@martin.st>
-rw-r--r-- | avplay.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -264,6 +264,7 @@ static int exit_on_keydown; static int exit_on_mousedown; static int loop = 1; static int framedrop = 1; +static int infinite_buffer = 0; static int rdftspeed = 20; #if CONFIG_AVFILTER @@ -2439,10 +2440,11 @@ static int decode_thread(void *arg) } /* if the queue are full, no need to read more */ - if ( is->audioq.size + is->videoq.size + is->subtitleq.size > MAX_QUEUE_SIZE + if (!infinite_buffer && + (is->audioq.size + is->videoq.size + is->subtitleq.size > MAX_QUEUE_SIZE || ( (is->audioq .size > MIN_AUDIOQ_SIZE || is->audio_stream < 0) && (is->videoq .nb_packets > MIN_FRAMES || is->video_stream < 0) - && (is->subtitleq.nb_packets > MIN_FRAMES || is->subtitle_stream < 0))) { + && (is->subtitleq.nb_packets > MIN_FRAMES || is->subtitle_stream < 0)))) { /* wait 10 ms */ SDL_Delay(10); continue; @@ -2907,6 +2909,7 @@ static const OptionDef options[] = { { "exitonmousedown", OPT_BOOL | OPT_EXPERT, { (void*)&exit_on_mousedown }, "exit on mouse down", "" }, { "loop", OPT_INT | HAS_ARG | OPT_EXPERT, { (void*)&loop }, "set number of times the playback shall be looped", "loop count" }, { "framedrop", OPT_BOOL | OPT_EXPERT, { (void*)&framedrop }, "drop frames when cpu is too slow", "" }, + { "infbuf", OPT_BOOL | OPT_EXPERT, { (void*)&infinite_buffer }, "don't limit the input buffer size (useful with realtime streams)", "" }, { "window_title", OPT_STRING | HAS_ARG, { (void*)&window_title }, "set window title", "window title" }, #if CONFIG_AVFILTER { "vf", OPT_STRING | HAS_ARG, { (void*)&vfilters }, "video filters", "filter list" }, |