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 17
17
package com.google.firebase.vertexai.common.util
18
18
19
19
import android.media.AudioRecord
20
- import kotlinx.coroutines.delay
21
20
import kotlinx.coroutines.flow.flow
21
+ import kotlinx.coroutines.yield
22
22
23
23
/* *
24
24
* The minimum buffer size for this instance.
@@ -31,17 +31,14 @@ internal val AudioRecord.minBufferSize: Int
31
31
/* *
32
32
* Reads from this [AudioRecord] and returns the data in a flow.
33
33
*
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.
35
35
*/
36
36
internal fun AudioRecord.readAsFlow () = flow {
37
37
val buffer = ByteArray (minBufferSize)
38
- val emptyBuffer = ByteArray (minBufferSize)
39
38
40
39
while (true ) {
41
40
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 ()
45
42
continue
46
43
}
47
44
You can’t perform that action at this time.
0 commit comments