question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Audio codec switching mid stream with hdmi receiver passthrough produces error on GCWTV

See original GitHub issue

Log excerpt (full adb bugreport sent via email)

2020-12-05 00:38:59.567 3568-3635/? W/APM_AudioPolicyManager: getOutputForDevices() could not find output for stream 3, sampling rate 48000, format 0x9000000, channels 0x3, flags 0x1
2020-12-05 00:38:59.568 3568-3635/? E/AudioFlinger: createTrack() getOutputForAttr() return error -38 or invalid output handle
2020-12-05 00:38:59.568 2888-2954/com.example.android.persistence E/IAudioFlinger: createTrack returned error -38
2020-12-05 00:38:59.568 2888-2954/com.example.android.persistence E/AudioTrack: createTrack_l(868): AudioFlinger could not create track, status: -38 output 326484847
2020-12-05 00:38:59.569 2888-2954/com.example.android.persistence E/AudioTrack-JNI: Error -38 initializing AudioTrack
2020-12-05 00:38:59.569 2888-2954/com.example.android.persistence D/AudioTrack: gather(): no metrics gathered, track status=-38
2020-12-05 00:38:59.570 2888-2954/com.example.android.persistence E/android.media.AudioTrack: Error code -20 when initializing AudioTrack.
2020-12-05 00:38:59.581 3532-3597/? D/audio_hw_primary: out_pause(0xeb2d9a80)
2020-12-05 00:38:59.581 3532-3597/? E/audio_hw_primary: out->pcm and adev->pcm are assumed same handle
2020-12-05 00:38:59.581 3532-16733/? D/audio_hw_primary: out_flush(0xeb2d9a80)
2020-12-05 00:38:59.582 3532-16733/? I/audio_hw_primary: do_output_standby_direct,out 0xeb2d9a80
2020-12-05 00:38:59.582 3532-16733/? I/audio_spdif_out: aml_audio_set_spdif_format tinymix AML_MIXER_ID_SPDIF_FORMAT 0
2020-12-05 00:38:59.582 3532-16733/? I/audio_hwsync: aml_audio_hwsync_init done
2020-12-05 00:38:59.586 3532-16733/? I/audio_hw_primary: ++adev_release_audio_patch: handle(105)
2020-12-05 00:38:59.586 3532-16733/? I/audio_hw_primary: patch set found id 105, patchset 0xeb2c6400
2020-12-05 00:38:59.586 3532-16733/? I/audio_hw_primary: source 0 type=2 sink type =1 amk patch src=11
2020-12-05 00:38:59.586 3532-16733/? D/audio_hw_primary: unregister_audio_patch: enter
2020-12-05 00:38:59.586 3532-16733/? D/audio_hw_primary: unregister_audio_patch: exit
2020-12-05 00:38:59.586 3532-16733/? I/audio_hw_primary: --adev_release_audio_patch: after releasing patch, patch sets will be:
2020-12-05 00:38:59.592 3532-16733/? I/audio_hw_primary: out_standby_direct(0xeb2d9a80),out 0xeb2d9a80
2020-12-05 00:38:59.593 3532-16733/? I/audio_spdif_out: aml_audio_set_spdif_format tinymix AML_MIXER_ID_SPDIF_FORMAT 0
2020-12-05 00:38:59.593 3532-16733/? I/audio_hw_primary: enable rawtopcm_flag !!!
2020-12-05 00:38:59.596 2888-2954/com.example.android.persistence E/ExoPlayerImplInternal: Playback error
      com.google.android.exoplayer2.ExoPlaybackException: MediaCodecAudioRenderer error, index=1, format=Format(61201/515, null, null, audio/ac3, null, -1, de, [-1, -1, -1.0], [2, 48000]), format_supported=YES
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:542)
        at android.os.Handler.dispatchMessage(Handler.java:103)
        at android.os.Looper.loop(Looper.java:214)
        at android.os.HandlerThread.run(HandlerThread.java:67)
     Caused by: com.google.android.exoplayer2.audio.AudioSink$InitializationException: AudioTrack init failed: 0, Config(48000, 12, 40000)
        at com.google.android.exoplayer2.audio.DefaultAudioSink$Configuration.buildAudioTrack(DefaultAudioSink.java:1933)
        at com.google.android.exoplayer2.audio.DefaultAudioSink.buildAudioTrack(DefaultAudioSink.java:845)
        at com.google.android.exoplayer2.audio.DefaultAudioSink.initializeAudioTrack(DefaultAudioSink.java:639)
        at com.google.android.exoplayer2.audio.DefaultAudioSink.handleBuffer(DefaultAudioSink.java:731)
        at com.google.android.exoplayer2.audio.MediaCodecAudioRenderer.processOutputBuffer(MediaCodecAudioRenderer.java:623)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.bypassRender(MediaCodecRenderer.java:2143)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:852)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:892)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:467)
        at android.os.Handler.dispatchMessage(Handler.java:103) 
        at android.os.Looper.loop(Looper.java:214) 
        at android.os.HandlerThread.run(HandlerThread.java:67) 
