Validate capture format and diagnose capture thread failures
This commit is contained in:
1 parent
be8dbcf25e
commit
5092bdf9fe
2 files changed
+15
-19
No files matched your search
@@ -82,8 +82,14 @@ class AudioRecorderManager {
|
||||
var totalRead = 0L
|
||||
|
||||
while (isRecording && device.recordingState == AudioRecord.RECORDSTATE_RECORDING) {
|
||||
val read = device.read(buffer, 0, FRAME_SAMPLES)
|
||||
if (read <= 0) break
|
||||
val read = try { device.read(buffer, 0, FRAME_SAMPLES) } catch (e: Exception) {
|
||||
if (isRecording) LogManager.addLog("ERROR", "AudioRecorder", "capture read failed: ${e.message}")
|
||||
break
|
||||
}
|
||||
if (read <= 0) {
|
||||
if (isRecording) LogManager.addLog("ERROR", "AudioRecorder", "capture read failed code=$read")
|
||||
break
|
||||
}
|
||||
NativeLib.voiceFeed(buffer.copyOf(read))
|
||||
totalRead += read
|
||||
}
|
||||
@@ -101,7 +107,7 @@ class AudioRecorderManager {
|
||||
isRecording = false
|
||||
|
||||
audioRecord?.apply {
|
||||
try { stop() } catch (_: Exception) {}
|
||||
try { stop() } catch (e: Exception) { LogManager.addLog("WARN", "AudioRecorder", "capture stop failed: ${e.message}") }
|
||||
}
|
||||
recordingThread?.join()
|
||||
recordingThread = null
|
||||
@@ -118,7 +124,7 @@ class AudioRecorderManager {
|
||||
isRecording = false
|
||||
|
||||
audioRecord?.apply {
|
||||
try { stop() } catch (_: Exception) {}
|
||||
try { stop() } catch (e: Exception) { LogManager.addLog("WARN", "AudioRecorder", "capture cancel failed: ${e.message}") }
|
||||
}
|
||||
recordingThread?.join()
|
||||
recordingThread = null
|
||||
|
||||
Reference in new issue
Block a user