[mythtv] [mythtv-commits] Ticket #12827: Raspberry Pi: Digital Audio does not work

John P Poet jppoet at gmail.com
Wed Jul 27 16:24:07 UTC 2016

On Wed, Jul 27, 2016 at 8:25 AM MythTV <noreply at mythtv.org> wrote:

> #12827: Raspberry Pi: Digital Audio does not work
> ----------------------------------+-----------------------------
>  Reporter:  pbennett              |          Owner:  pbennett
>      Type:  Bug Report - General  |         Status:  accepted
>  Priority:  minor                 |      Milestone:  unknown
> Component:  Ports - rPi           |        Version:  Master Head
>  Severity:  medium                |     Resolution:
>  Keywords:                        |  Ticket locked:  0
> ----------------------------------+-----------------------------
> Comment (by pbennett):
>  Output of Dolby digital passthru audio to a surround sound system works
>  and gives sound, but the audio  and video are jerky. This is because the
>  omx audio system seems to give incorrect and inconsistent values for audio
>  latency (i.e. amount of audio in the sound card that has not yet been
>  played). The result is that AVSync reports Video is behind audio (too
>  slow) for a few seconds and drops some frames to fix it, then reports that
>  Video is ahead of audio for a few seconds, and slows video down to
>  compensate. Thus the video is alternately speeded up and slowed down every
>  few seconds and the audio is paused and restarted every few seconds.
>  The audio latency values are incorrect only in the digital passthru case.
>  If playing digital stereo or analog, it works perfectly.
>  If I set very high values for MAXDIVERGE and DIVERGELIMIT so that AVSync
>  ignores the errors, the video plays very well. 5.1 channel Dolby Digital
>  audio is good, the surround sound receiver reports it as Dolby Digital.
>  The video is in good sync with the sound. However this is not a solution,
>  it will certainly get out of sync soon.
>  Options
>  1. Try to get some code that will estimate the latency based on amount of
>  data passed in and elapsed time. I am afraid this would also gradually get
>  worse over time. Also I am not sure how to handle pauses.
>  2. Try to minimize latency by passing data to audio only when it is
>  needed. This is difficult because audio is in a ring buffer before going
>  to the sound device and the ring buffer does not keep track of time codes.
>  3. Assume some fixed value for sound card latency all the time.
>  4. Average the sync calculation over 30, 75, 100, or 300 frames. Currently
>  it is averaged over 4 frames. This assumes that on average over time the
>  sound card latencies will be correct. I am afraid this may cause other
>  problems, for example when using softblend and displaying OSD the AVSync
>  has to compensate for the extra CPU load by dropping some frames. That
>  works well but will not work with the averaging calculation.
>  I am not sure how to proceed.

On first blush, I would be tempted to go with (2) and change the ringbuffer
to track time codes.  I am not familiar with that code, though, so I don't
know how hard or practical that is.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mythtv.org/pipermail/mythtv-dev/attachments/20160727/6e2d7ce1/attachment.html>

More information about the mythtv-dev mailing list