knute
Posts: 727
Joined: Thu Oct 23, 2014 12:14 am
Location: Texas
Contact: Website

Java sound audio only goes out the analog port?

Thu Oct 14, 2021 2:31 am

I discovered that programs that used java sound were not making any on my Pi4. After trying numerous things that didn't work, I discovered that the sound was coming out the analog port even though all other sound goes out the HDMI port. It is configured to use the HDMI port. I don't know when this stopped working correctly but it has to be in the last few months. I've tested it with Bellsoft Java 17 and OpenJDK 11. No difference.

Any ideas on how to get this to work?

Joop99
Posts: 72
Joined: Fri Jul 23, 2021 1:23 pm

Re: Java sound audio only goes out the analog port?

Fri Oct 15, 2021 3:37 pm

See this topic: viewtopic.php?f=28&hilit=java%20sound&p ... 5#p1626794
May be this helps, did for me. I have a Pi400 and OpenJDK11. Have sound on USB via a USB soundcard.

knute
Posts: 727
Joined: Thu Oct 23, 2014 12:14 am
Location: Texas
Contact: Website

Re: Java sound audio only goes out the analog port?

Sat Oct 16, 2021 12:53 am

Joop99 wrote:
Fri Oct 15, 2021 3:37 pm
See this topic: viewtopic.php?f=28&hilit=java%20sound&p ... 5#p1626794
May be this helps, did for me. I have a Pi400 and OpenJDK11. Have sound on USB via a USB soundcard.
Thanks Joop99. I thought I had tried that a couple of days ago but apparently got something wrong. I had 3 sound.properties files in the Pi and I added those lines to all of them and it works fine now.

For anybody else with the same problem, swap out any existing provider lines in sound.properties with these:

javax.sound.sampled.Clip=com.sun.media.sound.DirectAudioDeviceProvider
javax.sound.sampled.Port=com.sun.media.sound.PortMixerProvider
javax.sound.sampled.SourceDataLine=com.sun.media.sound.DirectAudioDeviceProvider
javax.sound.sampled.TargetDataLine=com.sun.media.sound.DirectAudioDeviceProvider

Return to “Java”