2020-12-05 00:38:59.596 3532-16733/? D/audio_hw_primary: out_set_parameters(kvpairs(closing=true), out_device=0x400)
2020-12-05 00:38:59.596 3532-16733/? E/audio_hw_primary: Amlogic_HAL - out_set_parameters: parameter is NULL, change ret value to 0 in order to pass VTS test.

Device: Google Chromecast with GoogleTV

Sample file

I gathered the following audio-only sample (copyright issues), it switches from AC3 with 5.1 to stereo and back to 5.1 This is enough to freeze the player and prompt the above error when a receiver with passthrough is the audio output.

sample.zip

Json for demo player:

  {
    "name": "Audio passthrough tests",
    "samples": [
      {
        "name": "AC3 5.1 to 2.0 to 5.1",
        "uri": "https://martb.eu/exoplayer/ac3-5.1-to-ac3.stereo-to-ac3-5.1.ts"
      }
    ]
  },

(almost )100% reproducable with a DENON AVR X2100W and X1200W sometimes the switching magically works, but most of the time it doesnt.

VLC behavior: Just to rule out a device issue, i played the file with VLC and enabled passthrough, it correctly played the file. But it seems like theres custom code in there to allow it: libvlc decoder: restarting module due to input format change

Kind regards and thanks for your time, MartB

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
stevemayhewcommented, Dec 5, 2020

@MartB I have a Denon receiver with an Android TV and assortment of other Android streamers, I can do a quick try with your stream, we have the fix @sneelavara mentioned back ported to release 2.11.

The fix deals with other unreported discontinuities just fine (we have a stream that goes AC3 to PCM and back). In our case it is HLS, so the change is technically illegal unless it is reported with an EXT-X-DISCONTINUITY tag

1reaction
sneelavaracommented, Dec 5, 2020

@MartB this is different than #8178 . The AudioFlinger error -38 used to happen for us during switching Audio track to AC-3 from non-AC-3 tracks. Sometimes commercials are in stereo and content is in 5.1 channel AC-3. In such case transitioning from content to commercial used to hit this error too.

We found the retry logic from 7dfdde9 , discussed in #7042 is very helpful. The AudioInit failure recovers with retries for us. We have tried this fix on AmLogic devices as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Guide] Audio setup - pass-through - codecs - settings - Reddit
Optical cables (also known as S/PDIF or TOSLINK) can carry digital audio streams to an AV receiver/soundbar that can decode two channels of ......
Read more >
Re: Dolby Digital 5.1 passthrough CCwGTV issues
I just got a CCwGTV and about to install into one of my Denon X6700H HDMI ports with ... Multichannel audio streams will...
Read more >
Supported Media for Google Cast
Google Cast and all Cast Web Receiver applications support the media facilities and types listed on this page.
Read more >
Has anyone plugged this into their Audio Video Pr – Q&A
I have had occasional trouble with receiver switching streaming channels within this device than when using the Roku or Firestick but it has ......
Read more >
[Audio Settings] How to Set-up Audio Mode. - Zappiti (English)
If you do not use AV receiver, please select "Downmix 2.0" in "HDMI outpout" and "S/PDIF ... Depending on the types of audio...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found