File tree Expand file tree Collapse file tree 2 files changed +4
-5
lines changed
firebase-ai/src/main/kotlin/com/google/firebase/ai Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -42,15 +42,13 @@ internal fun AudioRecord.readAsFlow() = callbackFlow {
4242
4343 while (isActive) {
4444 if (recordingState != AudioRecord .RECORDSTATE_RECORDING ) {
45- // TODO(vguthal): Investigate if both yield and delay are required.
46- delay(10 .milliseconds)
47- yield ()
45+ delay(0 )
4846 continue
4947 }
5048 val bytesRead = read(buffer, 0 , buffer.size)
5149 if (bytesRead > 0 ) {
5250 send(buffer.copyOf(bytesRead))
5351 }
54- yield ( )
52+ delay( 0 )
5553 }
5654}
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ import kotlinx.coroutines.CoroutineScope
4141import kotlinx.coroutines.Dispatchers
4242import kotlinx.coroutines.cancel
4343import kotlinx.coroutines.channels.Channel.Factory.UNLIMITED
44+ import kotlinx.coroutines.delay
4445import kotlinx.coroutines.flow.Flow
4546import kotlinx.coroutines.flow.buffer
4647import kotlinx.coroutines.flow.catch
@@ -411,7 +412,7 @@ internal constructor(
411412 if (! enableInterruptions) {
412413 audioHelper?.resumeRecording()
413414 }
414- yield ( )
415+ delay( 0 )
415416 } else {
416417 println (" Playing audio data" )
417418 /* *
You can’t perform that action at this time.
0 commit comments