fix(playback): bound the device profile by the audio route's channels (DR-141)
MediaCodecList answers "can this device decode 5.1", which is not the question that decides whether the user hears anything: a phone decodes an AC-3 5.1 track happily and still has two channels to play it out of. The DeviceProfile carried no MaxAudioChannels, so Jellyfin was free to direct-play the multichannel track to a two-channel sink — silence or dialogue folded into surround channels that go nowhere, depending on the device. Report media3 AudioCapabilities.maxChannelCount for the current route over JNI alongside the codec lists, and bound the direct-play and transcoding profiles (and the HLS URL's TranscodingMaxAudioChannels, previously hardcoded to 2) by it. No codec is ever removed, so a device with genuine surround output keeps direct-playing it. A missing or zero reading means "route not yet established", not "no audio", and falls back to stereo.
This commit is contained in:
@@ -404,7 +404,10 @@ impl OnlineRepository {
|
||||
("MaxStreamingBitrate", "20000000".to_string()),
|
||||
("VideoBitrate", "18000000".to_string()),
|
||||
("AudioBitrate", "384000".to_string()),
|
||||
("TranscodingMaxAudioChannels", "2".to_string()),
|
||||
(
|
||||
"TranscodingMaxAudioChannels",
|
||||
super::device_profile::max_audio_channels().to_string(),
|
||||
),
|
||||
("SegmentContainer", "ts".to_string()),
|
||||
("TranscodingContainer", "ts".to_string()),
|
||||
("TranscodingProtocol", "hls".to_string()),
|
||||
@@ -1271,6 +1274,10 @@ impl MediaRepository for OnlineRepository {
|
||||
name: String,
|
||||
max_streaming_bitrate: i64,
|
||||
max_static_bitrate: i64,
|
||||
/// Channels the device's audio route can actually voice. Without it
|
||||
/// the server may direct-play a 5.1 track to a two-channel sink,
|
||||
/// which is silence or inaudible dialogue depending on the device.
|
||||
max_audio_channels: String,
|
||||
direct_play_profiles: Vec<DirectPlayProfile>,
|
||||
transcoding_profiles: Vec<TranscodingProfile>,
|
||||
subtitle_profiles: Vec<SubtitleProfile>,
|
||||
@@ -1298,6 +1305,7 @@ impl MediaRepository for OnlineRepository {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
video_codec: Option<String>,
|
||||
audio_codec: String,
|
||||
max_audio_channels: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
@@ -1338,8 +1346,9 @@ impl MediaRepository for OnlineRepository {
|
||||
|
||||
// Get detected codecs from Android MediaCodecList or use platform defaults
|
||||
#[cfg(target_os = "android")]
|
||||
let (video_codecs, audio_codecs) =
|
||||
crate::player::get_detected_codecs().unwrap_or_else(|| {
|
||||
let (video_codecs, audio_codecs) = crate::player::get_detected_codecs()
|
||||
.map(|(video, audio, _channels)| (video, audio))
|
||||
.unwrap_or_else(|| {
|
||||
warn!("[DeviceProfile] Codec detection not complete, using conservative defaults");
|
||||
("h264,hevc".to_string(), "aac,mp3".to_string())
|
||||
});
|
||||
@@ -1362,11 +1371,18 @@ impl MediaRepository for OnlineRepository {
|
||||
info!("[DeviceProfile] Using video codecs: {}", video_codecs);
|
||||
info!("[DeviceProfile] Using audio codecs: {}", audio_codecs);
|
||||
|
||||
// Bound every profile by what the audio route can actually voice, so a
|
||||
// multichannel track is downmixed by the server rather than direct-played
|
||||
// into a sink that has nowhere to put the extra channels.
|
||||
let max_audio_channels = super::device_profile::max_audio_channels().to_string();
|
||||
info!("[DeviceProfile] Max audio channels: {}", max_audio_channels);
|
||||
|
||||
// Create device profile with detected hardware capabilities
|
||||
let device_profile = DeviceProfile {
|
||||
name: "JellyTau Native Player".to_string(),
|
||||
max_streaming_bitrate: 999_999_999,
|
||||
max_static_bitrate: 999_999_999,
|
||||
max_audio_channels: max_audio_channels.clone(),
|
||||
direct_play_profiles: vec![
|
||||
DirectPlayProfile {
|
||||
profile_type: "Video".to_string(),
|
||||
@@ -1389,6 +1405,7 @@ impl MediaRepository for OnlineRepository {
|
||||
container: "ts".to_string(),
|
||||
video_codec: Some("h264,hevc".to_string()),
|
||||
audio_codec: "aac,mp3".to_string(),
|
||||
max_audio_channels: max_audio_channels.clone(),
|
||||
},
|
||||
TranscodingProfile {
|
||||
profile_type: "Audio".to_string(),
|
||||
@@ -1397,6 +1414,7 @@ impl MediaRepository for OnlineRepository {
|
||||
container: "mp3".to_string(),
|
||||
video_codec: None,
|
||||
audio_codec: "mp3".to_string(),
|
||||
max_audio_channels: max_audio_channels.clone(),
|
||||
},
|
||||
],
|
||||
subtitle_profiles: vec![
|
||||
|
||||
Reference in New Issue
Block a user