Java Code Examples for javax.sound.sampled.AudioPermission

Following code examples demonstrate how to use javax.sound.sampled.AudioPermission from java. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use javax.sound.sampled.AudioPermission and various code implementation of this class.
Example 1
Project : java Source File : JavaSoundHub.java View Source Code on GitHub

    public JavaSoundHub() {

        System.out.println("---------------------------------------------");
        assert (the == null);
        the = this;
        assert (inited == false);

        inited = true;
        int iflag = 0;
        if (synth != null) {
            return;
        }

        try {

            double sampleRate = 44100;
            synth = JavaSoundSynth.the();

            Conductor.init();

            SecurityManager sm = System.getSecurityManager();

            boolean noRecord = false;
            if (sm != null) {
                System.out.println(
                        " Security manager exists. Asking about record");
                Object context = sm.getSecurityContext();
                AudioPermission perm = new AudioPermission("record");
                try {
                    sm.checkPermission(perm, context);
                } catch (SecurityException ex) {
                    ex.printStackTrace();
                    noRecord = true;
                }
            } else {
                System.out.println(" No Security manager.");
            }

            if (!noRecord) {
                feed = new TargetDataLineFeed(sampleRate);
                Thread t = new Thread(feed);
                t.setPriority(Thread.MAX_PRIORITY);

                peakAnalyst = new PeakAnalyst(feed);
                t.start();
            }
        } catch (Exception e) {

            e.printStackTrace();

        }


    }
			
Example 2
Project : java Source File : PulseAudioSourcePort.java View Source Code on GitHub

    public void open() {

        
        AudioPermission perm = new AudioPermission("record", null);
        perm.checkGuard(null);

        super.open();

        PulseAudioMixer parent = PulseAudioMixer.getInstance();
        parent.addSourceLine(this);
    }
			
Example 3
Project : java Source File : PulseAudioSourcePort.java View Source Code on GitHub

    public void close() {

        
        AudioPermission perm = new AudioPermission("record", null);
        perm.checkGuard(null);

        if (!isOpen) {
            throw new IllegalStateException("Port is not open; so cant close");
        }

        PulseAudioMixer parent = PulseAudioMixer.getInstance();
        parent.removeSourceLine(this);

        super.close();
    }
			
Example 4
Project : java Source File : AudioPermissionClassTests.java View Source Code on GitHub

    @Test
    public default void verifyGenericType()
    throws Exception {
        final Class<SUT> sut = createNewSUT();
        assertTrue("This j8unit test interface is used with a generic type that is illegaly not assignable to AudioPermission.class!",
                   AudioPermission.class.isAssignableFrom(sut));
    }