2719N/A/*
6321N/A * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
2719N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2719N/A *
2719N/A * This code is free software; you can redistribute it and/or modify it
2719N/A * under the terms of the GNU General Public License version 2 only, as
2719N/A * published by the Free Software Foundation. Oracle designates this
2719N/A * particular file as subject to the "Classpath" exception as provided
2719N/A * by Oracle in the LICENSE file that accompanied this code.
2719N/A *
2719N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2719N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2719N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2719N/A * version 2 for more details (a copy is included in the LICENSE file that
2719N/A * accompanied this code).
2719N/A *
2719N/A * You should have received a copy of the GNU General Public License version
2719N/A * 2 along with this work; if not, write to the Free Software Foundation,
2719N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2719N/A *
2719N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2719N/A * or visit www.oracle.com if you need additional information or have any
2719N/A * questions.
2719N/A */
2719N/Apackage com.sun.media.sound;
2719N/A
2719N/Aimport javax.sound.midi.*;
2719N/A
2719N/A
2719N/A/**
2719N/A * Helper class which allows to convert {@code Receiver}
2719N/A * to {@code MidiDeviceReceiver}.
2719N/A *
2719N/A * @author Alex Menkov
2719N/A */
6321N/Apublic final class MidiDeviceReceiverEnvelope implements MidiDeviceReceiver {
2719N/A
2719N/A private final MidiDevice device;
2719N/A private final Receiver receiver;
2719N/A
2719N/A /**
2719N/A * Creates a new {@code MidiDeviceReceiverEnvelope} object which
2719N/A * envelops the specified {@code Receiver}
2719N/A * and is owned by the specified {@code MidiDevice}.
2719N/A *
2719N/A * @param device the owner {@code MidiDevice}
2719N/A * @param receiver the {@code Receiver} to be enveloped
2719N/A */
2719N/A public MidiDeviceReceiverEnvelope(MidiDevice device, Receiver receiver) {
2719N/A if (device == null || receiver == null) {
2719N/A throw new NullPointerException();
2719N/A }
2719N/A this.device = device;
2719N/A this.receiver = receiver;
2719N/A }
2719N/A
2719N/A // Receiver implementation
2719N/A public void close() {
2719N/A receiver.close();
2719N/A }
2719N/A
2719N/A public void send(MidiMessage message, long timeStamp) {
2719N/A receiver.send(message, timeStamp);
2719N/A }
2719N/A
2719N/A // MidiDeviceReceiver implementation
2719N/A public MidiDevice getMidiDevice() {
2719N/A return device;
2719N/A }
2719N/A
2719N/A /**
2719N/A * Obtains the receiver enveloped
2719N/A * by this {@code MidiDeviceReceiverEnvelope} object.
2719N/A *
2719N/A * @return the enveloped receiver
2719N/A */
2719N/A public Receiver getReceiver() {
2719N/A return receiver;
2719N/A }
2719N/A}