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

Playing 5.1 PCM audio with tunneling mode. #6031

Closed
navluis opened this issue Jun 13, 2019 · 3 comments
Closed

Playing 5.1 PCM audio with tunneling mode. #6031

navluis opened this issue Jun 13, 2019 · 3 comments
Assignees
Labels

Comments

@navluis
Copy link

navluis commented Jun 13, 2019

[REQUIRED] Use case description

Some audio streams contain 5.1 channel-masks. When those audio streams are decoded (instead of played as passthrough) and tunneling is enabled, ExoPlayer is unable to play audio because it is using the version 1 of the av-sync header.

Proposed solution

The only thing that is required for that feature to work is to enable the lines corresponding to this comment :
// TODO: Uncomment this when [Internal ref: b/33627517] is clarified or fixed.
in file:
"library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java"

The reason why enabling that code will fix the issue is below:

The tunneling audio header version 1 has a fixed header-size of 16 bytes. The AudioTrack allows to write data only in multiples of the audio track frame size and because ExoPlayer attempts to fully write the header before writing the payload, it is therefore mandatory that the header size be a multiple of the frame-size. For PCM16 (2 channels) this is not a problem because the frame-size is 4, but for other channel-mask such as 5.1 (frame-size 12) ExoPlayer will be unable to fully write the audio header and therefore unable to play any audio.

Android introduced earlier a header version 2, which contains an 'offset' field which allows the frame-header to have a variable size. ExoPlayer writes the audio header itself (version 1) but Android internally is able to write the header version 2 and also sets the header size to a multiple of the frame size. This change simply delegates the task of writing the audio header to the Android framework.

Alternatives considered

n/a

@tonihei
Copy link
Collaborator

tonihei commented Jun 17, 2019

@andrewlewis Can you take a look at this issue?

@ojw28 ojw28 added bug and removed enhancement labels Jun 18, 2019
@ojw28
Copy link
Contributor

ojw28 commented Jun 18, 2019

It looks like we can do the TODO for Oreo and above (SDK_INT >= 26). Note however that the V2 header was only implemented at some point after that, however (possibly only Pie and above).

@ojw28 ojw28 assigned ojw28 and unassigned andrewlewis Jun 18, 2019
ojw28 added a commit that referenced this issue Jun 18, 2019
Issue: #6031
PiperOrigin-RevId: 253784986
@ojw28 ojw28 closed this as completed Jun 19, 2019
@navluis
Copy link
Author

navluis commented Jun 19, 2019

Thanks for the prompt response to this. Will give it a try!

ojw28 added a commit that referenced this issue Jun 19, 2019
Issue: #6031
PiperOrigin-RevId: 253784986
@google google locked and limited conversation to collaborators Oct 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants