Skip to content

Commit 8f199ef

Browse files
committed
Revert "Update android.kt"
This reverts commit 644a50b.
1 parent 0a1a48a commit 8f199ef

File tree

1 file changed

+3
-6
lines changed
  • firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/common/util

1 file changed

+3
-6
lines changed

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/common/util/android.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
package com.google.firebase.vertexai.common.util
1818

1919
import android.media.AudioRecord
20-
import kotlinx.coroutines.delay
2120
import kotlinx.coroutines.flow.flow
21+
import kotlinx.coroutines.yield
2222

2323
/**
2424
* The minimum buffer size for this instance.
@@ -31,17 +31,14 @@ internal val AudioRecord.minBufferSize: Int
3131
/**
3232
* Reads from this [AudioRecord] and returns the data in a flow.
3333
*
34-
* Will emit a zeroed out buffer every 100ms when this instance is not recording.
34+
* Will emit a zeroed out buffer when this instance is not recording.
3535
*/
3636
internal fun AudioRecord.readAsFlow() = flow {
3737
val buffer = ByteArray(minBufferSize)
38-
val emptyBuffer = ByteArray(minBufferSize)
3938

4039
while (true) {
4140
if (recordingState != AudioRecord.RECORDSTATE_RECORDING) {
42-
emit(emptyBuffer)
43-
// The model will close the connection if you spam it too fast
44-
delay(100)
41+
yield()
4542
continue
4643
}
4744

0 commit comments

Comments
 (0)