a52: can't fill input buffer if can't empty output buffer. Stuttering sound in XBMC. [patch]

Bug #1232073 reported by Lewis Jardine
This bug affects 1 person
Affects Status Importance Assigned to Milestone
alsa-plugins (Ubuntu)

Bug Description

In pcm_a52.c, write_out_pending can return -EAGAIN if the downstream buffer has no free space. When called from a52_transfer-->fill_data, the -EAGAIN causes the entire call to abort with -EAGAIN, making it look like a52's input buffer is full, when really there's plenty space. Whether a frame can be accepted or not does not depend on state of the the output buffer, but only on the free space in the input buffer, which is checked right at the start of the function.

Whilst it's nice to empty the output buffer so the new frames can be processed, failure to do so does not prevent accepting frames, so such a failure should be ignored to allow the incoming frames to be accepted.

Newer versions of XBMC (Frodo onwards) have a re-written audio engine that triggers this bug, every three playback-minutes or so. Despite being written to use asynchronous mode, the new audio engine really doesn't like getting back large numbers of EAGAINs, and repeatedly reinitialises the PCM on the assumption that it is broken. The problem is made worse by XBMC immediately retrying the call when it can only succeed after the hardware has consumed another AC3 packet.

Without patch: XBMC playback frequently interrupted with judders, motorboating, and video pausing while sound is restarted
With patch: occasional audio artefacts, video playback unaffected by pausing

I don't have the resources to test against upstream or unstable, though the source code appears to do the same thing. ALSA's bugtracker appears to be down.


Ubuntu version-
Description: Ubuntu 12.04.3 LTS
Release: 12.04

Package version-

Tags: patch
Revision history for this message
Lewis Jardine (oss-w) wrote :
Lewis Jardine (oss-w)
affects: alsa-utils (Ubuntu) → alsa-plugins (Ubuntu)
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "one-liner, ignore failure to empty output buffer" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.