mirror of
https://github.com/Genymobile/scrcpy
synced 2025-08-30 13:58:08 +00:00
Fix error handling in raw audio recorder
It is incorret to ever call: streamer.writeDisableStream(...); after: streamer.writeAudioHeader(); Move the try-catch block so that it can never happen.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user