LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-09-2005, 03:11 PM   #1
rpz
Member
 
Registered: Mar 2005
Posts: 126

Rep: Reputation: 15
Java - How to play well with others


After some googling I finally found out how to make most linux apps be more cooperative WRT sound (meaning they should not hijack the soundcard for themselves like win95 back in the days). The really simple solution I used was to have the following in my /etc/asound.conf:
Code:
pcm.!default {
type plug
slave.pcm "swmixer"
}

pcm.swmixer {
type dmix
ipc_key 1234
slave {
pcm "hw:0,0"
period_time 0
period_size 1024
buffer_size 4096
rate 44100
}
}
Works well for most apps (VLC, gstreamer, xine, ...)
Anyway, Java ignores this. If I have a Java applet with sound, subsequent sound playback will fail (e.g. opening a movie with VLC after loading a page with an applet with sound). The other way around also fails (the applet will fail while playing a movie).
I am not sure exactly what's going on, but it seems Java is using the OSS emulation layer (lsof showed java_vm opened /dev/dsp). I did rmmod snd_pcm_oss and then java_vm opened /dev/snd/pcmC0D0p instead, this is the same device as e.g. VLC will open, but it still won't cooperate. This is rather annoying and I would like to fix it somehow. Anyone?
 
Old 08-09-2005, 03:26 PM   #2
Moloko
Member
 
Registered: Mar 2004
Location: Netherlands
Distribution: Debian
Posts: 729

Rep: Reputation: 30
It's a drag, but some apps don't use Alsa and will not work. Even Mozilla Thunderbird doesn't use Alsa...
 
Old 08-09-2005, 05:56 PM   #3
Vgui
Member
 
Registered: Apr 2005
Location: Canada
Distribution: Slackware
Posts: 496

Rep: Reputation: 31
I have heard that esound allows multiple sound channels at once. Not a huge issue for me so I haven't looked into it heavily...
No idea on the Java issue though, I imagine that it just says "play sound" to the audio layer, and Linux does the rest.
 
Old 08-10-2005, 06:10 PM   #4
rpz
Member
 
Registered: Mar 2005
Posts: 126

Original Poster
Rep: Reputation: 15
OK, but can anyone explain this:
Code:
$cd /usr/java/jre1.5.0_04/lib/i386
$ls libjsound*
libjsoundalsa.so  libjsound.so
$ldd libjsoundalsa.so
...
libasound.so.2 => /lib/libasound.so.2 (0x001d3000)
...
My guess is libjsound.so is OSS and libjsoundalsa.so is ALSA. Just don't know how to tell Java which to use.

Plan B: Make OSS behave correctly. How do I force legacy apps into not opening OSS exclusively?

Also, if I had hardware mixing, this would have worked right?

Last edited by rpz; 08-10-2005 at 06:12 PM.
 
Old 08-10-2005, 06:15 PM   #5
Vgui
Member
 
Registered: Apr 2005
Location: Canada
Distribution: Slackware
Posts: 496

Rep: Reputation: 31
Hmm, a bit of a crude method you might want to try would be softlinking the OSS library to the alsa one, or somehow switching them so Java thinks it is using the OSS one, when really it is using alsa. Or maybe Google can find some results about how to point Java to a different library (I imagine since they are both included it wouldn't be too too hard).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Java plugin installed correctly for Firefox but not able to view any java applet tvn Linux - Software 10 04-15-2010 02:13 AM
I am not able to play Mp3 Songs In Red Hat 9,How To Play The Songs? vlovevj_patel Linux - General 10 03-23-2008 11:45 PM
Kaffeine, won't play a DVD but will play individual VOB files? GameGuru Linux - Newbie 12 07-08-2005 12:33 AM
JAVA: how to play wav file from a console application randomx Programming 5 10-12-2004 02:34 PM
Web start java not working (java works fine) powadha Debian 5 06-05-2004 12:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration