Fix(player): add exoplayer fallback for all 4k playback when MPV software decoding is enabled (#761)

## Description
Updates the logic in the Prefer MPV setting to prevent performance
issues when software decoding is selected. When the MPV backend is
configured to use software decoding, the app will now automatically
fallback to ExoPlayer for 4K content. Most Android TV devices cannot
smoothly render 4K video via software decoding, so falling back to
Exoplayer for this content makes sense in most cases when using the
software renderer. This mirrors the existing fallback mechanism used for
HDR content.

### Related issues
N/A

### Screenshots
N/A

### AI/LLM usage
None

---------

Co-authored-by: Ray <154766448+damontecres@users.noreply.github.com>
This commit is contained in:
Justin Caveda 2026-01-29 16:11:13 -06:00 committed by GitHub
parent abd8235556
commit e7ed173692
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 4 deletions

View file

@ -207,7 +207,11 @@ class PlaybackViewModel
jobs.forEach { it.cancel() }
}
private suspend fun createPlayer(isHdr: Boolean) {
private suspend fun createPlayer(
isHdr: Boolean,
is4k: Boolean,
) {
val softwareDecoding = !preferences.appPreferences.playbackPreferences.mpvOptions.enableHardwareDecoding
val playerBackend =
when (preferences.appPreferences.playbackPreferences.playerBackend) {
PlayerBackend.UNRECOGNIZED,
@ -216,7 +220,7 @@ class PlaybackViewModel
PlayerBackend.MPV -> PlayerBackend.MPV
PlayerBackend.PREFER_MPV -> if (isHdr) PlayerBackend.EXO_PLAYER else PlayerBackend.MPV
PlayerBackend.PREFER_MPV -> if (isHdr || (is4k && softwareDecoding)) PlayerBackend.EXO_PLAYER else PlayerBackend.MPV
}
Timber.d("Selected backend: %s", playerBackend)
@ -428,11 +432,13 @@ class PlaybackViewModel
val isHdr =
it.videoRange == VideoRange.HDR ||
(it.videoRangeType != VideoRangeType.SDR && it.videoRangeType != VideoRangeType.UNKNOWN)
SimpleVideoStream(it.index, isHdr)
// Often times 4k movies have a wider aspect ratio so the height is lower even though the width is still 3840
val is4k = (it.width ?: 0) > 2560 || (it.height ?: 0) > 1440
SimpleVideoStream(it.index, isHdr, is4k)
}
// Create the correct player for the media
createPlayer(videoStream?.hdr == true)
createPlayer(videoStream?.hdr == true, videoStream?.is4k == true)
val subtitleStreams =
mediaSource.mediaStreams

View file

@ -27,4 +27,5 @@ data class SimpleMediaStream(
data class SimpleVideoStream(
val index: Int,
val hdr: Boolean,
val is4k: Boolean,
)