feat(exoplayer): let the read-ahead buffer depth be chosen instead of fixed at 50s
ExoPlayer's DefaultLoadControl was built with hard-coded durations picked from one memory tier, so read-ahead stopped at 50s on any device reporting 2GB or less free, with no way to raise it. On hardware where mpv cannot render at all that ceiling is the whole buffer budget. Playback Buffer offers Auto, Large and Extra Large. The durations are taken from jellyfin-androidtv and jellyfin-android so the same words mean the same thing across Jellyfin clients; Auto keeps the memory-tiered values that shipped. Named tiers rather than a duration because a duration would be a promise the load control cannot keep: prioritizeTimeOverSizeThresholds is disabled, so targetBufferBytes stops the loader even below minBufferMs and the byte cap binds first above roughly 23 Mbit/s. The tier crosses the method channel as a string and resolves in the core, where an unrecognised name falls back to Auto. LoadControlPolicy clamps the resulting pair: media3 validates the ordering with Guava Preconditions, an unconditional throw R8 does not elide, so a bad pair would be an IllegalArgumentException out of player construction rather than a bad buffer. The two play-start thresholds stay fixed even though the Jellyfin tiers move them. BufferingStallPolicy.MIN_BUFFER_AHEAD_MS is a const derived from BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS, so a runtime value there would make the stall watchdog indict a player that is obeying its own load control. That leaves the byte target as a second, often smaller ceiling, and nothing surfaced either. The resolved values now reach getStats, and the overlay's Buffer section gains a Cache Limit row reading "120s / 128MB" next to the buffered-ahead duration, so a tier that appears to do nothing on a high-bitrate file explains itself. close #1816
This commit is contained in:
@@ -104,6 +104,8 @@ class _PlayerPerformanceOverlayState extends State<PlayerPerformanceOverlay> {
|
||||
_metric(t.fileInfo.duration, _stats.cacheDurationFormatted),
|
||||
if (isMpv) _metric(t.performanceOverlay.cacheUsed, _stats.cacheUsedFormatted),
|
||||
if (isMpv) _metric(t.performanceOverlay.cacheLimit, _stats.cacheLimitFormatted),
|
||||
if (!isMpv && _stats.hasValidBufferLimits)
|
||||
_metric(t.performanceOverlay.cacheLimit, _stats.bufferLimitsFormatted),
|
||||
if (isMpv) _metric(t.performanceOverlay.speed, _stats.cacheSpeedFormatted),
|
||||
]),
|
||||
_buildSection(Symbols.apps_rounded, t.performanceOverlay.app, [
|
||||
|
||||
@@ -53,6 +53,8 @@ class PerformanceStats {
|
||||
final int? cacheLimit;
|
||||
final double? cacheSpeed;
|
||||
final double? cacheDuration;
|
||||
final int? bufferTargetBytes;
|
||||
final int? bufferMaxMs;
|
||||
|
||||
// DV conversion
|
||||
final bool dvConversionActive;
|
||||
@@ -106,6 +108,8 @@ class PerformanceStats {
|
||||
this.cacheLimit,
|
||||
this.cacheSpeed,
|
||||
this.cacheDuration,
|
||||
this.bufferTargetBytes,
|
||||
this.bufferMaxMs,
|
||||
this.dvConversionActive = false,
|
||||
this.dvConversionMode = '',
|
||||
this.dvConvertedRpus,
|
||||
@@ -157,6 +161,8 @@ class PerformanceStats {
|
||||
cacheLimit = null,
|
||||
cacheSpeed = null,
|
||||
cacheDuration = null,
|
||||
bufferTargetBytes = null,
|
||||
bufferMaxMs = null,
|
||||
dvConversionActive = false,
|
||||
dvConversionMode = '',
|
||||
dvConvertedRpus = null,
|
||||
@@ -183,6 +189,17 @@ class PerformanceStats {
|
||||
return '${mbps.toStringAsFixed(1)} Mbps';
|
||||
}
|
||||
|
||||
/// Both ExoPlayer read-ahead ceilings: the duration target and the hard byte cap.
|
||||
/// The smaller one binds, so showing both explains a duration setting that
|
||||
/// appears to have no effect on high-bitrate media.
|
||||
String get bufferLimitsFormatted {
|
||||
if (bufferMaxMs == null || bufferMaxMs! <= 0) return 'N/A';
|
||||
final duration = '${bufferMaxMs! ~/ 1000}s';
|
||||
if (bufferTargetBytes == null) return duration;
|
||||
final targetBufferMb = bufferTargetBytes! ~/ (1024 * 1024);
|
||||
return '$duration / ${targetBufferMb}MB';
|
||||
}
|
||||
|
||||
/// Format audio bitrate in kbps.
|
||||
String get audioBitrateFormatted {
|
||||
if (audioBitrate == null || audioBitrate == 0) return 'N/A';
|
||||
@@ -377,6 +394,8 @@ class PerformanceStats {
|
||||
return videoBitrate != null && videoBitrate! > 0;
|
||||
}
|
||||
|
||||
bool get hasValidBufferLimits => bufferMaxMs != null && bufferMaxMs! > 0;
|
||||
|
||||
/// Check if audio bitrate is valid (not null, not negative, not zero).
|
||||
bool get hasValidAudioBitrate {
|
||||
return audioBitrate != null && audioBitrate! > 0;
|
||||
|
||||
@@ -211,6 +211,8 @@ class PerformanceStatsService {
|
||||
frameDropCount: statsMap['videoDroppedFrames'] as int?,
|
||||
// Buffer metrics - convert ms to seconds for duration
|
||||
cacheDuration: ((statsMap['totalBufferedDurationMs'] as int?) ?? 0) / 1000.0,
|
||||
bufferTargetBytes: statsMap['bufferTargetBytes'] as int?,
|
||||
bufferMaxMs: statsMap['bufferMaxMs'] as int?,
|
||||
// DV conversion
|
||||
dvConversionActive: statsMap['dvConversionActive'] == true,
|
||||
dvConversionMode: statsMap['dvConversionMode'] as String? ?? '',
|
||||
|
||||
Reference in New Issue
Block a user