Modify

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#12229 closed enhancement (fixed)

Unit test for audio playback on Linux

Reported by: Don-vip Owned by: team
Priority: normal Milestone: 15.12
Component: Core audio Version:
Keywords: unit test audio linux debian ubuntu alsa java sound jenkins pulseaudio wav Cc: stoecker, bastiK, simon04, naoliv, malenki, skyper, mdk

Description (last modified by Don-vip)

I have added a unit test for Audio (wav) playback in r9144:9146.

It works fine on Windows, but I can't get it working on our Jenkins/Linux server. The test results in:

Java 7:

javax.sound.sampled.LineUnavailableException
	at org.classpath.icedtea.pulseaudio.PulseAudioMixer.openImpl(PulseAudioMixer.java:714)
	at org.classpath.icedtea.pulseaudio.PulseAudioMixer.openLocal(PulseAudioMixer.java:588)
	at org.classpath.icedtea.pulseaudio.PulseAudioMixer.openLocal(PulseAudioMixer.java:584)
	at org.classpath.icedtea.pulseaudio.PulseAudioMixer.open(PulseAudioMixer.java:579)
	at org.classpath.icedtea.pulseaudio.PulseAudioDataLine.open(PulseAudioDataLine.java:94)
	at org.classpath.icedtea.pulseaudio.PulseAudioSourceDataLine.open(PulseAudioSourceDataLine.java:75)
	at org.classpath.icedtea.pulseaudio.PulseAudioSourceDataLine.open(PulseAudioSourceDataLine.java:90)
	at org.openstreetmap.josm.tools.AudioPlayer.run(AudioPlayer.java:348)

Java 8:

java.lang.IllegalArgumentException: No line matching interface SourceDataLine supporting format PCM_UNSIGNED 22050.0 Hz, 8 bit, mono, 1 bytes/frame,  is supported.
java.lang.IllegalArgumentException: No line matching interface SourceDataLine supporting format PCM_UNSIGNED 22050.0 Hz, 8 bit, mono, 1 bytes/frame,  is supported.
	at javax.sound.sampled.AudioSystem.getLine(AudioSystem.java:479)
	at org.openstreetmap.josm.tools.AudioPlayer.run(AudioPlayer.java:347)

Maybe because we don't have any sound card on the server.

I assume it is possible to use a virtual sound device as a workaround but I can't find how to do it.

I have installed pulseaudio server (apt-get install pulseaudio) and started it (service pulseaudio start).

When I try to play wav file manually with jenkins user I get:

jenkins@josm:~$ aplay /var/lib/jenkins/jobs/JOSM/workspace/test/data/regress/6851/20111003_121226.wav
Failed to create secure directory (/run/user/0/pulse): Permission denied
Failed to create secure directory (/run/user/0/pulse): Permission denied
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Access denied

aplay: main:722: audio open error: Connection refused

I have added jenkins user to audio and pulse groups, does not change anything.

When trying as root I get:

root@josm:~# aplay /var/lib/jenkins/jobs/JOSM/workspace/test/data/regress/6851/20111003_121226.wav
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Access denied

aplay: main:722: audio open error: Connection refused

Using null it seems to work, but I don't know if we can use it as default, or tell Java to use it:

root@josm:~# aplay -D null /var/lib/jenkins/jobs/JOSM/workspace/test/data/regress/6851/20111003_121226.wav
Playing WAVE '/var/lib/jenkins/jobs/JOSM/workspace/test/data/regress/6851/20111003_121226.wav' : Unsigned 8 bit, Rate 22050 Hz, Mono

I'm kind of lost here, can anyone with good knowledge of Audio on Linux please help me?

Attachments (0)

Change History (7)

comment:1 by Don-vip, 9 years ago

Cc: stoecker bastiK simon04 naoliv malenki skyper mdk added
Description: modified (diff)
Milestone: 15.12

A little help from a Linux guru? :)

comment:2 by Don-vip, 9 years ago

Resolution: fixed
Status: newclosed

Now it's working.. I don't get how it suddenly worked with jdk 8./it was still failing with jdk 7. The solution was to disable icedtea pulseaudio provider in sounds.properties and use com.sun.* instead.

in reply to:  2 comment:3 by bastiK, 9 years ago

Replying to Don-vip:

Now it's working.. I don't get how it suddenly worked with jdk 8.

I had a go and loaded the snd-dummy kernel module. This is supposed to work, but I still couldn't play a file with aplay, so I gave up. If it has an effect on java, we should make sure it is loaded on reboot.

comment:4 by Don-vip, 9 years ago

okay thanks! now I understand better :)

comment:5 by Don-vip, 9 years ago

The audio unit test is failing again since a few days (before we switched to the new server) and I can't figure why. I thought it was because of r9779 but I disabled/reverted everything related in r9785 then r9803.

Maybe it was due to a software update, or a reboot, I don't know. Now we have switched to the new server and the test is still failing. I have done everything I remembered of from this ticket, and also enabled snd-dummy from your comment, but it's still not working, can you please help me? I have restored the SoundAudit.java file.

in reply to:  description comment:6 by bastiK, 9 years ago

Seems to work now after reboot.

Replying to Don-vip:

When I try to play wav file manually with jenkins user I get:

jenkins@josm:~$ aplay /var/lib/jenkins/jobs/JOSM/workspace/test/data/regress/6851/20111003_121226.wav
Failed to create secure directory (/run/user/0/pulse): Permission denied

You can get rid of this error with

$ unset XDG_RUNTIME_DIR

(I don't think it has anything to do with normal Jenkins process, this is just a problem when logging in with su - jenkins.)

Also interesting read: TheAudioGroup. Apparently the jenkins user has to be the first one to "grab" the sound device, whatever that means.

comment:7 by Don-vip, 9 years ago

In 9814/josm:

see #12229 - revert r9785 and r9803: problem with audio unit test was unrelated

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.