Makes max exoplayer pool size to a variable in the class

This commit is contained in:
Vitor Pamplona
2025-09-11 11:06:09 -04:00
parent 7f428a9976
commit 2eda4d40e8
2 changed files with 7 additions and 2 deletions

View File

@@ -37,9 +37,9 @@ import java.util.concurrent.ConcurrentLinkedQueue
@OptIn(UnstableApi::class)
class ExoPlayerPool(
val builder: ExoPlayerBuilder,
private val poolSize: Int,
) {
private val playerPool = ConcurrentLinkedQueue<ExoPlayer>()
private val poolSize = SimultaneousPlaybackCalculator.max()
private val poolStartingSize = 3
// Exists to avoid exceptions stopping the coroutine

View File

@@ -33,6 +33,7 @@ import com.vitorpamplona.amethyst.service.playback.pip.BackgroundMedia
import com.vitorpamplona.amethyst.service.playback.playerPool.ExoPlayerBuilder
import com.vitorpamplona.amethyst.service.playback.playerPool.ExoPlayerPool
import com.vitorpamplona.amethyst.service.playback.playerPool.MediaSessionPool
import com.vitorpamplona.amethyst.service.playback.playerPool.SimultaneousPlaybackCalculator
import okhttp3.OkHttpClient
class PlaybackService : MediaSessionService() {
@@ -42,7 +43,11 @@ class PlaybackService : MediaSessionService() {
@OptIn(UnstableApi::class)
fun newPool(okHttp: OkHttpClient): MediaSessionPool =
MediaSessionPool(
ExoPlayerPool(ExoPlayerBuilder(okHttp)),
exoPlayerPool =
ExoPlayerPool(
ExoPlayerBuilder(okHttp),
poolSize = SimultaneousPlaybackCalculator.max(applicationContext),
),
okHttpClient = okHttp,
reset = { session, keepPlaying ->
(session.player as ExoPlayer).apply {