• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.media.midi;
18 
19 /**
20  * Interface provided by a device to allow attaching
21  * MidiReceivers to a MIDI device.
22  */
23 abstract public class MidiSender {
24 
25     /**
26      * Connects a {@link MidiReceiver} to the sender
27      *
28      * @param receiver the receiver to connect
29      */
connect(MidiReceiver receiver)30     public void connect(MidiReceiver receiver) {
31         if (receiver == null) {
32             throw new NullPointerException("receiver null in MidiSender.connect");
33         }
34         onConnect(receiver);
35     }
36 
37     /**
38      * Disconnects a {@link MidiReceiver} from the sender
39      *
40      * @param receiver the receiver to disconnect
41      */
disconnect(MidiReceiver receiver)42     public void disconnect(MidiReceiver receiver) {
43         if (receiver == null) {
44             throw new NullPointerException("receiver null in MidiSender.disconnect");
45         }
46         onDisconnect(receiver);
47     }
48 
49     /**
50      * Called to connect a {@link MidiReceiver} to the sender
51      *
52      * @param receiver the receiver to connect
53      */
onConnect(MidiReceiver receiver)54     abstract public void onConnect(MidiReceiver receiver);
55 
56     /**
57      * Called to disconnect a {@link MidiReceiver} from the sender
58      *
59      * @param receiver the receiver to disconnect
60      */
onDisconnect(MidiReceiver receiver)61     abstract public void onDisconnect(MidiReceiver receiver);
62 }
63