From 523097eadf6fb276909df518ed1086ab427cee6b Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 9 Feb 2018 13:29:48 +0100 Subject: [PATCH] Provide decoder_init() Expose an initializer so that the caller does not have to guess what fields must be initialized. --- app/src/decoder.c | 5 +++++ app/src/decoder.h | 1 + app/src/scrcpy.c | 3 +-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/decoder.c b/app/src/decoder.c index 2aeab773..34c7034e 100644 --- a/app/src/decoder.c +++ b/app/src/decoder.c @@ -140,6 +140,11 @@ run_finally_free_codec_ctx: return ret; } +void decoder_init(struct decoder *decoder, struct frames *frames, TCPsocket video_socket) { + decoder->frames = frames; + decoder->video_socket = video_socket; +} + SDL_bool decoder_start(struct decoder *decoder) { SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Starting decoder thread"); diff --git a/app/src/decoder.h b/app/src/decoder.h index 59a59d75..04ff14a6 100644 --- a/app/src/decoder.h +++ b/app/src/decoder.h @@ -13,6 +13,7 @@ struct decoder { SDL_mutex *mutex; }; +void decoder_init(struct decoder *decoder, struct frames *frames, TCPsocket video_socket); SDL_bool decoder_start(struct decoder *decoder); void decoder_stop(struct decoder *decoder); void decoder_join(struct decoder *decoder); diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index 924aab99..6a354290 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -129,8 +129,7 @@ SDL_bool scrcpy(const char *serial, Uint16 local_port, Uint16 max_size, Uint32 b goto finally_destroy_server; } - decoder.frames = &frames; - decoder.video_socket = device_socket; + decoder_init(&decoder, &frames, device_socket); // now we consumed the header values, the socket receives the video stream // start the decoder