views:

475

answers:

5

I use a Java applet, which produces unwanted sounds to me. Mute option in the applet is missing, and it's not possible to rewrite the source code. I want to hear other(non-JVM) applications' sounds. How do I suppress this Java applet(or JVM) sound output without disabling it?

I'm using Ubuntu 9.10, jre1.6.0_18 and Mozilla FF 3.5.8.

UPDATE:

  1. Java applet is missing in "Sound preferences->Applications", because sounds are too short("beep" etc.).
  2. When other application produces sounds(.mp3, .ogg music) java applet doesn't.
A: 

probably should be in power user. You can use pulse audio to control applications sounds(assuming you haven't disabled it) it should be in sound preferences. right click on the volume applet and open preferences click on application tab.

Roman A. Taycher
Yes i can control ANOTHER applications from that thing, but there is no java applet that produces sounds.
INeedUrHelpRly
A: 

I am wondering if a custom local security policy be able to stop the applet from accessing audio? I didn't investigate it far (Googled the terms java applet local policy)

http://www.wutka.com/hackingjava/ch3.htm#CreatingaCustomizedSecurityManager

The applet would probably exit with an exception if it fails loading the audio file or running the audio code, but it might be worth a shot.

Another short page http://www.jensign.com/JavaScience/www/policyfiles/

Photodeus
A: 

It appears that Pulse stores the volume settings for individual applications in a Trivial Database (tbd) file in your home directory:(~/.pulse/(guid)-stream-volumes.tdb)

The tdbtool command from the Synaptic "tdb-tools" package can be used to inspect the records of this file, but it is not meant to be edited and appears to not be possible (except by someone with intimate knowledge of the pulse code) because all of the values are in hex format and are not easily readable or understood.

xhalarin
A: 

I never encountered a problem like yours, but I removed pulseaudio completely and have never had any compaints since. In case, you want to go down that path, here are instructions for safely replacing pulseaudio with alsa.

  1. sudo apt-get purge pulseaudio gstreamer0.10-pulseaudio
  2. sudo apt-get autoremove
  3. sudo apt-get install alsa-base alsa-tools alsa-tools-gui alsa-utils alsa-oss linux-sound-base alsamixergui
  4. sudo apt-get install esound esound-clients esound-common libesd-alsa0 gnome-alsamixer
  5. Restart your computer!
  6. gstreamer-properties ----set ALSA to default

Now, you can always use alsamixergui to manage sound for all apps.

Hope that solves your problem.

Suvir
+1  A: 

If you are in control of the deployment of the applet (I.e. the webpage hosting the applet), you could write your own Applet Launcher. The launcher functions as a wrapper that provides a custom environment to the actual applet. The launcher instantiates the real applet and passes to it customized versions of the applet environment (AppletStub, AppletContext.) The custom environment implements AudioClip as a "do nothing" interface.

To disable audio, you could override the AppletContext like this:

class CustomAppletContext implements AppletContext
{
    AppletContext realContext;

    // most methods delegate to the real context, either directly, or with a little modification to hide the fact that we are using this launcher
   public void setStatus(String status)
   {
       realContext.setStatus(status);
   }

   // override the getAudioClip to return a dummy clip
   public AudioClip getAudioClip(URl url)
   {
       return new DummyAudioClip();
   }
}

// An AudioClip implementation that does nothing
class DummyAudioClip implements AudioClip
{
    public void loop() { }
    public void play() { }
    public void stop() { }
}

We also override AppletStub, since this is where the Applet gets the AppletContext from

class CustomAppletStub implements AppletStub
{
    AppletStub realStub;

    public AppletContext getAppletContext()
    {
        return new CustomAppletContext(realStub.getAppletContext());
    }
}

And then, your launcher:

class AppletLauncher extends Applet
{
    private Applet   realApplet = new NoisyApplet();

    // delegate most methods to the applet, but override the stub, to inject our
    // AppletContext and AudioClip implementation

    public void setAppletStub(AppletStub stub)
    {
        realApplet.setAppletStub(new CustomAppletStub(stub));
    }
}

It looks like a lot of code, but it's really just a few classes and mostly wiring just to inject a new DummyAudioClip implementation.

HTH!

mdma