Merge pull request #483 from Schnitzel5/feature/hwdec-settings

added option to change hwdec
This commit is contained in:
Moustapha Kodjo Amadou 2025-06-07 13:35:56 +01:00 committed by GitHub
commit a803ee2ad8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 741 additions and 213 deletions

View file

@ -473,7 +473,6 @@
"continue_to_next_chapter": "Continue scrolling to read the next chapter",
"no_next_chapter": "No next chapter",
"you_have_finished_reading": "You have finished reading",
"return_to_the_list_of_chapters": "Return to the list of chapters"
"return_to_the_list_of_chapters": "Return to the list of chapters",
"hwdec": "Hardware Decoder"
}

View file

@ -2963,6 +2963,12 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'Return to the list of chapters'**
String get return_to_the_list_of_chapters;
/// No description provided for @hwdec.
///
/// In en, this message translates to:
/// **'Hardware Decoder'**
String get hwdec;
}
class _AppLocalizationsDelegate

View file

@ -1514,4 +1514,7 @@ class AppLocalizationsAr extends AppLocalizations {
@override
String get return_to_the_list_of_chapters => 'Return to the list of chapters';
@override
String get hwdec => 'Hardware Decoder';
}

View file

@ -1525,4 +1525,7 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get return_to_the_list_of_chapters => 'Return to the list of chapters';
@override
String get hwdec => 'Hardware Decoder';
}

View file

@ -1514,4 +1514,7 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get return_to_the_list_of_chapters => 'Return to the list of chapters';
@override
String get hwdec => 'Hardware Decoder';
}

View file

@ -1531,6 +1531,9 @@ class AppLocalizationsEs extends AppLocalizations {
@override
String get return_to_the_list_of_chapters => 'Return to the list of chapters';
@override
String get hwdec => 'Hardware Decoder';
}
/// The translations for Spanish Castilian, as used in Latin America and the Caribbean (`es_419`).

View file

@ -1536,4 +1536,7 @@ class AppLocalizationsFr extends AppLocalizations {
@override
String get return_to_the_list_of_chapters =>
'Retournez à la liste des chapitres';
@override
String get hwdec => 'Hardware Decoder';
}

View file

@ -1520,4 +1520,7 @@ class AppLocalizationsId extends AppLocalizations {
@override
String get return_to_the_list_of_chapters => 'Return to the list of chapters';
@override
String get hwdec => 'Hardware Decoder';
}

View file

@ -1530,4 +1530,7 @@ class AppLocalizationsIt extends AppLocalizations {
@override
String get return_to_the_list_of_chapters => 'Return to the list of chapters';
@override
String get hwdec => 'Hardware Decoder';
}

View file

@ -1528,6 +1528,9 @@ class AppLocalizationsPt extends AppLocalizations {
@override
String get return_to_the_list_of_chapters => 'Return to the list of chapters';
@override
String get hwdec => 'Hardware Decoder';
}
/// The translations for Portuguese, as used in Brazil (`pt_BR`).

View file

@ -1530,4 +1530,7 @@ class AppLocalizationsRu extends AppLocalizations {
@override
String get return_to_the_list_of_chapters => 'Return to the list of chapters';
@override
String get hwdec => 'Hardware Decoder';
}

View file

@ -1515,4 +1515,7 @@ class AppLocalizationsTh extends AppLocalizations {
@override
String get return_to_the_list_of_chapters => 'Return to the list of chapters';
@override
String get hwdec => 'Hardware Decoder';
}

View file

@ -1521,4 +1521,7 @@ class AppLocalizationsTr extends AppLocalizations {
@override
String get return_to_the_list_of_chapters => 'Return to the list of chapters';
@override
String get hwdec => 'Hardware Decoder';
}

View file

@ -1483,4 +1483,7 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get return_to_the_list_of_chapters => 'Return to the list of chapters';
@override
String get hwdec => 'Hardware Decoder';
}

View file

