mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
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:
parent
abd8235556
commit
e7ed173692
2 changed files with 11 additions and 4 deletions
|
|
@ -207,7 +207,11 @@ class PlaybackViewModel
|
||||||
jobs.forEach { it.cancel() }
|
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 =
|
val playerBackend =
|
||||||
when (preferences.appPreferences.playbackPreferences.playerBackend) {
|
when (preferences.appPreferences.playbackPreferences.playerBackend) {
|
||||||
PlayerBackend.UNRECOGNIZED,
|
PlayerBackend.UNRECOGNIZED,
|
||||||
|
|
@ -216,7 +220,7 @@ class PlaybackViewModel
|
||||||
|
|
||||||
PlayerBackend.MPV -> PlayerBackend.MPV
|
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)
|
Timber.d("Selected backend: %s", playerBackend)
|
||||||
|
|
@ -428,11 +432,13 @@ class PlaybackViewModel
|
||||||
val isHdr =
|
val isHdr =
|
||||||
it.videoRange == VideoRange.HDR ||
|
it.videoRange == VideoRange.HDR ||
|
||||||
(it.videoRangeType != VideoRangeType.SDR && it.videoRangeType != VideoRangeType.UNKNOWN)
|
(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
|
// Create the correct player for the media
|
||||||
createPlayer(videoStream?.hdr == true)
|
createPlayer(videoStream?.hdr == true, videoStream?.is4k == true)
|
||||||
|
|
||||||
val subtitleStreams =
|
val subtitleStreams =
|
||||||
mediaSource.mediaStreams
|
mediaSource.mediaStreams
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,5 @@ data class SimpleMediaStream(
|
||||||
data class SimpleVideoStream(
|
data class SimpleVideoStream(
|
||||||
val index: Int,
|
val index: Int,
|
||||||
val hdr: Boolean,
|
val hdr: Boolean,
|
||||||
|
val is4k: Boolean,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue