JDK 1.7.0 - Java sound api - Speed up the caching period

94 views Asked by At

I am working on a project in which I need to get list of recording devices but If I connect new device,shows old list, Sound API takes near about 50 sec to load newly connected device list. I tried to use com.sun.media.sound.JDK13Services.setCachingPeriod() method but looks like it has been removed from jdk 1.7_0.

Is there any way to speed up the caching period?

Here is my code, Currently I have removed com.sun.media.sound.JDK13Services.setCachingPeriod() methods from code because it gives deprecation error at compile time.

private LinkedList<Mixer.Info> getTargetMixers()
    {
        Line.Info targetDLInfo = new Line.Info(TargetDataLine.class);
        Line line = null;

        LinkedList<Mixer.Info> targetMixers = new LinkedList<Mixer.Info>();

        // Get all the mixers
        Mixer.Info[] mixerInfoArray = AudioSystem.getMixerInfo();
        for(int i=0; i<mixerInfoArray.length; i++)
        {
            Mixer.Info mixerInfo = mixerInfoArray[i];
            try
            {
                Mixer mixer = AudioSystem.getMixer(mixerInfo);
                if(mixer.isLineSupported(targetDLInfo))
                    targetMixers.add(mixerInfoArray[i]);
            }
            catch(Exception ex)
            {
                logger_.error("Error getting mixer: " + mixerInfo.getName(), ex);
            }
        }
        return targetMixers;
    }
0

There are 0 answers