Search in sources :

Example 1 with LineEvent

use of javax.sound.sampled.LineEvent in project jdk8u_jdk by JetBrains.

the class EventDispatcher method processEvent.

/**
     * Invoked when there is at least one event in the queue.
     * Implement this as a callback to process one event.
     */
void processEvent(EventInfo eventInfo) {
    int count = eventInfo.getListenerCount();
    // process an LineEvent
    if (eventInfo.getEvent() instanceof LineEvent) {
        LineEvent event = (LineEvent) eventInfo.getEvent();
        if (Printer.debug)
            Printer.debug("Sending " + event + " to " + count + " listeners");
        for (int i = 0; i < count; i++) {
            try {
                ((LineListener) eventInfo.getListener(i)).update(event);
            } catch (Throwable t) {
                if (Printer.err)
                    t.printStackTrace();
            }
        }
        return;
    }
    // process a MetaMessage
    if (eventInfo.getEvent() instanceof MetaMessage) {
        MetaMessage event = (MetaMessage) eventInfo.getEvent();
        for (int i = 0; i < count; i++) {
            try {
                ((MetaEventListener) eventInfo.getListener(i)).meta(event);
            } catch (Throwable t) {
                if (Printer.err)
                    t.printStackTrace();
            }
        }
        return;
    }
    // process a Controller or Mode Event
    if (eventInfo.getEvent() instanceof ShortMessage) {
        ShortMessage event = (ShortMessage) eventInfo.getEvent();
        int status = event.getStatus();
        // c is the channel they are sent on.
        if ((status & 0xF0) == 0xB0) {
            for (int i = 0; i < count; i++) {
                try {
                    ((ControllerEventListener) eventInfo.getListener(i)).controlChange(event);
                } catch (Throwable t) {
                    if (Printer.err)
                        t.printStackTrace();
                }
            }
        }
        return;
    }
    Printer.err("Unknown event type: " + eventInfo.getEvent());
}
Also used : LineEvent(javax.sound.sampled.LineEvent) ControllerEventListener(javax.sound.midi.ControllerEventListener) ShortMessage(javax.sound.midi.ShortMessage) MetaEventListener(javax.sound.midi.MetaEventListener) LineListener(javax.sound.sampled.LineListener) MetaMessage(javax.sound.midi.MetaMessage)

Example 2 with LineEvent

use of javax.sound.sampled.LineEvent in project jdk8u_jdk by JetBrains.

the class AbstractLine method setOpen.

// HELPER METHODS
/**
     * This method sets the open state and generates
     * events if it changes.
     */
final void setOpen(boolean open) {
    if (Printer.trace)
        Printer.trace("> " + getClass().getName() + " (AbstractLine): setOpen(" + open + ")  this.open: " + this.open);
    boolean sendEvents = false;
    long position = getLongFramePosition();
    synchronized (this) {
        if (this.open != open) {
            this.open = open;
            sendEvents = true;
        }
    }
    if (sendEvents) {
        if (open) {
            sendEvents(new LineEvent(this, LineEvent.Type.OPEN, position));
        } else {
            sendEvents(new LineEvent(this, LineEvent.Type.CLOSE, position));
        }
    }
    if (Printer.trace)
        Printer.trace("< " + getClass().getName() + " (AbstractLine): setOpen(" + open + ")  this.open: " + this.open);
}
Also used : LineEvent(javax.sound.sampled.LineEvent)

Example 3 with LineEvent

use of javax.sound.sampled.LineEvent in project jdk8u_jdk by JetBrains.

the class SoftMixingClip method loop.

public void loop(int count) {
    LineEvent event = null;
    synchronized (control_mutex) {
        if (isOpen()) {
            if (active)
                return;
            active = true;
            active_sg = true;
            loopcount = count;
            event = new LineEvent(this, LineEvent.Type.START, getLongFramePosition());
        }
    }
    if (event != null)
        sendEvent(event);
}
Also used : LineEvent(javax.sound.sampled.LineEvent)

Example 4 with LineEvent

use of javax.sound.sampled.LineEvent in project jdk8u_jdk by JetBrains.

the class SoftMixingClip method close.

public void close() {
    LineEvent event = null;
    synchronized (control_mutex) {
        if (!isOpen())
            return;
        stop();
        event = new LineEvent(this, LineEvent.Type.CLOSE, getLongFramePosition());
        open = false;
        mixer.getMainMixer().closeLine(this);
    }
    if (event != null)
        sendEvent(event);
}
Also used : LineEvent(javax.sound.sampled.LineEvent)

Example 5 with LineEvent

use of javax.sound.sampled.LineEvent in project jdk8u_jdk by JetBrains.

the class SoftMixingClip method start.

public void start() {
    LineEvent event = null;
    synchronized (control_mutex) {
        if (isOpen()) {
            if (active)
                return;
            active = true;
            active_sg = true;
            loopcount = 0;
            event = new LineEvent(this, LineEvent.Type.START, getLongFramePosition());
        }
    }
    if (event != null)
        sendEvent(event);
}
Also used : LineEvent(javax.sound.sampled.LineEvent)

Aggregations

LineEvent (javax.sound.sampled.LineEvent)13 AudioInputStream (javax.sound.sampled.AudioInputStream)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ControllerEventListener (javax.sound.midi.ControllerEventListener)1 MetaEventListener (javax.sound.midi.MetaEventListener)1 MetaMessage (javax.sound.midi.MetaMessage)1 ShortMessage (javax.sound.midi.ShortMessage)1 LineListener (javax.sound.sampled.LineListener)1 LineUnavailableException (javax.sound.sampled.LineUnavailableException)1