feat(hwdec): Set default codec to SW for WSA clients

This commit is contained in:
Quickdesh 2023-12-07 00:11:54 -05:00 committed by jmir1
parent e82ee87645
commit 56e806f3ba
No known key found for this signature in database
GPG key ID: 7B3B624787A072BD
4 changed files with 14 additions and 58 deletions

View file

@ -1,6 +1,7 @@
package eu.kanade.tachiyomi
import android.content.Context
import android.os.Build
import androidx.core.content.edit
import androidx.preference.PreferenceManager
import eu.kanade.domain.base.BasePreferences
@ -14,6 +15,7 @@ import eu.kanade.tachiyomi.data.track.TrackerManager
import eu.kanade.tachiyomi.network.NetworkPreferences
import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE
import eu.kanade.tachiyomi.ui.player.settings.PlayerPreferences
import eu.kanade.tachiyomi.ui.player.viewer.HwDecState
import eu.kanade.tachiyomi.ui.reader.setting.ReaderOrientation
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
import eu.kanade.tachiyomi.util.system.DeviceUtil
@ -535,6 +537,10 @@ object Migrations {
filterPredicate = { it.key in prefsToReplace },
newKey = { Preference.appStateKey(it) },
)
if (Build.MODEL == "Subsystem for Android(TM)") {
playerPreferences.hwDec().set(HwDecState.SW.mpvValue)
}
}
return true
}

View file

@ -1,56 +0,0 @@
package eu.kanade.tachiyomi.ui.player.settings.dialogs
import android.os.Build
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import eu.kanade.tachiyomi.ui.player.viewer.HwDecState
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.RadioItem
@Composable
fun DefaultDecoderDialog(
currentDecoder: String,
onSelectDecoder: (String) -> Unit,
onDismissRequest: () -> Unit,
) {
val items = mutableListOf(
Pair("${HwDecState.HW.title} (${HwDecState.HW.mpvValue})", HwDecState.HW.mpvValue),
Pair(HwDecState.SW.title, HwDecState.SW.mpvValue),
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
items.add(
index = 0,
Pair(
"${HwDecState.HW_PLUS.title} (${HwDecState.HW_PLUS.mpvValue})",
HwDecState.HW_PLUS.mpvValue,
),
)
}
fun selectDecoder(decoder: String) {
onSelectDecoder(decoder)
onDismissRequest()
}
PlayerDialog(
titleRes = MR.strings.player_hwdec_mode,
modifier = Modifier.fillMaxWidth(fraction = 0.8F),
onDismissRequest = onDismissRequest,
) {
Column {
items.forEach {
Spacer(Modifier.height(16.dp))
RadioItem(
label = it.first,
selected = it.second == currentDecoder,
onClick = { selectDecoder(it.second) },
)
}
}
}
}

View file

@ -134,7 +134,7 @@ fun PlayerSettingsSheet(
modifier = Modifier.padding(vertical = MaterialTheme.padding.tiny),
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
) {
PlayerStatsPage.values().forEach {
PlayerStatsPage.entries.forEach {
FilterChip(
selected = statisticsPage == it.page,
onClick = { togglePlayerStatsPage(it.page) },

View file

@ -62,7 +62,13 @@ enum class HwDecState(val title: String, val mpvValue: String) {
companion object {
internal val isHwSupported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
internal val defaultHwDec = if (isHwSupported) HW_PLUS else HW
private val isWSA = Build.MODEL == "Subsystem for Android(TM)"
internal val defaultHwDec = when {
isHwSupported -> HW_PLUS
isWSA -> SW
else -> HW
}
}
}