1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_MIDI_MIDI_MANAGER_MAC_H_
6 #define MEDIA_MIDI_MIDI_MANAGER_MAC_H_
8 #include <CoreMIDI/MIDIServices.h>
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "media/midi/midi_manager.h"
15 #include "media/midi/midi_port_info.h"
19 class MEDIA_EXPORT MIDIManagerMac
: public MIDIManager
{
22 virtual ~MIDIManagerMac();
24 // MIDIManager implementation.
25 virtual bool Initialize() OVERRIDE
;
26 virtual void SendMIDIData(int port_index
,
29 double timestamp
) OVERRIDE
;
32 // CoreMIDI callback for MIDI data.
33 // Each callback can contain multiple packets, each of which can contain
34 // multiple MIDI messages.
35 static void ReadMidiDispatch(
36 const MIDIPacketList
*pktlist
,
37 void *read_proc_refcon
,
38 void *src_conn_refcon
);
39 virtual void ReadMidi(MIDIEndpointRef source
, const MIDIPacketList
*pktlist
);
42 static media::MIDIPortInfo
GetPortInfoFromEndpoint(MIDIEndpointRef endpoint
);
43 static double MIDITimeStampToSeconds(MIDITimeStamp timestamp
);
44 static MIDITimeStamp
SecondsToMIDITimeStamp(double seconds
);
47 MIDIClientRef midi_client_
;
48 MIDIPortRef coremidi_input_
;
49 MIDIPortRef coremidi_output_
;
51 enum{ kMaxPacketListSize
= 512 };
52 char midi_buffer_
[kMaxPacketListSize
];
53 MIDIPacketList
* packet_list_
;
54 MIDIPacket
* midi_packet_
;
56 typedef std::map
<MIDIEndpointRef
, int> SourceMap
;
58 // Keeps track of the index (0-based) for each of our sources.
59 SourceMap source_map_
;
61 // Keeps track of all destinations.
62 std::vector
<MIDIEndpointRef
> destinations_
;
64 DISALLOW_COPY_AND_ASSIGN(MIDIManagerMac
);
69 #endif // MEDIA_MIDI_MIDI_MANAGER_MAC_H_