Store the recording request in a local bool

This avoids to test explicitly whether options->record_filename is NULL.
This commit is contained in:
Romain Vimont 2019-03-02 18:18:12 +01:00
parent 8aeb5c0e3c
commit e7b7b083aa

View file

@ -174,10 +174,10 @@ av_log_callback(void *avcl, int level, const char *fmt, va_list vl) {
} }
SDL_bool scrcpy(const struct scrcpy_options *options) { SDL_bool scrcpy(const struct scrcpy_options *options) {
SDL_bool send_frame_meta = !!options->record_filename; SDL_bool record = !!options->record_filename;
if (!server_start(&server, options->serial, options->port, if (!server_start(&server, options->serial, options->port,
options->max_size, options->bit_rate, options->crop, options->max_size, options->bit_rate, options->crop,
send_frame_meta)) { record)) {
return SDL_FALSE; return SDL_FALSE;
} }
@ -228,7 +228,7 @@ SDL_bool scrcpy(const struct scrcpy_options *options) {
} }
struct recorder *rec = NULL; struct recorder *rec = NULL;
if (options->record_filename) { if (record) {
if (!recorder_init(&recorder, if (!recorder_init(&recorder,
options->record_filename, options->record_filename,
options->record_format, options->record_format,
@ -292,7 +292,7 @@ finally_stop_decoder:
server_stop(&server); server_stop(&server);
decoder_join(&decoder); decoder_join(&decoder);
finally_destroy_recorder: finally_destroy_recorder:
if (options->record_filename) { if (record) {
recorder_destroy(&recorder); recorder_destroy(&recorder);
} }
finally_destroy_file_handler: finally_destroy_file_handler: