mirror of
https://github.com/Genymobile/scrcpy
synced 2024-11-15 06:12:53 +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
@ -31,8 +31,14 @@ public final class AudioRawRecorder implements AsyncProcessor {
|
|||||||
final ByteBuffer buffer = ByteBuffer.allocateDirect(READ_SIZE);
|
final ByteBuffer buffer = ByteBuffer.allocateDirect(READ_SIZE);
|
||||||
final MediaCodec.BufferInfo bufferInfo = new MediaCodec.BufferInfo();
|
final MediaCodec.BufferInfo bufferInfo = new MediaCodec.BufferInfo();
|
||||||
|
|
||||||
|
try {
|
||||||
try {
|
try {
|
||||||
capture.start();
|
capture.start();
|
||||||
|
} catch (Throwable t) {
|
||||||
|
// Notify the client that the audio could not be captured
|
||||||
|
streamer.writeDisableStream(false);
|
||||||
|
throw t;
|
||||||
|
}
|
||||||
|
|
||||||
streamer.writeAudioHeader();
|
streamer.writeAudioHeader();
|
||||||
while (!Thread.currentThread().isInterrupted()) {
|
while (!Thread.currentThread().isInterrupted()) {
|
||||||
@ -45,10 +51,6 @@ public final class AudioRawRecorder implements AsyncProcessor {
|
|||||||
|
|
||||||
streamer.writePacket(buffer, bufferInfo);
|
streamer.writePacket(buffer, bufferInfo);
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
|
||||||
// Notify the client that the audio could not be captured
|
|
||||||
streamer.writeDisableStream(false);
|
|
||||||
throw e;
|
|
||||||
} finally {
|
} finally {
|
||||||
capture.stop();
|
capture.stop();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user