Choppy playback on Snowball through pulseaudio

Bug #939593 reported by Kalle Vahlman
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
IglooCommunity
Fix Released
Medium
Ramesh Chandrasekaran
Linaro Multimedia WG project
Won't Fix
Undecided
Unassigned
Linaro Ubuntu
Won't Fix
Undecided
Unassigned

Bug Description

The 2012.02 release introduced proper settings to make pulseaudio work with audio-out jack on snowball, however the playback is choppy.

Observable for example in the sound settings, hardware tab has the Test Speakers utility. Clicking on the left/right channel testers produces only parts of "front left" and "front right".

Tags: multimedia
Anmar Oueja (anmar)
Changed in igloocommunity:
milestone: none → 2012.03
Anmar Oueja (anmar)
Changed in igloocommunity:
status: New → Confirmed
importance: Undecided → High
assignee: nobody → Lee Jones (lag)
Anmar Oueja (anmar)
Changed in linaro-ubuntu:
assignee: nobody → Ricardo Salveti (rsalveti)
tags: added: multimedia
Revision history for this message
Riku Voipio (riku-voipio) wrote :

Copying over the comment from the previous bug#:

As tested with the 12.02 RC2 images, audio works from command line:

 aplay -Dhw:0,1 /usr/share/sounds/alsa/Side_Left.wav

but is heavily distorted in pulseaudio. For example try speaker tests in gnome sound settings.

Switching pulseaudio from timer based scheduling to interrupt based fixed the choppiness for me:

17:35 < suihkulokki> in /etc/pulse/default.pa:
17:35 < suihkulokki> -load-module module-udev-detect
17:35 < suihkulokki> +load-module module-udev-detect tsched=0

 it is apparently considered a bug in the alsa driver if pulseaudio cannot use timer scheduling, and we probably shouldn't change the default for all boards.

Explanation of timer based scheduling in pulseaudio at:

http://0pointer.de/blog/projects/pulse-glitch-free.html

Changed in igloocommunity:
importance: High → Medium
Lee Jones (lag)
Changed in igloocommunity:
assignee: Lee Jones (lag) → Thomas Espersson (espersson)
Revision history for this message
Anmar Oueja (anmar) wrote : Re: [Bug 939593] Re: Choppy playback on Snowball through pulseaudio

There is a hack right now to fix it this. However, the real culprit is
the audio driver. Assigning back to Thomas to escalate internally.

Revision history for this message
Lee Jones (lag) wrote :

All of the information you need can be found in [1].

Basically, the audio driver needs converting to a timer based system.

[1] http://fedoraproject.org/wiki/Features/GlitchFreeAudio

Revision history for this message
Anmar Oueja (anmar) wrote :

Hmm... Ricardo says that the work around Lee submitted to him will affect all the boards (not just snowball) and that is a show stopper. The ideal fix is to fix the driver as per Lee's comment (#3).

Jayeeta/Thomas: Can we assign that to the right person inside of ST-Ericsson.

Revision history for this message
Thomas Espersson (espersson) wrote :

Can anyone with the adequate knowledge do some kind of estimate and summary on whats needs to be done? The link in comment #3 does not tell how much work this would be for the driver used on snowball (or if it is even possible without rewriting the same)

Revision history for this message
Thomas Espersson (espersson) wrote :

No progress yet, trying to some input from STE audio experts on this matter

Revision history for this message
Thomas Espersson (espersson) wrote :

Decided to move to 12.04, workaround should be documented with the known limitations for the 12.03 release.

Changed in igloocommunity:
milestone: 2012.03 → 2012.04
Revision history for this message
Anmar Oueja (anmar) wrote :

I created a bug (https://bugs.launchpad.net/igloocommunity/+bug/959622) to capture the need for updating the release notes for the 2012.03 release notes.

Revision history for this message
Thomas Espersson (espersson) wrote :

Comment from STE Audio guys:

I looked a bit at the glitch-free audio solution and it seems that there are many things to be addressed to
make that work. For example it seems that not even the ALSA-framework yet supports this. Also I see som
requirements of having HW-buffers of 2-3 seconds! AB8500 does not support this.
These kind of large changes would probably require a lot of work and testing.

However, I don’t think that this new features should be needed to avoid underruns. We have done a lot of
work already to get rid of underruns, and the solution was to use cyclic DMA, i.e. we set up the DMA once
before playback starts and then we just fill as much as we can after each interrupt. So the DMA just assumes
that we have filled data it needs.
Perhaps, the solution is to tweak the period-size and the buffer-size configuration of the driver from userspace.

To be further investigated....

Changed in linaro-ubuntu:
status: New → Confirmed
importance: Undecided → Medium
milestone: none → 12.04
Changed in igloocommunity:
assignee: Thomas Espersson (espersson) → Ramesh Chandrasekaran (ramesh-chandrasekaran)
Revision history for this message
Ramesh Chandrasekaran (ramesh-chandrasekaran) wrote :

Do you have any procedure to test pulse-audio in ubuntu ?

1) I ran the pulseaudio server as root with pulse-audio –system & (although it is not recommended to run this as root system wide, but running as other user throws many errors )
2) I ran the alsamixer, able to see the pulse audio device. (initially gave some authentication errors, connecting to pulse audio server, but got it fixed, by setting authentications flags to anonymous in system.pa file)
3) But, aplay –Dpulse xyz.wav, still doesn’t play anything on the headphone (not even the sloppy playback as mentioned in the launchpad)

 Do we have any basic doc / setup in ubuntu for snowball on the config setup for this pulse audio ?

Revision history for this message
Ramesh Chandrasekaran (ramesh-chandrasekaran) wrote :

Able to get the sloppy playback, by changing some conf in system.pa. Will post if there is any solution for this sloppy playback here

