Skip to content

Commit c8fb925

Browse files
committed
illegal state exception
1 parent 581a196 commit c8fb925

File tree

1 file changed

+4
-2
lines changed
  • firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type

1 file changed

+4
-2
lines changed

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/AudioHelper.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,13 @@ internal class AudioHelper {
7070
}
7171

7272
fun stopRecording() {
73-
audioRecord.stop()
73+
if(::audioRecord.isInitialized && audioRecord.recordingState == AudioRecord.RECORDSTATE_RECORDING) {
74+
audioRecord.stop()
75+
}
7476
}
7577

7678
fun start() {
77-
if (::audioRecord.isInitialized) {
79+
if (::audioRecord.isInitialized && audioRecord.recordingState != AudioRecord.RECORDSTATE_RECORDING) {
7880
audioRecord.startRecording()
7981
}
8082
}

0 commit comments

Comments
 (0)