Fix recorder waiting when stream disabled

In the recorder, if the video or audio stream is disabled, do not wait
for its initialization (it will never happen) to process the header.

In that case (scrcpy --no-audio --record=file.mp4), this caused the
whole content to be buffered in memory, and written only on exit.
This commit is contained in:
Romain Vimont 2023-06-03 15:09:46 +02:00
parent 379caf8551
commit 9d3c656414

View file

@ -178,9 +178,10 @@ static bool
sc_recorder_process_header(struct sc_recorder *recorder) { sc_recorder_process_header(struct sc_recorder *recorder) {
sc_mutex_lock(&recorder->mutex); sc_mutex_lock(&recorder->mutex);
while (!recorder->stopped && (!recorder->video_init while (!recorder->stopped &&
|| !recorder->audio_init ((recorder->video && !recorder->video_init)
|| sc_recorder_has_empty_queues(recorder))) { || (recorder->audio && !recorder->audio_init)
|| sc_recorder_has_empty_queues(recorder))) {
sc_cond_wait(&recorder->cond, &recorder->mutex); sc_cond_wait(&recorder->cond, &recorder->mutex);
} }