From bb704ea3fda2635587195bcde044b06056f7fbb4 Mon Sep 17 00:00:00 2001 From: Alexander Capehart Date: Sun, 19 Feb 2023 13:11:54 -0700 Subject: [PATCH] music: fix broken audio info extraction Fix an issue where audio info extraction would break if done consequtively. Accidentally released a global state instance of the extractor. Now that it's a local instance, the issue should not occur. --- .../java/org/oxycblt/auxio/music/metadata/AudioInfo.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/oxycblt/auxio/music/metadata/AudioInfo.kt b/app/src/main/java/org/oxycblt/auxio/music/metadata/AudioInfo.kt index 5f0172ba0..9411c5cfe 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/metadata/AudioInfo.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/metadata/AudioInfo.kt @@ -57,12 +57,13 @@ data class AudioInfo( */ class AudioInfoProviderImpl @Inject constructor(@ApplicationContext private val context: Context) : AudioInfo.Provider { - // While we would use ExoPlayer to extract this information, it doesn't support - // common data like bit rate in progressive data sources due to there being no - // demand. Thus, we are stuck with the inferior OS-provided MediaExtractor. - private val extractor = MediaExtractor() override suspend fun extract(song: Song): AudioInfo { + // While we would use ExoPlayer to extract this information, it doesn't support + // common data like bit rate in progressive data sources due to there being no + // demand. Thus, we are stuck with the inferior OS-provided MediaExtractor. + val extractor = MediaExtractor() + try { extractor.setDataSource(context, song.uri, emptyMap()) } catch (e: Exception) {