Skip to content

Commit c0e6d25

Browse files
committed
Formatting
1 parent 6ad6e02 commit c0e6d25

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@
1717
package com.google.firebase.ai.common.util
1818

1919
import android.media.AudioRecord
20-
import kotlin.time.Duration.Companion.milliseconds
2120
import kotlinx.coroutines.delay
22-
import kotlinx.coroutines.flow.callbackFlow
2321
import kotlinx.coroutines.flow.flow
24-
import kotlinx.coroutines.isActive
25-
import kotlinx.coroutines.yield
2622

2723
/**
2824
* The minimum buffer size for this instance.

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,10 @@ internal class AudioHelper(
162162
fun build(): AudioHelper {
163163
val playbackTrack =
164164
AudioTrack(
165-
AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_MEDIA).setContentType(AudioAttributes.CONTENT_TYPE_SPEECH).build(),
165+
AudioAttributes.Builder()
166+
.setUsage(AudioAttributes.USAGE_MEDIA)
167+
.setContentType(AudioAttributes.CONTENT_TYPE_SPEECH)
168+
.build(),
166169
AudioFormat.Builder()
167170
.setSampleRate(24000)
168171
.setChannelMask(AudioFormat.CHANNEL_OUT_MONO)

firebase-ai/src/main/kotlin/com/google/firebase/ai/type/LiveSession.kt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,13 @@ import io.ktor.client.plugins.websocket.DefaultClientWebSocketSession
3838
import io.ktor.websocket.Frame
3939
import io.ktor.websocket.close
4040
import io.ktor.websocket.readBytes
41-
import kotlinx.coroutines.CoroutineName
4241
import java.util.concurrent.ConcurrentLinkedQueue
42+
import java.util.concurrent.Executors
43+
import java.util.concurrent.ThreadFactory
4344
import java.util.concurrent.atomic.AtomicBoolean
45+
import java.util.concurrent.atomic.AtomicLong
4446
import kotlin.coroutines.CoroutineContext
47+
import kotlinx.coroutines.CoroutineName
4548
import kotlinx.coroutines.CoroutineScope
4649
import kotlinx.coroutines.asCoroutineDispatcher
4750
import kotlinx.coroutines.cancel
@@ -61,9 +64,6 @@ import kotlinx.serialization.ExperimentalSerializationApi
6164
import kotlinx.serialization.Serializable
6265
import kotlinx.serialization.encodeToString
6366
import kotlinx.serialization.json.Json
64-
import java.util.concurrent.Executors
65-
import java.util.concurrent.ThreadFactory
66-
import java.util.concurrent.atomic.AtomicLong
6767

6868
/** Represents a live WebSocket session capable of streaming content to and from the server. */
6969
@PublicPreviewAPI
@@ -85,8 +85,8 @@ internal constructor(
8585
/**
8686
* Coroutine scope that we batch data on for audio recording and playback.
8787
*
88-
* Separate from [networkScope] to ensure interchanging of dispatchers doesn't
89-
* cause any deadlocks or issues.
88+
* Separate from [networkScope] to ensure interchanging of dispatchers doesn't cause any deadlocks
89+
* or issues.
9090
*
9191
* Makes it easy to stop all the work with [stopAudioConversation] by just cancelling the scope.
9292
*/
@@ -156,7 +156,8 @@ internal constructor(
156156
)
157157
return@catchAsync
158158
}
159-
networkScope = CoroutineScope(blockingDispatcher + childJob() + CoroutineName("LiveSession Network"))
159+
networkScope =
160+
CoroutineScope(blockingDispatcher + childJob() + CoroutineName("LiveSession Network"))
160161
audioScope = CoroutineScope(audioDispatcher + childJob() + CoroutineName("LiveSession Audio"))
161162
audioHelper = AudioHelper.build()
162163

@@ -513,7 +514,8 @@ internal constructor(
513514
AudioFormat.ENCODING_PCM_16BIT
514515
)
515516
@SuppressLint("ThreadPoolCreation")
516-
val audioDispatcher = Executors.newCachedThreadPool(AudioThreadFactory()).asCoroutineDispatcher()
517+
val audioDispatcher =
518+
Executors.newCachedThreadPool(AudioThreadFactory()).asCoroutineDispatcher()
517519
}
518520
}
519521

@@ -545,4 +547,4 @@ internal class AudioThreadFactory : ThreadFactory {
545547
return builder.penaltyLog().build()
546548
}
547549
}
548-
}
550+
}

0 commit comments

Comments
 (0)