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.

Matthieu Brucher
  • 21,634
  • 7
  • 38
  • 62
ChrisR
  • 1,227
  • 1
  • 10
  • 17
  • 1
    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 http://sscce.org/ so we can try to reproduce it and fix it? – Bernd Elkemann Jul 16 '11 at 19:11
  • 4
    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! – mikera Jul 17 '11 at 09:52
  • 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 reset – ChrisR Jul 18 '11 at 01:01
  • 2
    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). – lucas1000001 Jul 24 '11 at 16:35
  • 1
    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? – Panayiotis Karabassis Jun 12 '12 at 19:12
  • 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. – Arnout Engelen Aug 02 '12 at 21:10

3 Answers3

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.

Daniel Baktiar
  • 1,692
  • 11
  • 22
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?

hcarver
  • 7,126
  • 4
  • 41
  • 67
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 ..."

Community
  • 1
  • 1
Justin
  • 397
  • 7
  • 17