Bug 85445

Summary: PlaneShift with OpenAL sound stutters: PulseAudio returned minreq > tlength/2; expect break up
Product: PulseAudio Reporter: Martin Steigerwald <Martin>
Component: clientsAssignee: pulseaudio-bugs
Status: RESOLVED WORKSFORME QA Contact: pulseaudio-bugs
Severity: normal    
Priority: medium CC: lennart, simonandric5
Version: unspecified   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: pulseaudio debug log
syslog output of kernel boot

Description Martin Steigerwald 2014-10-25 15:08:06 UTC
Hello!

When using PlaneShift with Pulseaudio sound stutters badly. This happens with either the excellent sounding JBL Pebbles USB loudspeakers or ThinkPad T520 internal audio.

The stuttering doesn´t happen without PulseAudio. Thats my current main reason why I still run my system without PulseAudio.

How to reproduce:

1) Make sure OpenAL is installed and available.

2) Get and install Linux PlaneShift client from: http://www.planeshift.it/Download

The client itself open source (the content is not) and I think you do not have to register an account to at least get to the start login screen which already has music that stutters. Accounts are for free tough and I think all you need it a username and a mail address.

Its graphical installer either installs to home directory or /opt/PlaneShift

3) Start the client

4) Click Settings and check for Sound Renderer = OpenAL.

5) Click "Play"

PlaneShift is played best with OpenAL, without OpenAL sound is… well… just not the same experience.


PulseAudio uses standard configuration as far as I am aware. I coded system-wide alsoft.conf to use JBL Pebbles instead of internal speakers. But as said it happens also with internal audio.

Audio playback via Amarok or FS-UAE Amiga emulator is okay with PulseAudio.

I have not found the error message PulseAudio returned minreq > tlength/2; expect break up within libopenal source code and I have no idea what exactly it means.


This is my system:

martin@merkaba:~> phoronix-test-suite system-info

Phoronix Test Suite v5.2.1
System Information

Hardware:
Processor: Intel Core i5-2520M @ 3.20GHz (4 Cores), Motherboard: LENOVO 42433WG, Chipset: Intel 2nd Generation Core Family DRAM, Memory: 16384MB, Disk: 300GB INTEL SSDSA2CW30 + 480GB Crucial_CT480M50, Graphics: Intel HD 3000 (1300MHz), Audio: Intel 6 /C200, Network: Intel 82579LM Gigabit Connection + Intel Centrino Advanced-N 6205

Software:
OS: Debian unstable, Kernel: 3.17.0-tp520 (x86_64), Desktop: KDE 4.14.2, Display Server: X Server 1.16.1, Display Driver: intel 2.21.15, OpenGL: 3.1 Mesa 10.3.1, Compiler: GCC 4.9.1, File-System: btrfs, Screen Resolution: 1920x1080


This is my audio hardware:

martin@merkaba:~> lsusb | grep Harm    
Bus 001 Device 011: ID 05fc:0231 Harman Multimedia 
martin@merkaba:~> lspci -nn | grep Audio   
00:1b.0 Audio device [0403]: Intel Corporation 6 Series/C200 Series Chipset Family High Definition Audio Controller [8086:1c20] (rev 04)


This is Pulseaudio and OpenAL versions installed:

martin@merkaba:~> apt-show-versions | egrep -i "pulseaudio|openal|alsa"
alsa-base:all/sid 1.0.27+1 uptodate
alsa-utils:amd64/sid 1.0.28-1 uptodate
alsaplayer-alsa:amd64/sid 0.99.81-1 uptodate
alsaplayer-common:amd64/sid 0.99.81-1 uptodate
alsaplayer-text:amd64/sid 0.99.81-1 uptodate
gstreamer0.10-alsa:amd64/sid 0.10.36-2 uptodate
gstreamer0.10-pulseaudio:amd64/sid 0.10.31-3+nmu4+b1 uptodate
gstreamer1.0-pulseaudio:amd64/sid 1.4.3-2 uptodate
libghc-openal-dev:amd64/sid 1.4.0.2-3 uptodate
libopenal-data:all/sid 1:1.15.1-5 uptodate
libopenal-dev:amd64/sid 1:1.15.1-5 uptodate
libopenal1:amd64/sid 1:1.15.1-5 uptodate
libopenal1:i386/sid 1:1.15.1-5 uptodate
libsox-fmt-alsa:amd64/sid 14.4.1-4 uptodate
pulseaudio:amd64/sid 5.0-13 uptodate
pulseaudio-module-x11:amd64/sid 5.0-13 uptodate
pulseaudio-utils:amd64/sid 5.0-13 uptodate

