Display and control your Android device
Add start() function for recorder
Romain Vimont3c407773e9dd
diff --git a/app/src/recorder.c b/app/src/recorder.cindex 784ef7ee..aa3aea0e 100644--- a/app/src/recorder.c+++ b/app/src/recorder.c@@ -444,17 +444,8 @@ sc_recorder_init(struct sc_recorder *recorder, const char *filename,recorder->packet_sink.ops = &ops;- ok = sc_thread_create(&recorder->thread, run_recorder, "scrcpy-recorder",- recorder);- if (!ok) {- LOGE("Could not start recorder thread");- goto error_stream_cond_destroy;- }-return true;-error_stream_cond_destroy:- sc_cond_destroy(&recorder->stream_cond);error_queue_cond_destroy:sc_cond_destroy(&recorder->queue_cond);error_mutex_destroy:@@ -465,6 +456,18 @@ error_free_filename:return false;}+bool+sc_recorder_start(struct sc_recorder *recorder) {+ bool ok = sc_thread_create(&recorder->thread, run_recorder,+ "scrcpy-recorder", recorder);+ if (!ok) {+ LOGE("Could not start recorder thread");+ return false;+ }++ return true;+}+voidsc_recorder_stop(struct sc_recorder *recorder) {sc_mutex_lock(&recorder->mutex);diff --git a/app/src/recorder.h b/app/src/recorder.hindex cab71678..e98d0ea2 100644--- a/app/src/recorder.h+++ b/app/src/recorder.h@@ -54,6 +54,9 @@ sc_recorder_init(struct sc_recorder *recorder, const char *filename,struct sc_size declared_frame_size,const struct sc_recorder_callbacks *cbs, void *cbs_userdata);+bool+sc_recorder_start(struct sc_recorder *recorder);+voidsc_recorder_stop(struct sc_recorder *recorder);diff --git a/app/src/scrcpy.c b/app/src/scrcpy.cindex 90c6bd9b..b636a03a 100644--- a/app/src/scrcpy.c+++ b/app/src/scrcpy.c@@ -277,6 +277,7 @@ scrcpy(struct scrcpy_options *options) {bool server_started = false;bool file_pusher_initialized = false;bool recorder_initialized = false;+ bool recorder_started = false;#ifdef HAVE_V4L2bool v4l2_sink_initialized = false;#endif@@ -401,8 +402,14 @@ scrcpy(struct scrcpy_options *options) {&recorder_cbs, NULL)) {goto end;}- rec = &s->recorder;recorder_initialized = true;++ if (!sc_recorder_start(&s->recorder)) {+ goto end;+ }+ recorder_started = true;++ rec = &s->recorder;}static const struct sc_demuxer_callbacks demuxer_cbs = {@@ -708,8 +715,10 @@ end:sc_controller_destroy(&s->controller);}- if (recorder_initialized) {+ if (recorder_started) {sc_recorder_join(&s->recorder);+ }+ if (recorder_initialized) {sc_recorder_destroy(&s->recorder);}