OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_MIDI_MIDI_MANAGER_MAC_H_ | 5 #ifndef MEDIA_MIDI_MIDI_MANAGER_MAC_H_ |
6 #define MEDIA_MIDI_MIDI_MANAGER_MAC_H_ | 6 #define MEDIA_MIDI_MIDI_MANAGER_MAC_H_ |
7 | 7 |
8 #include <CoreMIDI/MIDIServices.h> | 8 #include <CoreMIDI/MIDIServices.h> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
| 11 #include <vector> |
11 | 12 |
12 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
14 #include "media/midi/midi_manager.h" | 15 #include "media/midi/midi_manager.h" |
15 #include "media/midi/midi_port_info.h" | 16 #include "media/midi/midi_port_info.h" |
16 | 17 |
17 namespace media { | 18 namespace media { |
18 | 19 |
19 class MEDIA_EXPORT MIDIManagerMac : public MIDIManager { | 20 class MEDIA_EXPORT MIDIManagerMac : public MIDIManager { |
20 public: | 21 public: |
21 MIDIManagerMac(); | 22 MIDIManagerMac(); |
22 virtual ~MIDIManagerMac(); | 23 virtual ~MIDIManagerMac(); |
23 | 24 |
24 // MIDIManager implementation. | 25 // MIDIManager implementation. |
25 virtual bool Initialize() OVERRIDE; | 26 virtual bool Initialize() OVERRIDE; |
26 virtual void SendMIDIData(MIDIManagerClient* client, | 27 virtual void SendMIDIData(MIDIManagerClient* client, |
27 int port_index, | 28 uint32 port_index, |
28 const uint8* data, | 29 const std::vector<uint8>& data, |
29 size_t length, | |
30 double timestamp) OVERRIDE; | 30 double timestamp) OVERRIDE; |
31 | 31 |
32 private: | 32 private: |
33 // CoreMIDI callback for MIDI data. | 33 // CoreMIDI callback for MIDI data. |
34 // Each callback can contain multiple packets, each of which can contain | 34 // Each callback can contain multiple packets, each of which can contain |
35 // multiple MIDI messages. | 35 // multiple MIDI messages. |
36 static void ReadMidiDispatch( | 36 static void ReadMIDIDispatch( |
37 const MIDIPacketList *pktlist, | 37 const MIDIPacketList *pktlist, |
38 void *read_proc_refcon, | 38 void *read_proc_refcon, |
39 void *src_conn_refcon); | 39 void *src_conn_refcon); |
40 virtual void ReadMidi(MIDIEndpointRef source, const MIDIPacketList *pktlist); | 40 virtual void ReadMIDI(MIDIEndpointRef source, const MIDIPacketList *pktlist); |
41 | 41 |
42 // Helper | 42 // Helper |
43 static media::MIDIPortInfo GetPortInfoFromEndpoint(MIDIEndpointRef endpoint); | 43 static media::MIDIPortInfo GetPortInfoFromEndpoint(MIDIEndpointRef endpoint); |
44 static double MIDITimeStampToSeconds(MIDITimeStamp timestamp); | 44 static double MIDITimeStampToSeconds(MIDITimeStamp timestamp); |
45 static MIDITimeStamp SecondsToMIDITimeStamp(double seconds); | 45 static MIDITimeStamp SecondsToMIDITimeStamp(double seconds); |
46 | 46 |
47 // CoreMIDI | 47 // CoreMIDI |
48 MIDIClientRef midi_client_; | 48 MIDIClientRef midi_client_; |
49 MIDIPortRef coremidi_input_; | 49 MIDIPortRef coremidi_input_; |
50 MIDIPortRef coremidi_output_; | 50 MIDIPortRef coremidi_output_; |
51 | 51 |
52 enum{ kMaxPacketListSize = 512 }; | 52 enum{ kMaxPacketListSize = 512 }; |
53 char midi_buffer_[kMaxPacketListSize]; | 53 char midi_buffer_[kMaxPacketListSize]; |
54 MIDIPacketList* packet_list_; | 54 MIDIPacketList* packet_list_; |
55 MIDIPacket* midi_packet_; | 55 MIDIPacket* midi_packet_; |
56 | 56 |
57 typedef std::map<MIDIEndpointRef, int> SourceMap; | 57 typedef std::map<MIDIEndpointRef, uint32> SourceMap; |
58 | 58 |
59 // Keeps track of the index (0-based) for each of our sources. | 59 // Keeps track of the index (0-based) for each of our sources. |
60 SourceMap source_map_; | 60 SourceMap source_map_; |
61 | 61 |
62 // Keeps track of all destinations. | 62 // Keeps track of all destinations. |
63 std::vector<MIDIEndpointRef> destinations_; | 63 std::vector<MIDIEndpointRef> destinations_; |
64 | 64 |
65 DISALLOW_COPY_AND_ASSIGN(MIDIManagerMac); | 65 DISALLOW_COPY_AND_ASSIGN(MIDIManagerMac); |
66 }; | 66 }; |
67 | 67 |
68 } // namespace media | 68 } // namespace media |
69 | 69 |
70 #endif // MEDIA_MIDI_MIDI_MANAGER_MAC_H_ | 70 #endif // MEDIA_MIDI_MIDI_MANAGER_MAC_H_ |
OLD | NEW |