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
@ -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…
x
Reference in New Issue
Block a user