PlaneShift client version is 0.6.2 as PlaneShift Launcher 3.06 tells me.


Also see:
[pulseaudio-discuss] PulseAudio and OpenAL games: AL lib: pulseaudio.c:331: PulseAudio returned minreq > tlength/2; expect break up
http://lists.freedesktop.org/archives/pulseaudio-discuss/2014-September/021678.html



I get this debug output when starting PlaneShift on command line:

[…]
DEBUG: Initializing OpenAL sound system
DEBUG: Retrieving available devices.
DEBUG: Available OpenAL device: PulseAudio Default
DEBUG: Available OpenAL device: ALSA Default
DEBUG: Available OpenAL device: No Output
DEBUG: Default OpenAL device: PulseAudio Default
DEBUG: No device specified
DEBUG: Falling back on default device
DEBUG: OpenAL context frequency: 44100 Hz
DEBUG: OpenAL context refresh: 43 Hz
DEBUG: OpenAL context uses asynchronous (threaded) context
DEBUG: OpenAL context should support 255 mono sources
DEBUG: OpenAL context should support 1 stereo sources
No updates needed!
Checking for updates to all files: No updates needed!
Skin loaded: minimatuux2.zip
DEBUG: Closing OpenAL sound system
DEBUG: Closing OpenAL sound system
*****MinidumpDescriptor::UpdatePath = /tmp/6588eaa2-fbdd-9bbe-2b58277c-5059680d.dmp
Your configuration files are in... /home/martin/.PlaneShift


AL lib: pulseaudio.c:331: PulseAudio returned minreq > tlength/2; expect break up


ATTENTION: default value of option force_s3tc_enable overridden by environment.

planeshift.application.client:
  PlaneShift Azure Spirit (0.6.1)
  This game uses Crystal Space Engine created by Jorrit and others
  2.1.0.4234 [Unix-x86(64)-GCC]
[…]

Thanks,
Martin
Comment 1 Raymond 2014-10-26 02:09:55 UTC
you have to provide pulseaudio verbose log while playing openal game


DEBUG: OpenAL context should support 255 mono sources
DEBUG: OpenAL context should support 1 stereo sources


only the back ground music is playing through stereo

other sound events are mono and openal perform 3d spatalizaion 

