Search in sources :

Example 1 with Renderer

use of javax.media.Renderer in project Spark by igniterealtime.

the class JMFInit method detectDirectAudio.

private void detectDirectAudio() {
    Class<?> cls;
    int plType = PlugInManager.RENDERER;
    String dar = "com.sun.media.renderer.audio.DirectAudioRenderer";
    try {
        // Check if this is the Windows Performance Pack - hack
        Class.forName("VFWAuto");
        // Check if DS capture is supported, otherwise fail DS renderer
        // since NT doesn't have capture
        Class.forName("com.sun.media.protocol.dsound.DSound");
        // Find the renderer class and instantiate it.
        cls = Class.forName(dar);
        Renderer rend = (Renderer) cls.newInstance();
        try {
            // Set the format and open the device
            AudioFormat af = new AudioFormat(AudioFormat.LINEAR, 44100, 16, 2);
            rend.setInputFormat(af);
            rend.open();
            Format[] inputFormats = rend.getSupportedInputFormats();
            // Register the device
            PlugInManager.addPlugIn(dar, inputFormats, new Format[0], plType);
            // Move it to the top of the list
            Vector<String> rendList = PlugInManager.getPlugInList(null, null, plType);
            int listSize = rendList.size();
            if (rendList.elementAt(listSize - 1).equals(dar)) {
                rendList.removeElementAt(listSize - 1);
                rendList.insertElementAt(dar, 0);
                PlugInManager.setPlugInList(rendList, plType);
                PlugInManager.commit();
            // Log.debug("registered");
            }
            rend.close();
        } catch (Throwable t) {
        // Log.debug("Error " + t);
        }
    } catch (Throwable tt) {
    // Nothing to do
    }
}
Also used : Format(javax.media.Format) AudioFormat(javax.media.format.AudioFormat) Renderer(javax.media.Renderer) AudioFormat(javax.media.format.AudioFormat)

Example 2 with Renderer

use of javax.media.Renderer in project Smack by igniterealtime.

the class JMFInit method detectS8DirectAudio.

private static void detectS8DirectAudio() {
    Class<?> cls;
    int plType = PlugInManager.RENDERER;
    String dar = "com.sun.media.renderer.audio.DirectAudioRenderer";
    try {
        // Check if this is the solaris Performance Pack - hack
        cls = Class.forName("SunVideoAuto");
        // Find the renderer class and instantiate it.
        cls = Class.forName(dar);
        Renderer rend = (Renderer) cls.getConstructor().newInstance();
        if (rend instanceof ExclusiveUse && !((ExclusiveUse) rend).isExclusive()) {
            // sol8+, DAR supports mixing
            @SuppressWarnings("unchecked") Vector<String> rendList = PlugInManager.getPlugInList(null, null, plType);
            int listSize = rendList.size();
            boolean found = false;
            String rname;
            for (int i = 0; i < listSize; i++) {
                rname = rendList.elementAt(i);
                if (rname.equals(dar)) {
                    // DAR is in the registry
                    found = true;
                    rendList.removeElementAt(i);
                    break;
                }
            }
            if (found) {
                rendList.insertElementAt(dar, 0);
                PlugInManager.setPlugInList(rendList, plType);
                PlugInManager.commit();
            }
        }
    } catch (Throwable tt) {
    // Do nothing.
    }
}
Also used : ExclusiveUse(com.sun.media.ExclusiveUse) Renderer(javax.media.Renderer)

Example 3 with Renderer

use of javax.media.Renderer in project Smack by igniterealtime.

the class JMFInit method detectDirectAudio.

private static void detectDirectAudio() {
    Class<?> cls;
    int plType = PlugInManager.RENDERER;
    String dar = "com.sun.media.renderer.audio.DirectAudioRenderer";
    try {
        // Check if this is the Windows Performance Pack - hack
        cls = Class.forName("VFWAuto");
        // Check if DS capture is supported, otherwise fail DS renderer
        // since NT doesn't have capture
        cls = Class.forName("com.sun.media.protocol.dsound.DSound");
        // Find the renderer class and instantiate it.
        cls = Class.forName(dar);
        Renderer rend = (Renderer) cls.getConstructor().newInstance();
        try {
            // Set the format and open the device
            AudioFormat af = new AudioFormat(AudioFormat.LINEAR, 44100, 16, 2);
            rend.setInputFormat(af);
            rend.open();
            Format[] inputFormats = rend.getSupportedInputFormats();
            // Register the device
            PlugInManager.addPlugIn(dar, inputFormats, new Format[0], plType);
            // Move it to the top of the list
            @SuppressWarnings("unchecked") Vector<String> rendList = PlugInManager.getPlugInList(null, null, plType);
            int listSize = rendList.size();
            if (rendList.elementAt(listSize - 1).equals(dar)) {
                rendList.removeElementAt(listSize - 1);
                rendList.insertElementAt(dar, 0);
                PlugInManager.setPlugInList(rendList, plType);
                PlugInManager.commit();
            // Log.debug("registered");
            }
            rend.close();
        } catch (Throwable t) {
        // Log.debug("Error " + t);
        }
    } catch (Throwable tt) {
    // Do nothing.
    }
}
Also used : Format(javax.media.Format) AudioFormat(javax.media.format.AudioFormat) Renderer(javax.media.Renderer) AudioFormat(javax.media.format.AudioFormat)

Example 4 with Renderer

use of javax.media.Renderer in project Spark by igniterealtime.

the class JMFInit method detectS8DirectAudio.

private void detectS8DirectAudio() {
    Class<?> cls;
    int plType = PlugInManager.RENDERER;
    String dar = "com.sun.media.renderer.audio.DirectAudioRenderer";
    try {
        // Check if this is the solaris Performance Pack - hack
        Class.forName("SunVideoAuto");
        // Find the renderer class and instantiate it.
        cls = Class.forName(dar);
        Renderer rend = (Renderer) cls.newInstance();
        if (rend instanceof ExclusiveUse && !((ExclusiveUse) rend).isExclusive()) {
            // sol8+, DAR supports mixing
            Vector<String> rendList = PlugInManager.getPlugInList(null, null, plType);
            int listSize = rendList.size();
            boolean found = false;
            String rname;
            for (int i = 0; i < listSize; i++) {
                rname = rendList.elementAt(i);
                if (rname.equals(dar)) {
                    // DAR is in the registry
                    found = true;
                    rendList.removeElementAt(i);
                    break;
                }
            }
            if (found) {
                rendList.insertElementAt(dar, 0);
                PlugInManager.setPlugInList(rendList, plType);
                PlugInManager.commit();
            }
        }
    } catch (Throwable tt) {
    // Nothing to do
    }
}
Also used : ExclusiveUse(com.sun.media.ExclusiveUse) Renderer(javax.media.Renderer)

Aggregations

Renderer (javax.media.Renderer)4 ExclusiveUse (com.sun.media.ExclusiveUse)2 Format (javax.media.Format)2 AudioFormat (javax.media.format.AudioFormat)2