@ -204,6 +204,8 @@ class Settings {
bool? useLibass;
String? hwdecMode;
int? libraryFilterNovelDownloadType;
int? libraryFilterNovelUnreadType;
@ -326,6 +328,7 @@ class Settings {
this.animeGridSize,
this.disableSectionType = SectionType.all,
this.useLibass = true,
this.hwdecMode = "auto",
this.libraryFilterNovelDownloadType = 0,
this.libraryFilterNovelUnreadType = 0,
this.libraryFilterNovelStartedType = 0,
@ -509,6 +512,7 @@ class Settings {
disableSectionType =
SectionType.values[json['disableSectionType'] ?? SectionType.all.index];
useLibass = json['useLibass'];
hwdecMode = json['hwdecMode'];
libraryFilterNovelBookMarkedType = json['libraryFilterNovelBookMarkedType'];
libraryFilterNovelDownloadType = json['libraryFilterNovelDownloadType'];
libraryFilterNovelStartedType = json['libraryFilterNovelStartedType'];
@ -666,6 +670,7 @@ class Settings {
'animeGridSize': animeGridSize,
'disableSectionType': disableSectionType.index,
'useLibass': useLibass,
'hwdecMode': hwdecMode,
'libraryFilterNovelBookMarkedType': libraryFilterNovelBookMarkedType,
'libraryFilterNovelDownloadType': libraryFilterNovelDownloadType,
'libraryFilterNovelStartedType': libraryFilterNovelStartedType,

File diff suppressed because it is too large Load diff

View file

@ -183,7 +183,11 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage>
late final Player _player = Player(
configuration: PlayerConfiguration(libass: useLibass),
);
late final VideoController _controller = VideoController(_player);
late final hwdecMode = ref.read(hwdecModeStateProvider());
late final VideoController _controller = VideoController(
_player,
configuration: VideoControllerConfiguration(hwdec: hwdecMode),
);
late final _streamController = ref.read(
animeStreamControllerProvider(episode: widget.episode).notifier,
);

View file

@ -158,7 +158,7 @@ class _AddDownloadToQueueProviderElement
Chapter get chapter => (origin as AddDownloadToQueueProvider).chapter;
}
String _$downloadChapterHash() => r'ee2f93aaa7fd64b46d5ce729d1e58ba20a6fa0fc';
String _$downloadChapterHash() => r'199d0cba47ae8839c23def9c0b012f92472193e9';
/// See also [downloadChapter].
@ProviderFor(downloadChapter)

View file

@ -6,7 +6,7 @@ part of 'check_for_update.dart';
// RiverpodGenerator
// **************************************************************************
String _$checkForUpdateHash() => r'c59c08b12062030079f9592d907d1009b2681227';
String _$checkForUpdateHash() => r'644316334ac3e95d37f54d7197d744c9de1260b6';
/// Copied from Dart SDK
class _SystemHash {

View file

@ -26,6 +26,7 @@ class PlayerScreen extends ConsumerWidget {
final enableAutoSkip = ref.watch(enableAutoSkipStateProvider);
final aniSkipTimeoutLength = ref.watch(aniSkipTimeoutLengthStateProvider);
final useLibass = ref.watch(useLibassStateProvider);
final hwdecMode = ref.watch(hwdecModeStateProvider(rawValue: true));
final fullScreenPlayer = ref.watch(fullScreenPlayerStateProvider);
return Scaffold(
@ -467,6 +468,80 @@ class PlayerScreen extends ConsumerWidget {
ref.read(fullScreenPlayerStateProvider.notifier).set(value);
},
),
ListTile(
onTap: () {
final values = [
("no", ""),
("auto", ""),
("d3d11va", "(Windows 8+)"),
("d3d11va-copy", "(Windows 8+)"),
("videotoolbox", "(iOS 9.0+)"),
("videotoolbox-copy", "(iOS 9.0+)"),
("nvdec", "(CUDA)"),
("nvdec-copy", "(CUDA)"),
("mediacodec", "- HW (Android)"),
("mediacodec-copy", "- HW+ (Android)"),
("crystalhd", ""),
];
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(context.l10n.hwdec),
content: SizedBox(
width: context.width(0.8),
child: SuperListView.builder(
shrinkWrap: true,
itemCount: values.length,
itemBuilder: (context, index) {
return RadioListTile(
dense: true,
contentPadding: const EdgeInsets.all(0),
value: values[index].$1,
groupValue: hwdecMode,
onChanged: (value) {
ref
.read(hwdecModeStateProvider(rawValue: true).notifier)
.set(value!);
Navigator.pop(context);
},
title: Row(
children: [
Text(
"${values[index].$1} ${values[index].$2}",
),
],
),
);
},
),
),
actions: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () async {
Navigator.pop(context);
},
child: Text(
context.l10n.cancel,
style: TextStyle(color: context.primaryColor),
),
),
],
),
],
);
},
);
},
title: Text(context.l10n.hwdec),
subtitle: Text(
hwdecMode,
style: TextStyle(fontSize: 11, color: context.secondaryColor),
),
),
],
),
),

