@@ -38,10 +38,13 @@ import io.ktor.client.plugins.websocket.DefaultClientWebSocketSession
3838import io.ktor.websocket.Frame
3939import io.ktor.websocket.close
4040import io.ktor.websocket.readBytes
41- import kotlinx.coroutines.CoroutineName
4241import java.util.concurrent.ConcurrentLinkedQueue
42+ import java.util.concurrent.Executors
43+ import java.util.concurrent.ThreadFactory
4344import java.util.concurrent.atomic.AtomicBoolean
45+ import java.util.concurrent.atomic.AtomicLong
4446import kotlin.coroutines.CoroutineContext
47+ import kotlinx.coroutines.CoroutineName
4548import kotlinx.coroutines.CoroutineScope
4649import kotlinx.coroutines.asCoroutineDispatcher
4750import kotlinx.coroutines.cancel
@@ -61,9 +64,6 @@ import kotlinx.serialization.ExperimentalSerializationApi
6164import kotlinx.serialization.Serializable
6265import kotlinx.serialization.encodeToString
6366import 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