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 317a5e93bb
commit 84f1792c6f
3 changed files with 26 additions and 11 deletions

View File

@@ -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;
}
void
sc_recorder_stop(struct sc_recorder *recorder) {
sc_mutex_lock(&recorder->mutex);