most  event sounds are full ampltiude , openal computed the atten and doppler effect when the listener is moving towards/away from those mono sound sources
Comment 2 Martin Steigerwald 2014-10-26 11:45:11 UTC
(In reply to Raymond from comment #1)
> you have to provide pulseaudio verbose log while playing openal game

I need *clear* and *working* instruction on how to do this.

I tried:

echo autospawn = no >> ~/.config/pulse/client.conf  #use ~/.pulse/client.conf on Ubuntu <= 12.10
killall pulseaudio
LANG=C pulseaudio -vvvv --log-time=1 > ~/pulseverbose.log 2>&1

https://wiki.ubuntu.com/PulseAudio/Log

Result: I don´t hear any sound in PlaneShift at all anymore after this. Also KDE systemsettings display "Pulseaudio-Server" instead of the sound device. It seems to me that new Pulseaudio does not get registered with desktop session.


I tried:

merkaba:/etc/pulse> diff -u daemon.conf daemon.conf-debug
--- daemon.conf 2014-10-26 12:27:55.373316432 +0100
+++ daemon.conf-debug   2014-10-26 12:20:04.856111541 +0100
@@ -50,11 +50,10 @@
 ; log-meta = no
 ; log-time = no
 ; log-backtrace = 0
-
 ; Für Debugging
-; log-target = file:/var/log/pulseaudio-debug.log
-; log-level = 4
-; log-time = 1
+log-target = file:/var/log/pulseaudio-debug.log
+log-level = 4
+log-time = 1
 
 # resample-method defaults to  speex-float-1 on most architectures,
 # speex-fixed-1 on ARM


But information still landed in syslog and was in german as well.



I tried:

merkaba:~#1> diff -u /usr/bin/start-pulseaudio-kde.orig /usr/bin/start-pulseaudio-kde
--- /usr/bin/start-pulseaudio-kde.orig  2014-10-12 07:50:26.000000000 +0200
+++ /usr/bin/start-pulseaudio-kde       2014-10-26 12:36:27.669922285 +0100
@@ -26,7 +26,7 @@
     EXIT_WITH_X_SESSION=no
 else
     EXIT_WITH_X_SESSION=yes
-    /usr/bin/pulseaudio --start "$@"
+    LANG=C /usr/bin/pulseaudio -vvvv --log-time=1 > /var/tmp/pulseverbose.log 2>&1 &
 fi

but PlaneShift client did not seem to use Pulseaudio at all with it. It seems it needs the "--start".

Before that I also tried with "--start" but it just put the first line on daemon startup into that logfile and then no more.

Really, this *got* to be easier for users to help debugging PulseAudio issues.

I will now have one last try:

use LANG=C in start-pulseaudio-kde and daemon.conf with verbose + leave it to syslog and grep pulseaudio related stuff out from it.

*sigh* (sorry if this sounds like a rant, but really, this took more more than one hour without any usable log so far).
Comment 3 Martin Steigerwald 2014-10-26 12:06:11 UTC
Created attachment 108445 [details]
pulseaudio debug log

Obtained with:

log-target = syslog
log-level = 4
log-time = 1

in daemon.conf

merkaba:~> diff -u /usr/bin/start-pulseaudio-kde.orig /usr/bin/start-pulseaudio-kde     
--- /usr/bin/start-pulseaudio-kde.orig  2014-10-12 07:50:26.000000000 +0200
+++ /usr/bin/start-pulseaudio-kde       2014-10-26 12:46:09.347951247 +0100
@@ -26,7 +26,7 @@
     EXIT_WITH_X_SESSION=no
 else
     EXIT_WITH_X_SESSION=yes
-    /usr/bin/pulseaudio --start "$@"
+    LANG=C /usr/bin/pulseaudio --start "$@"
 fi
 
and grep pulseaudio /var/log/syslog > attachedfile

With the following scenario:

1. KDE sessions tartup
2. Quick test in KDE systemsettings whether PulseAudio plays something
3. Quit KDE systemsettings
4. Start PlaneShift client and proceed to login screen.
5. Listen to music is playing stutteringly
6. Login to the PlaneShift server
7. Listen to the sound and music playing stuggeringly
8. Then copy syslog and grep.
Comment 4 Martin Steigerwald 2014-10-26 12:07:58 UTC
Created attachment 108446 [details]
syslog output of kernel boot

Just in case you need anything in there.
Comment 5 Martin Steigerwald 2014-10-26 12:24:35 UTC
Move the debug easyness stuff into a different bug report:

Bug #85483 - Please make debugging easier

in order to keep that to PlaneShift OpenAL sound stuttering issue.
Comment 6 Raymond 2014-11-03 02:30:10 UTC
(In reply to Martin Steigerwald from comment #4)
> Created attachment 108446 [details]
> syslog output of kernel boot
> 
> Just in case you need anything in there.

at 12:31:31

"Starting playback" was immediately followed by several "cutting sleep time for the initial iteration by half"

this mean the first write did not fill up 0.371ms buffer
Comment 7 Martin Steigerwald 2015-09-20 13:06:07 UTC
(In reply to Raymond from comment #6)
> (In reply to Martin Steigerwald from comment #4)
> > Created attachment 108446 [details]
> > syslog output of kernel boot
> > 
> > Just in case you need anything in there.
> 
> at 12:31:31
> 
> "Starting playback" was immediately followed by several "cutting sleep time
> for the initial iteration by half"
> 
> this mean the first write did not fill up 0.371ms buffer

Thank you Raymond.

What can I do?

I am having various audio issues recently with the switch from Phonon Qt4 => Qt5 and recent updates and I want to switch to Pulseaudio as thats the only audio output platform officially supported by Phonon developers. While it still allows to output to ALSA directly (well though vlc or gstreamer), this is not officially supported.

I soooo want a simple and out of the box working multimedia layer on Linux.
Comment 8 Raymond 2015-09-21 01:56:38 UTC
http://repo.or.cz/w/openal-soft.git/commitdiff/ee61f7a55caabec6f9c1394ce84e343d940cab92?hp=241ddf76d4e3b7b0efd771bbc8270e1da2a7ca72



 this mean Device->NumUpdates <= 1

 Device->NumUpdates = (data->attr.tlength/data->frame_size) / Device->UpdateSize;
Comment 9 Martin Steigerwald 2015-09-21 08:14:19 UTC
Raymond, I am no audio expert: Does that mean that PlaneShift is slow to deliver new samples to play? For ALSA it works just fine, why doesn´t it work for PulseAudio then? Does PulseAudio require a different buffer size? Where can it be fixed? Can it be fixed / worked-around by changing frame size somewhere (maybe in PulseAudio configuration)?

Currently there is a regression with PlaneShift and PulseAudio that just goes away when I remove PulseAudio from the equation. But if it would still be something that needs fixing within the game or within OpenAL, I can forward this bug. I just like to provide clear information then on what needs to be done for fixing it. Thank you, Martin
Comment 10 Raymond 2015-09-21 09:22:46 UTC
http://repo.or.cz/w/openal-soft.git/blob/HEAD:/alsoftrc.sample

## period_size:
#  Sets the update period size, in frames. This is the number of frames needed
#  for each mixing update. Acceptable values range between 64 and 8192.
#period_size = 1024

## periods:
#  Sets the number of update periods. Higher values create a larger mix ahead,
#  which helps protect against skips when the CPU is under load, but increases
#  the delay between a sound getting mixed and being heard. Acceptable values
#  range between 2 and 16.
#periods = 4



OpenAL is an environmental 3D audio library that aims to provide an open replacement for proprietary (and generally incompatible with one another) 3D audio systems such as EAX and A3D. OpenAL can add realism to a game by simulating attenuation (degradation of sound over distance), the Doppler effect (change in frequency as a result of motion), and material densities.
Comment 11 Arun Raghavan 2015-09-21 12:24:59 UTC
Martin, could you also attach pulseaudio log of the problem occurring on your internal audio?

It does look like there is a problem with the rate at which data is being provided by the PlaneShift client, but it's hard to figure out why. Let me see if I can find some openal code that I can quickly run to repro the problem.
Comment 12 Martin Steigerwald 2015-09-21 13:58:16 UTC
(In reply to Arun Raghavan from comment #11)
> Martin, could you also attach pulseaudio log of the problem occurring on
> your internal audio?

You mean the same as in comment #3 but with OpenAL switched to internal audio instead?

I installed PulseAudio again, and I had to fix quite some places where I disabled it back then. I will try to play around with the OpenAL settings to fix the issue for me. And if I found a working setting, I will post it here. And look into providing more debug output with standard settings and internal audio. Can take some days since I will be back home late today.
Comment 13 Martin Steigerwald 2015-09-21 15:13:23 UTC
As I now wanted to adapt openal settings or gather further debug logs I found it to be working out of the box with:

martin@merkaba:~> apt-show-versions | egrep -i "pulseaudio|openal|alsa"
alsa-base:all/sid 1.0.27+1 uptodate
alsa-utils:amd64/sid 1.0.29-1 uptodate
alsa-utils:i386 not installed
alsaplayer-alsa:amd64/sid 0.99.81-1+b1 uptodate
alsaplayer-alsa:i386 not installed
alsaplayer-common:amd64/sid 0.99.81-1+b1 uptodate
alsaplayer-common:i386 not installed
alsaplayer-text:amd64/sid 0.99.81-1+b1 uptodate
alsaplayer-text:i386 not installed
[… gstreamer removed as libopenal does not depend on it …]
libopenal-data:all/sid 1:1.16.0-3 uptodate
libopenal-dev:amd64/sid 1:1.16.0-3 uptodate
libopenal-dev:i386 not installed
libopenal1:amd64/sid 1:1.16.0-3 uptodate
libopenal1:i386 not installed
libsox-fmt-alsa:amd64/sid 14.4.1-5 uptodate
libsox-fmt-alsa:i386 not installed
pulseaudio:amd64/sid 6.0-5 uptodate
pulseaudio:i386 not installed
pulseaudio-module-x11:amd64/sid 6.0-5 uptodate
pulseaudio-module-x11:i386 not installed
pulseaudio-utils:amd64/sid 6.0-5 uptodate
pulseaudio-utils:i386 not installed

Thats openal 1.15 => 1.16 and PulseAudio 5 => 6.

So I will leave things as they are for now and close as worksforme.

Thank you Raymond for your help!

Now I can focus on looked at inconsistencies with Phonon + PulseAudio as this is an officially supported combination (from Phonon developers).

Thanks,
Martin

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.