From bf41e5479b12252b0903a1e777d21019c49d7419 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Thu, 15 Feb 2018 22:56:32 +0100 Subject: [PATCH] Improve decoder stopped event The syntax was correct, but less readable, and it unnecessarily zeroed the fields other than "type". Create the event properly, from a separate method. --- app/src/decoder.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/decoder.c b/app/src/decoder.c index afab344c..c3700006 100644 --- a/app/src/decoder.c +++ b/app/src/decoder.c @@ -33,6 +33,12 @@ static void push_frame(struct decoder *decoder) { SDL_PushEvent(&new_frame_event); } +static void notify_stopped(void) { + SDL_Event stop_event; + stop_event.type = EVENT_DECODER_STOPPED; + SDL_PushEvent(&stop_event); +} + static int run_decoder(void *data) { struct decoder *decoder = data; int ret = 0; @@ -137,7 +143,7 @@ run_finally_close_codec: avcodec_close(codec_ctx); run_finally_free_codec_ctx: avcodec_free_context(&codec_ctx); - SDL_PushEvent(&(SDL_Event) {.type = EVENT_DECODER_STOPPED}); + notify_stopped(); return ret; }