mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-03 14:49:29 +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:
parent
9d5f53caa7
commit
420d3a40dd
1 changed files with 7 additions and 5 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue