From 0983f0a194db154823842a4728f3c2bb5a3b1cc3 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Tue, 1 Aug 2023 12:05:16 +0200 Subject: [PATCH] Report device disconnection on audio EOS If --no-video was set, then device disconnection was not reported. To avoid the problem, report device disconnection also on audio end-of-stream (EOS). If both video and audio are enabled, then a device disconnection event will be sent twice, but only the first one will be handled (since it makes scrcpy exit). Fixes #4207 --- app/src/scrcpy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index d68a2424..aabb7c5a 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -252,7 +252,9 @@ sc_audio_demuxer_on_ended(struct sc_demuxer *demuxer, // Contrary to the video demuxer, keep mirroring if only the audio fails // (unless --require-audio is set). - if (status == SC_DEMUXER_STATUS_ERROR + if (status == SC_DEMUXER_STATUS_EOS) { + PUSH_EVENT(SC_EVENT_DEVICE_DISCONNECTED); + } else if (status == SC_DEMUXER_STATUS_ERROR || (status == SC_DEMUXER_STATUS_DISABLED && options->require_audio)) { PUSH_EVENT(SC_EVENT_DEMUXER_ERROR);