Makes max exoplayer pool size to a variable in the class
This commit is contained in:
+1
-1
@@ -37,9 +37,9 @@ import java.util.concurrent.ConcurrentLinkedQueue
|
|||||||
@OptIn(UnstableApi::class)
|
@OptIn(UnstableApi::class)
|
||||||
class ExoPlayerPool(
|
class ExoPlayerPool(
|
||||||
val builder: ExoPlayerBuilder,
|
val builder: ExoPlayerBuilder,
|
||||||
|
private val poolSize: Int,
|
||||||
) {
|
) {
|
||||||
private val playerPool = ConcurrentLinkedQueue<ExoPlayer>()
|
private val playerPool = ConcurrentLinkedQueue<ExoPlayer>()
|
||||||
private val poolSize = SimultaneousPlaybackCalculator.max()
|
|
||||||
private val poolStartingSize = 3
|
private val poolStartingSize = 3
|
||||||
|
|
||||||
// Exists to avoid exceptions stopping the coroutine
|
// Exists to avoid exceptions stopping the coroutine
|
||||||
|
|||||||
+6
-1
@@ -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.ExoPlayerBuilder
|
||||||
import com.vitorpamplona.amethyst.service.playback.playerPool.ExoPlayerPool
|
import com.vitorpamplona.amethyst.service.playback.playerPool.ExoPlayerPool
|
||||||
import com.vitorpamplona.amethyst.service.playback.playerPool.MediaSessionPool
|
import com.vitorpamplona.amethyst.service.playback.playerPool.MediaSessionPool
|
||||||
|
import com.vitorpamplona.amethyst.service.playback.playerPool.SimultaneousPlaybackCalculator
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
|
|
||||||
class PlaybackService : MediaSessionService() {
|
class PlaybackService : MediaSessionService() {
|
||||||
@@ -42,7 +43,11 @@ class PlaybackService : MediaSessionService() {
|
|||||||
@OptIn(UnstableApi::class)
|
@OptIn(UnstableApi::class)
|
||||||
fun newPool(okHttp: OkHttpClient): MediaSessionPool =
|
fun newPool(okHttp: OkHttpClient): MediaSessionPool =
|
||||||
MediaSessionPool(
|
MediaSessionPool(
|
||||||
ExoPlayerPool(ExoPlayerBuilder(okHttp)),
|
exoPlayerPool =
|
||||||
|
ExoPlayerPool(
|
||||||
|
ExoPlayerBuilder(okHttp),
|
||||||
|
poolSize = SimultaneousPlaybackCalculator.max(applicationContext),
|
||||||
|
),
|
||||||
okHttpClient = okHttp,
|
okHttpClient = okHttp,
|
||||||
reset = { session, keepPlaying ->
|
reset = { session, keepPlaying ->
|
||||||
(session.player as ExoPlayer).apply {
|
(session.player as ExoPlayer).apply {
|
||||||
|
|||||||
Reference in New Issue
Block a user