From 179642d78b2796d165ac4cc7feff23bb7bf2987d Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 26 Apr 2026 16:54:26 +0000 Subject: [PATCH] fix(playback): hoist DataSourceBitmapLoader build into a function Android Lint's UnsafeOptInUsageError doesn't recognize @OptIn placed on a `by lazy` property as covering the lambda body, so each Media3 unstable-API call inside the initializer (Builder, setExecutorService, setDataSourceFactory, build) was flagged. Move the construction into a real function carrying the @OptIn annotation; the lazy delegate just calls it. No behavior change. --- .../service/playback/playerPool/MediaSessionPool.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/playback/playerPool/MediaSessionPool.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/playback/playerPool/MediaSessionPool.kt index cda75c6ce..290ab7bc9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/playback/playerPool/MediaSessionPool.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/playback/playerPool/MediaSessionPool.kt @@ -81,14 +81,17 @@ class MediaSessionPool( // The bitmap loader is stateless w.r.t. the session; a fresh allocation per session was // pure noise. ExoPlayer's DEFAULT_EXECUTOR_SERVICE is a process-wide singleton, the // dataSourceFactory is owned by the pool, and the appContext is already retained. + // The init is in a separate function so the @OptIn lands on a real declaration — + // applying it to a `by lazy` property doesn't propagate into the lambda body. + private val sharedBitmapLoader by lazy { buildSharedBitmapLoader() } + @OptIn(UnstableApi::class) - private val sharedBitmapLoader by lazy { + private fun buildSharedBitmapLoader(): DataSourceBitmapLoader = DataSourceBitmapLoader .Builder(appContext) .setExecutorService(DataSourceBitmapLoader.DEFAULT_EXECUTOR_SERVICE.get()) .setDataSourceFactory(dataSourceFactory) .build() - } // protects from LruCache killing playing sessions private val playingMap = mutableMapOf()