Add start() function for recorder

For consistency with the other components, do not start the internal
thread from an init() function.
This commit is contained in:
Romain Vimont
2023-02-23 11:00:34 +01:00
parent 0af71d2bd8
commit ed14c56be4
3 changed files with 26 additions and 11 deletions

View File

@@ -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_V4L2
bool 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);
}