summaryrefslogtreecommitdiffstats
path: root/ffplay.c
diff options
context:
space:
mode:
authorGanesh Ajjanagadde <gajjanagadde@gmail.com>2015-10-03 07:34:49 -0500
committerMarton Balint <cus@passwd.hu>2015-10-03 17:43:24 +0200
commit8dc6e92c3dc67a85026f3010045c7a28b1c0adc8 (patch)
tree4464615829adbfe5cd77a1cfadfc03abdcb7cc12 /ffplay.c
parent64508b9af240ece9f5fef7fa4a371dff55222733 (diff)
downloadffmpeg-streaming-8dc6e92c3dc67a85026f3010045c7a28b1c0adc8.zip
ffmpeg-streaming-8dc6e92c3dc67a85026f3010045c7a28b1c0adc8.tar.gz
ffplay: more robust mutex, condition variable handling
SDL_CreateMutex and SDL_CreateCond can fail: https://wiki.libsdl.org/SDL_CreateMutex. This patch makes handling more robust in one instance. Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'ffplay.c')
-rw-r--r--ffplay.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/ffplay.c b/ffplay.c
index 3c2407f..b7b2b0b 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -451,12 +451,21 @@ static int packet_queue_put_nullpacket(PacketQueue *q, int stream_index)
}
/* packet queue handling */
-static void packet_queue_init(PacketQueue *q)
+static int packet_queue_init(PacketQueue *q)
{
memset(q, 0, sizeof(PacketQueue));
q->mutex = SDL_CreateMutex();
+ if (!q->mutex) {
+ av_log(q, AV_LOG_FATAL, "SDL_CreateMutex(): %s\n", SDL_GetError());
+ return AVERROR(ENOMEM);
+ }
q->cond = SDL_CreateCond();
+ if (!q->cond) {
+ av_log(q, AV_LOG_FATAL, "SDL_CreateCond(): %s\n", SDL_GetError());
+ return AVERROR(ENOMEM);
+ }
q->abort_request = 1;
+ return 0;
}
static void packet_queue_flush(PacketQueue *q)
@@ -3136,9 +3145,10 @@ static VideoState *stream_open(const char *filename, AVInputFormat *iformat)
if (frame_queue_init(&is->sampq, &is->audioq, SAMPLE_QUEUE_SIZE, 1) < 0)
goto fail;
- packet_queue_init(&is->videoq);
- packet_queue_init(&is->audioq);
- packet_queue_init(&is->subtitleq);
+ if (packet_queue_init(&is->videoq) < 0 ||
+ packet_queue_init(&is->audioq) < 0 ||
+ packet_queue_init(&is->subtitleq) < 0)
+ goto fail;
is->continue_read_thread = SDL_CreateCond();
OpenPOWER on IntegriCloud