View file

@ -1,3 +1,4 @@
import 'dart:io';
import 'dart:ui';
import 'package:mangayomi/main.dart';
@ -181,3 +182,42 @@ class UseLibassState extends _$UseLibassState {
);
}
}
final hwdecs = {
"no": ["all"],
"auto": ["all"],
"d3d11va": ["windows"],
"d3d11va-copy": ["windows"],
"videotoolbox": ["ios"],
"videotoolbox-copy": ["ios"],
"nvdec": ["all"],
"nvdec-copy": ["all"],
"mediacodec": ["android"],
"mediacodec-copy": ["android"],
"crystalhd": ["all"],
};
@riverpod
class HwdecModeState extends _$HwdecModeState {
@override
String build({bool rawValue = false}) {
final hwdecMode = isar.settings.getSync(227)!.hwdecMode ?? "auto";
if (rawValue) {
return hwdecMode;
}
final hwdecSupport = hwdecs[hwdecMode] ?? [];
if (!hwdecSupport.contains("all") &&
!hwdecSupport.contains(Platform.operatingSystem)) {
return Platform.isAndroid ? "auto-safe" : "auto";
}
return hwdecMode;
}
void set(String value) {
final settings = isar.settings.getSync(227);
state = value;
isar.writeTxnSync(
() => isar.settings.putSync(settings!..hwdecMode = value),
);
}
}

View file

