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> |
(...skipping 28 matching lines...) Expand all Loading... |
39 void *read_proc_refcon, | 39 void *read_proc_refcon, |
40 void *src_conn_refcon); | 40 void *src_conn_refcon); |
41 virtual void ReadMidi(MIDIEndpointRef source, const MIDIPacketList *pktlist); | 41 virtual void ReadMidi(MIDIEndpointRef source, const MIDIPacketList *pktlist); |
42 | 42 |
43 // An internal callback that runs on MidiSendThread. | 43 // An internal callback that runs on MidiSendThread. |
44 void SendMidiData(MidiManagerClient* client, | 44 void SendMidiData(MidiManagerClient* client, |
45 uint32 port_index, | 45 uint32 port_index, |
46 const std::vector<uint8>& data, | 46 const std::vector<uint8>& data, |
47 double timestamp); | 47 double timestamp); |
48 | 48 |
49 // Helper | |
50 static media::MidiPortInfo GetPortInfoFromEndpoint(MIDIEndpointRef endpoint); | |
51 static double MIDITimeStampToSeconds(MIDITimeStamp timestamp); | |
52 static MIDITimeStamp SecondsToMIDITimeStamp(double seconds); | |
53 | |
54 // CoreMIDI | 49 // CoreMIDI |
55 MIDIClientRef midi_client_; | 50 MIDIClientRef midi_client_; |
56 MIDIPortRef coremidi_input_; | 51 MIDIPortRef coremidi_input_; |
57 MIDIPortRef coremidi_output_; | 52 MIDIPortRef coremidi_output_; |
58 | 53 |
59 enum{ kMaxPacketListSize = 512 }; | 54 enum{ kMaxPacketListSize = 512 }; |
60 char midi_buffer_[kMaxPacketListSize]; | 55 char midi_buffer_[kMaxPacketListSize]; |
61 MIDIPacketList* packet_list_; | 56 MIDIPacketList* packet_list_; |
62 MIDIPacket* midi_packet_; | 57 MIDIPacket* midi_packet_; |
63 | 58 |
64 typedef std::map<MIDIEndpointRef, uint32> SourceMap; | 59 typedef std::map<MIDIEndpointRef, uint32> SourceMap; |
65 | 60 |
66 // Keeps track of the index (0-based) for each of our sources. | 61 // Keeps track of the index (0-based) for each of our sources. |
67 SourceMap source_map_; | 62 SourceMap source_map_; |
68 | 63 |
69 // Keeps track of all destinations. | 64 // Keeps track of all destinations. |
70 std::vector<MIDIEndpointRef> destinations_; | 65 std::vector<MIDIEndpointRef> destinations_; |
71 | 66 |
72 // |send_thread_| is used to send MIDI data. | 67 // |send_thread_| is used to send MIDI data. |
73 base::Thread send_thread_; | 68 base::Thread send_thread_; |
74 | 69 |
75 DISALLOW_COPY_AND_ASSIGN(MidiManagerMac); | 70 DISALLOW_COPY_AND_ASSIGN(MidiManagerMac); |
76 }; | 71 }; |
77 | 72 |
78 } // namespace media | 73 } // namespace media |
79 | 74 |
80 #endif // MEDIA_MIDI_MIDI_MANAGER_MAC_H_ | 75 #endif // MEDIA_MIDI_MIDI_MANAGER_MAC_H_ |
OLD | NEW |