diff --git a/server/src/main/java/com/genymobile/scrcpy/AudioRawRecorder.java b/server/src/main/java/com/genymobile/scrcpy/AudioRawRecorder.java index 6108c54b..fdac8b3a 100644 --- a/server/src/main/java/com/genymobile/scrcpy/AudioRawRecorder.java +++ b/server/src/main/java/com/genymobile/scrcpy/AudioRawRecorder.java @@ -32,7 +32,13 @@ public final class AudioRawRecorder implements AsyncProcessor { final MediaCodec.BufferInfo bufferInfo = new MediaCodec.BufferInfo(); try { - capture.start(); + try { + capture.start(); + } catch (Throwable t) { + // Notify the client that the audio could not be captured + streamer.writeDisableStream(false); + throw t; + } streamer.writeAudioHeader(); while (!Thread.currentThread().isInterrupted()) { @@ -45,10 +51,6 @@ public final class AudioRawRecorder implements AsyncProcessor { streamer.writePacket(buffer, bufferInfo); } - } catch (Throwable e) { - // Notify the client that the audio could not be captured - streamer.writeDisableStream(false); - throw e; } finally { capture.stop(); }