Skip to content

Commit 25a69fb

Browse files
Replace coroutineContext with currentCoroutineContext (#3270)
1 parent b70be0d commit 25a69fb

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

core/playback/src/main/kotlin/voice/core/playback/PlayerController.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import kotlinx.coroutines.CancellationException
1111
import kotlinx.coroutines.CoroutineScope
1212
import kotlinx.coroutines.Deferred
1313
import kotlinx.coroutines.Dispatchers
14+
import kotlinx.coroutines.currentCoroutineContext
1415
import kotlinx.coroutines.ensureActive
1516
import kotlinx.coroutines.flow.first
1617
import kotlinx.coroutines.guava.asDeferred
@@ -27,7 +28,6 @@ import voice.core.playback.session.MediaItemProvider
2728
import voice.core.playback.session.PlaybackService
2829
import voice.core.playback.session.sendCustomCommand
2930
import voice.core.playback.session.toMediaIdOrNull
30-
import kotlin.coroutines.coroutineContext
3131
import kotlin.time.Duration
3232

3333
@Inject
@@ -168,7 +168,7 @@ class PlayerController(
168168
return try {
169169
controller.await()
170170
} catch (e: Exception) {
171-
if (e is CancellationException) coroutineContext.ensureActive()
171+
if (e is CancellationException) currentCoroutineContext().ensureActive()
172172
Logger.w(e, "Error while connecting to media controller")
173173
null
174174
}

core/scanner/src/main/kotlin/voice/core/scanner/CoverExtractor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import androidx.media3.extractor.metadata.id3.ApicFrame
1010
import androidx.media3.inspector.MetadataRetriever
1111
import dev.zacsweers.metro.Inject
1212
import kotlinx.coroutines.CancellationException
13+
import kotlinx.coroutines.currentCoroutineContext
1314
import kotlinx.coroutines.ensureActive
1415
import kotlinx.coroutines.guava.await
1516
import voice.core.logging.api.Logger
1617
import voice.core.scanner.matroska.MatroskaCoverExtractor
1718
import java.io.File
18-
import kotlin.coroutines.coroutineContext
1919

2020
@Inject
2121
internal class CoverExtractor(
@@ -76,7 +76,7 @@ internal class CoverExtractor(
7676
.retrieveTrackGroups()
7777
.await()
7878
} catch (e: Exception) {
79-
if (e is CancellationException) coroutineContext.ensureActive()
79+
if (e is CancellationException) currentCoroutineContext().ensureActive()
8080
Logger.w(e, "Error retrieving metadata")
8181
null
8282
}

core/scanner/src/main/kotlin/voice/core/scanner/MediaAnalyzer.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import androidx.media3.extractor.metadata.vorbis.VorbisComment
1515
import androidx.media3.inspector.MetadataRetriever
1616
import dev.zacsweers.metro.Inject
1717
import kotlinx.coroutines.CancellationException
18+
import kotlinx.coroutines.currentCoroutineContext
1819
import kotlinx.coroutines.ensureActive
1920
import kotlinx.coroutines.guava.await
2021
import voice.core.data.MarkData
@@ -24,7 +25,6 @@ import voice.core.logging.api.Logger
2425
import voice.core.scanner.matroska.MatroskaMetaDataExtractor
2526
import voice.core.scanner.matroska.MatroskaParseException
2627
import voice.core.scanner.mp4.Mp4ChapterExtractor
27-
import kotlin.coroutines.coroutineContext
2828
import kotlin.time.Duration
2929
import kotlin.time.Duration.Companion.microseconds
3030

@@ -204,7 +204,7 @@ internal class MediaAnalyzer(
204204
it.retrieveTrackGroups().await()
205205
}
206206
} catch (e: Exception) {
207-
if (e is CancellationException) coroutineContext.ensureActive()
207+
if (e is CancellationException) currentCoroutineContext().ensureActive()
208208
Logger.w(e, "Error retrieving metadata")
209209
null
210210
}
@@ -219,7 +219,7 @@ internal class MediaAnalyzer(
219219
it.retrieveDurationUs().await().microseconds
220220
}
221221
} catch (e: Exception) {
222-
if (e is CancellationException) coroutineContext.ensureActive()
222+
if (e is CancellationException) currentCoroutineContext().ensureActive()
223223
Logger.w(e, "Error retrieving metadata")
224224
null
225225
}

0 commit comments

Comments
 (0)