File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed
firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/common/util Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change 1717package com.google.firebase.vertexai.common.util
1818
1919import android.media.AudioRecord
20- import kotlinx.coroutines.delay
2120import 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 */
3636internal 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
You can’t perform that action at this time.
0 commit comments