Well, I got it working…
Here’s what needs to be done to output the sound from openhab to pulseaudio (and a BT connected speaker in my case).
I got it working using oracle-java8-jdk (I also tried the same with Zulu, but no luck)
Install need packages
apt-get install libpulse-jni libpulse-java
Copy pulse-java
files:
sudo cp /usr/lib/arm-linux-gnueabihf/jni/libpulse-java.so /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/lib/arm/
sudo cp /usr/share/java/pulse-java* /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/lib/ext/
Edit /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/lib/sound.properties
and add the following lines:
javax.sound.sampled.Clip=org.classpath.icedtea.pulseaudio.PulseAudioMixerProvider
javax.sound.sampled.Port=org.classpath.icedtea.pulseaudio.PulseAudioMixerProvider
javax.sound.sampled.SourceDataLine=org.classpath.icedtea.pulseaudio.PulseAudioMixerProvider
javax.sound.sampled.TargetDataLine=org.classpath.icedtea.pulseaudio.PulseAudioMixerProvider
And voila!, now smarthome:audio play doorbell.mp3
plays nicely on my BT speaker
Same approach didn’t work with Zulu :
# ls -la /opt/zulu/8u112/jre/lib/ext/
total 7716
drwxrwxr-x 2 root root 4096 Feb 13 11:50 .
drwxrwxr-x 10 root root 4096 Feb 13 11:41 ..
-rw-rw-r-- 1 root root 3861228 Dec 23 12:56 cldrdata.jar
-rw-rw-r-- 1 root root 8287 Dec 23 12:56 dnsns.jar
-rw-rw-r-- 1 root root 44517 Dec 23 12:56 jaccess.jar
-rw-rw-r-- 1 root root 1179094 Dec 23 12:56 localedata.jar
-rw-rw-r-- 1 root root 617 Dec 23 12:56 meta-index
-rw-rw-r-- 1 root root 2032277 Dec 23 12:56 nashorn.jar
-rw-r--r-- 1 root root 69031 Feb 13 11:50 pulse-java-2.4.7.jar
-rw-r--r-- 1 root root 69031 Feb 13 11:50 pulse-java.jar
-rw-rw-r-- 1 root root 38163 Dec 23 12:56 sunec.jar
-rw-rw-r-- 1 root root 261567 Dec 23 12:56 sunjce_provider.jar
-rw-rw-r-- 1 root root 238950 Dec 23 12:56 sunpkcs11.jar
-rw-rw-r-- 1 root root 68938 Dec 23 12:56 zipfs.jar
#~ $ ls -la /opt/zulu/8u112/jre/lib/arm/
total 60
drwxr-xr-x 2 root root 4096 Feb 13 11:42 .
drwxrwxr-x 10 root root 4096 Feb 13 11:41 ..
-rw-r--r-- 1 root root 50772 Feb 13 11:42 libpulse-java.so
# cat cat /opt/zulu/8u112/jre/lib/sound.properties
javax.sound.sampled.Clip=org.classpath.icedtea.pulseaudio.PulseAudioMixerProvider
javax.sound.sampled.Port=org.classpath.icedtea.pulseaudio.PulseAudioMixerProvider
javax.sound.sampled.SourceDataLine=org.classpath.icedtea.pulseaudio.PulseAudioMixerProvider
javax.sound.sampled.TargetDataLine=org.classpath.icedtea.pulseaudio.PulseAudioMixerProvider
Runnin a java simple program to test the sound output gives:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no pulse-java in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at org.classpath.icedtea.pulseaudio.SecurityWrapper.loadNativeLibrary(SecurityWrapper.java:27)
at org.classpath.icedtea.pulseaudio.EventLoop.<clinit>(EventLoop.java:97)
at org.classpath.icedtea.pulseaudio.PulseAudioMixer.openImpl(PulseAudioMixer.java:654)
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 com.sun.media.sound.DataPusher.start(DataPusher.java:107)
at com.sun.media.sound.DataPusher.start(DataPusher.java:91)
at sun.audio.AudioDevice.startSampled(AudioDevice.java:118)
at sun.audio.AudioDevice.openChannel(AudioDevice.java:190)
at sun.audio.AudioPlayer.start(AudioPlayer.java:133)
at PlaySound.main(PlaySound.java:26)
Anybody got a clue? I’d like to get rid of Oracle…