@ -175,5 +175,169 @@ final useLibassStateProvider =
);
typedef _$UseLibassState = AutoDisposeNotifier<bool>;
String _$hwdecModeStateHash() => r'e8b8e2b378eb9ac687bd8dad5637a816ad33fedb';
/// Copied from Dart SDK
class _SystemHash {
_SystemHash._();
static int combine(int hash, int value) {
// ignore: parameter_assignments
hash = 0x1fffffff & (hash + value);
// ignore: parameter_assignments
hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
return hash ^ (hash >> 6);
}
static int finish(int hash) {
// ignore: parameter_assignments
hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
// ignore: parameter_assignments
hash = hash ^ (hash >> 11);
return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
}
}
abstract class _$HwdecModeState extends BuildlessAutoDisposeNotifier<String> {
late final bool rawValue;
String build({
bool rawValue = false,
});
}
/// See also [HwdecModeState].
@ProviderFor(HwdecModeState)
const hwdecModeStateProvider = HwdecModeStateFamily();
/// See also [HwdecModeState].
class HwdecModeStateFamily extends Family<String> {
/// See also [HwdecModeState].
const HwdecModeStateFamily();
/// See also [HwdecModeState].
HwdecModeStateProvider call({
bool rawValue = false,
}) {
return HwdecModeStateProvider(
rawValue: rawValue,
);
}
@override
HwdecModeStateProvider getProviderOverride(
covariant HwdecModeStateProvider provider,
) {
return call(
rawValue: provider.rawValue,
);
}
static const Iterable<ProviderOrFamily>? _dependencies = null;
@override
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
@override
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
_allTransitiveDependencies;
@override
String? get name => r'hwdecModeStateProvider';
}
/// See also [HwdecModeState].
class HwdecModeStateProvider
extends AutoDisposeNotifierProviderImpl<HwdecModeState, String> {
/// See also [HwdecModeState].
HwdecModeStateProvider({
bool rawValue = false,
}) : this._internal(
() => HwdecModeState()..rawValue = rawValue,
from: hwdecModeStateProvider,
name: r'hwdecModeStateProvider',
debugGetCreateSourceHash:
const bool.fromEnvironment('dart.vm.product')
? null
: _$hwdecModeStateHash,
dependencies: HwdecModeStateFamily._dependencies,
allTransitiveDependencies:
HwdecModeStateFamily._allTransitiveDependencies,
rawValue: rawValue,
);
HwdecModeStateProvider._internal(
super._createNotifier, {
required super.name,
required super.dependencies,
required super.allTransitiveDependencies,
required super.debugGetCreateSourceHash,
required super.from,
required this.rawValue,
}) : super.internal();
final bool rawValue;
@override
String runNotifierBuild(
covariant HwdecModeState notifier,
) {
return notifier.build(
rawValue: rawValue,
);
}
@override
Override overrideWith(HwdecModeState Function() create) {
return ProviderOverride(
origin: this,
override: HwdecModeStateProvider._internal(
() => create()..rawValue = rawValue,
from: from,
name: null,
dependencies: null,
allTransitiveDependencies: null,
debugGetCreateSourceHash: null,
rawValue: rawValue,
),
);
}
@override
AutoDisposeNotifierProviderElement<HwdecModeState, String> createElement() {
return _HwdecModeStateProviderElement(this);
}
@override
bool operator ==(Object other) {
return other is HwdecModeStateProvider && other.rawValue == rawValue;
}
@override
int get hashCode {
var hash = _SystemHash.combine(0, runtimeType.hashCode);
hash = _SystemHash.combine(hash, rawValue.hashCode);
return _SystemHash.finish(hash);
}
}
@Deprecated('Will be removed in 3.0. Use Ref instead')
// ignore: unused_element
mixin HwdecModeStateRef on AutoDisposeNotifierProviderRef<String> {
/// The parameter `rawValue` of this provider.
bool get rawValue;
}
class _HwdecModeStateProviderElement
extends AutoDisposeNotifierProviderElement<HwdecModeState, String>
with HwdecModeStateRef {
_HwdecModeStateProviderElement(super.provider);
@override
bool get rawValue => (origin as HwdecModeStateProvider).rawValue;
}
// ignore_for_file: type=lint
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package

View file

@ -6,7 +6,7 @@ part of 'aniskip.dart';
// RiverpodGenerator
// **************************************************************************
String _$aniSkipHash() => r'887869b54e2e151633efd46da83bde845e14f421';
String _$aniSkipHash() => r'2e5d19b025a2207ff64da7bf7908450ea9e5ff8c';
/// See also [AniSkip].
@ProviderFor(AniSkip)

View file

@ -6,7 +6,7 @@ part of 'get_chapter_pages.dart';
// RiverpodGenerator
// **************************************************************************
String _$getChapterPagesHash() => r'7ec8b6adb94e33df9b5374bd423f7864a4c2f8ef';
String _$getChapterPagesHash() => r'69bdb90a1ec142dbdb069a675cfb13ad69e18998';
/// Copied from Dart SDK
class _SystemHash {

View file

@ -6,7 +6,7 @@ part of 'get_video_list.dart';
// RiverpodGenerator
// **************************************************************************
String _$getVideoListHash() => r'bae6a3cbc064163148577d0646b87a3f16d44da7';
String _$getVideoListHash() => r'1d34225b32d5c0475f06c7066792837d4b800800';
/// Copied from Dart SDK
class _SystemHash {

View file

@ -6,7 +6,7 @@ part of 'anilist.dart';
// RiverpodGenerator
// **************************************************************************
String _$anilistHash() => r'80c9c6e9028e8a8180795366729acbe6c248d9ce';
String _$anilistHash() => r'd672e47052f0b40088dd477b7918dc1e06654b48';
/// Copied from Dart SDK
class _SystemHash {