Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pcm multichannel audio for Tvs #3422

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

MichaelRUSF
Copy link
Contributor

@MichaelRUSF MichaelRUSF commented Mar 1, 2024

Changes
Android apps running on Smart TVs are limited to PCM 2.0 Audio, while DD(+) and DTS have full support. This causes multichannel formats such as AAC and Opus to output stereo audio when playing directly from a TV to a receiver. This change identifies what is a TV based on feature testing and will transcode non-DD (+)/DTS multichannel audio if the app is running on a TV.

Also, add a condition for enabling/disabling DTS. The bitstreaming option in the preference menu isn't tied to any action.

Issues

Fixes #2991 #3294 #3152 #520

@@ -862,6 +863,16 @@
return currIndex;
}

public Integer getNumberOfChannels() {

Check notice

Code scanning / Android Lint

Unknown nullness Note

Unknown nullability; explicitly declare as @Nullable or @NonNull to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations
@MichaelRUSF MichaelRUSF force-pushed the fix_pcm_multichannel_audio_for_tvs branch 3 times, most recently from 6596201 to bb76c2d Compare March 2, 2024 02:00
@MichaelRUSF MichaelRUSF force-pushed the fix_pcm_multichannel_audio_for_tvs branch from bb76c2d to b11e3b4 Compare March 3, 2024 02:52
Copy link
Member

@nielsvanvelzen nielsvanvelzen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not introduce new behavior that relies on the manufacturer/model of the device. Use feature testing instead.

@MichaelRUSF
Copy link
Contributor Author

New tests were added based on features.

!packageManager.hasSystemFeature("android.hardware.camera") and
!packageManager.hasSystemFeature("android.hardware.location.gps") and
!packageManager.hasSystemFeature("android.hardware.screen.portrait")
}

Check warning

Code scanning / detekt

Checks whether files end with a line separator. Warning

The file /home/runner/work/jellyfin-androidtv/jellyfin-androidtv/app/src/main/java/org/jellyfin/androidtv/util/ContextExtensions.kt is not ending with a new line.
@nielsvanvelzen
Copy link
Member

If you want to know whether an audio codec is supported or not you should not test for various system features but for that specific audio codec.

@MichaelRUSF
Copy link
Contributor Author

Testing the audio codec will not work for this issue. The issue is not the lack of codec support from the TV, it’s the fact that TV apps are not allowed to output multichannel PCM, which is what Jellyfin sends for Non-DD (+)/DTS media.

If the app is running directly from the TV, testing for Non-DD (+)/DTS codecs would come back as true if supported, but if the media is multichannel then only stereo audio will be played b/c of these limitations.

TVs can passthrough multichannel PCM from external devices plugged in via HDMI. So this is not an issue for any connected devices, e.g., Shields, Fire TVs, Chromecast, etc.

There are only two ways to solve this. Either detect if an app running from a TV and transcode multichannel PCM formats to DD, which this does. Or give users the option to bypass manually. Because automatic codec detection will not work for this issue.

@MichaelRUSF
Copy link
Contributor Author

However all internal apps including Plex do not support lossless audio (like Dolby TrueHD) passthru, only external HDMI devices can use eArc to passthru the lossless audio formats - so those require an external media player that supports those formats.

There is a hardware limitation that prevents full eArc support of lossless audio codecs from the internal TV apps, this affects all current TVs not just the Sonys. eArc is only fully supported on current TVs with external HDMI devices. Internal app audio support is based on using them with streaming services that use compressed DD+ with atmos audio at maximum.

Source

If you select PCM even though you have a home theater system or soundbar connected, the sound system will only receive 2.0 channel sound and the result will not be multi-channel surround sound, even if the sound system is capable of multi-channel PCM audio.

Source

@entropicdrifter
Copy link

Maybe it would make more sense to just have a setting in the menu, something like a toggle to turn on transcoding of all surround (that's not already DD, DD+, or DTS) into Dolby or DTS. That'll fix AAC, OGG, TrueHD and DTS-HD MA all at once on the devices in question.

People who don't bother to turn on the setting are probably the same people who wouldn't notice/care about the issue, right?

@jellyfin-bot jellyfin-bot added the merge conflict Conflicts prevent merging label Mar 23, 2024
@interkelstar
Copy link

Maybe it would make more sense to just have a setting in the menu, something like a toggle to turn on transcoding of all surround (that's not already DD, DD+, or DTS) into Dolby or DTS. That'll fix AAC, OGG, TrueHD and DTS-HD MA all at once on the devices in question.

People who don't bother to turn on the setting are probably the same people who wouldn't notice/care about the issue, right?

I actually agree and that's how it's done in Emby, just a setting to transcode all unsupported to DD which works really well

@nextlooper42
Copy link
Contributor

Same in Kodi, there is a toggle to transcode all unsupported audio to AC3. Works like charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge conflict Conflicts prevent merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blacklist specific audio formats
6 participants