Revision history for this message
Feng Wei (b34248) wrote :

@Ramesh Chandrasekaran

1. a lot of modules won't be loaded when running pulseaudio by root, which provide the most of functions.
2. "running as other user throws many errors" -- What errors? You must resolve them first.
3. which linaro release version are you running on?

Revision history for this message
Riku Voipio (riku-voipio) wrote :

Ramesh,

The test procedure briefly explained in the first message of the bug
report. Lets make it more explicit:

1) Wait until the user interface has fully booted
2) click on the volume icon up right in the screen
3) select "sound settings" from the popup screen
4) select "hardware" tab
5) select test speakers
6) press on the "test" buttons under speaker buttons

A sound "left speaker" or "right speaker" sound should be heard.

Pulseaudio is used by default so no specific configuration or setup
should be necessary for pulseaudio testing.

On 10 April 2012 08:56, Ramesh Chandrasekaran
<email address hidden> wrote:
> Do you have any procedure to test pulse-audio in ubuntu ?
>
> 1)      I ran the pulseaudio server as root with pulse-audio –system & (although it is not recommended to run this as root system wide, but running as other user throws many errors )
> 2)      I ran the alsamixer, able to see the pulse audio device. (initially gave some authentication errors, connecting to pulse audio server, but got it fixed, by setting authentications flags to anonymous in system.pa file)
> 3)      But, aplay –Dpulse xyz.wav, still doesn’t play anything on the headphone (not even the sloppy playback as mentioned in the launchpad)
>
>  Do we have any basic doc / setup in ubuntu for snowball on the config
> setup for this pulse audio ?
>
> --
> You received this bug notification because you are a member of Linaro
> Developer Platform, which is subscribed to Linaro-Ubuntu.
> https://bugs.launchpad.net/bugs/939593
>
> Title:
>  Choppy playback on Snowball through pulseaudio
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/igloocommunity/+bug/939593/+subscriptions

Changed in igloocommunity:
milestone: 2012.04 → 2012.05
Changed in linaro-ubuntu:
assignee: Ricardo Salveti (rsalveti) → Riku Voipio (riku-voipio)
milestone: 12.04 → 12.05
Tom Gall (tom-gall)
Changed in linaro-multimedia-project:
assignee: nobody → Feng Wei (b34248)
milestone: none → 2012.05
Changed in igloocommunity:
milestone: 2012.05 → 2012.06
Changed in linaro-ubuntu:
milestone: 12.05 → 12.06
Changed in igloocommunity:
status: Confirmed → In Progress
Revision history for this message
Ramesh Chandrasekaran (ramesh-chandrasekaran) wrote :

Root cause of the issue:

Since pulse audio, tries to use, bigger audio period size, with minimum fragments to improve the performance, using timer based scheduling, it request the audio driver maximum period size supported and minimum fragment number supported.

When a bigger period size greater than 131070 bytes (that is greater than 32767 frames), the dma driver in snowball, could not carry out such a bigger chunk in one shot (hardware limitation), so it tries to split the transaction in to two and raises interrupt for it. Either The interrupt at inappropriate time to audio driver before the actual buffer is flushed to i2s (or) due to dma limitation, there may be some data lost in deliviering to msp i2s buffer.

The way choosen here to handle the problem was to limit the period size to maximum dma limited segment size in audio driver(so that dma never goes for splitting the single period transaction), instead of fixing the actual dma driver for multiple split transaction which could take more effort. The period size of 32676 frames, needs to be more than sufficient for the pulse audio's bigger buffer requirement.

The Fix is sent for review.

Changed in igloocommunity:
status: In Progress → Fix Committed
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

Do you have additional pointers for the proposed fix? Seems nothing landed at the 3.3 based kernel this cycle, so it'd be nice to check if you're fix is indeed applied.

Changed in linaro-ubuntu:
milestone: 12.06 → 12.07
Revision history for this message
Ramesh Chandrasekaran (ramesh-chandrasekaran) wrote :

Below, is the fix for the choppy playback. I got notified from phillipe that, the patch is already merged.

diff --git a/sound/soc/ux500/ux500_pcm.h b/sound/soc/ux500/ux500_pcm.h index 3d1ea4f..0386784 100644
--- a/sound/soc/ux500/ux500_pcm.h
+++ b/sound/soc/ux500/ux500_pcm.h
@@ -26,7 +26,12 @@
 #define UX500_PLATFORM_MAX_CHANNELS 8

 #define UX500_PLATFORM_PERIODS_BYTES_MIN 128
-#define UX500_PLATFORM_PERIODS_BYTES_MAX (64 * PAGE_SIZE)
+
+/* Our DMA supports maximum of 131070 bytes segment size
+ * So, we can support period_size of max 32767 frames */
+#define UX500_PLATFORM_PERIODS_BYTES_MAX 131070
+
 #define UX500_PLATFORM_PERIODS_MIN 2
 #define UX500_PLATFORM_PERIODS_MAX 48
 #define UX500_PLATFORM_BUFFER_BYTES_MAX (2048 * PAGE_SIZE)

Changed in linaro-ubuntu:
milestone: 12.07 → 12.08
Fathi Boudra (fboudra)
Changed in linaro-ubuntu:
milestone: 12.08 → 12.09
Changed in igloocommunity:
status: Fix Committed → Fix Released
Changed in linaro-ubuntu:
milestone: 12.09 → none
Fathi Boudra (fboudra)
Changed in linaro-ubuntu:
assignee: Riku Voipio (riku-voipio) → nobody
importance: Medium → Undecided
status: Confirmed → Won't Fix
Changed in linaro-multimedia-project:
status: New → Won't Fix
assignee: Feng Wei (b34248) → nobody
milestone: 2012.05 → none
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.