Music in JLayer stops when other apps play music
Asked Answered
S

3

25

I have written a few hundred line app in Clojure that uses the JLayer Java library for audio where I run mp3s in the background. This works fine but as soon as I run any other music, YouTube etc in the background (I'm running Arch Linux) the sounds in my app completely stop.

I have wasted the last two hours and tried dozens of things to fix this so any advice is appreciated.

Sovereignty answered 16/7, 2011 at 15:12 Comment(6)
My first guess would be that your app is paused if it is placed in the background, my second guess would be that the sound-buffer only works for one application. Does your application do anything else if it is in the background? Try making it write to a file and see if that file continues growing even while your app is in the background. Can you give us a sscce.org so we can try to reproduce it and fix it?Bifilar
sounds more like a sound driver problem than a Clojure / Java problem as such.... you might be better asking in a forum of Linux experts!Meyers
thanks for the reply's its still an issue, I can run multiple sound streams from other sources ie skype + youtube + mp3 at same time works fine, additionally, I can make my app create graphs while music is running the the background, so it can function while audio is on.. just when another device has audio it will stop immediately and won't resume until resetSovereignty
Yeah, I'd agree it's probably sound system issues. I've toyed around with a similar setup lately (Clojure x Java x Arch Linux), but recording from a loopback interface. Things to watch out for : 1) What sound Port is your app listening / streaming out on (see javax.sound.sampled.AudioSystem to see what mixers are available etc). If you have several try changing to another (you can use Audacity to also see the mixers available). 2) Check your ALSA configuration (I had to tweak mine and add some new mixers through the .asoundrc config file to add a loopback interface).Margaux
This is from a user, not programmer, perspective. I frequently have this kind of problem when I use ALSA directly. Can you try using PulseAudio?Thulium
I think the first step to figure out what's going on is to determine which API JLayer uses to get sound to your speakers: /dev/dsp, PulseAudio, JACK, some other sound daemon, /dev/snd/*, etcetera.Packer
S
1

Since you have stated that you're on Linux, the problem could be on your ALSA driver. Check whether this article will help you fix the problem.

Swashbuckler answered 29/12, 2011 at 11:15 Comment(0)
P
0

Though I have no personal coding experience with sound in Java, it is my understanding that there are some mismatched assumptions and/or incomplete APIs when it comes to Linux sound services and also with Java sound interfaces. Mix the two together and you get what you've run into. While playing with FreeTTS, I rand into similar, possibly same problem:

FreeTTS, Java, Linux: Workaround for "LINE UNAVAILABLE: Format is ..."

Perineuritis answered 22/11, 2011 at 17:21 Comment(0)
G
0

I've had problems with PulseAudio and Jack fighting for control of sound card before.

Have you considered that? Can you check whether the two apps are fighting each other in that way?

Gadroon answered 2/8, 2012 at 18:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.