OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef MEDIA_MIDI_MIDI_MANAGER_MAC_H_ |
| 6 #define MEDIA_MIDI_MIDI_MANAGER_MAC_H_ |
| 7 |
| 8 #include <CoreMIDI/MIDIServices.h> |
| 9 #include <map> |
| 10 #include <string> |
| 11 |
| 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" |
| 16 |
| 17 namespace media { |
| 18 |
| 19 class MEDIA_EXPORT MIDIManagerMac : public MIDIManager { |
| 20 public: |
| 21 MIDIManagerMac(); |
| 22 virtual ~MIDIManagerMac(); |
| 23 |
| 24 // MIDIManager implementation. |
| 25 virtual bool Initialize() OVERRIDE; |
| 26 virtual void SendMIDIData(int port_index, |
| 27 const uint8* data, |
| 28 size_t length, |
| 29 double timestamp) OVERRIDE; |
| 30 |
| 31 private: |
| 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); |
| 40 |
| 41 // Helper |
| 42 static media::MIDIPortInfo GetPortInfoFromEndpoint(MIDIEndpointRef endpoint); |
| 43 static double MIDITimeStampToSeconds(MIDITimeStamp timestamp); |
| 44 static MIDITimeStamp SecondsToMIDITimeStamp(double seconds); |
| 45 |
| 46 // CoreMIDI |
| 47 MIDIClientRef midi_client_; |
| 48 MIDIPortRef coremidi_input_; |
| 49 MIDIPortRef coremidi_output_; |
| 50 |
| 51 enum{ kMaxPacketListSize = 512 }; |
| 52 char midi_buffer_[kMaxPacketListSize]; |
| 53 MIDIPacketList* packet_list_; |
| 54 MIDIPacket* midi_packet_; |
| 55 |
| 56 typedef std::map<MIDIEndpointRef, int> SourceMap; |
| 57 |
| 58 // Keeps track of the index (0-based) for each of our sources. |
| 59 SourceMap source_map_; |
| 60 |
| 61 // Keeps track of all destinations. |
| 62 std::vector<MIDIEndpointRef> destinations_; |
| 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(MIDIManagerMac); |
| 65 }; |
| 66 |
| 67 } // namespace media |
| 68 |
| 69 #endif // MEDIA_MIDI_MIDI_MANAGER_MAC_H_ |
OLD | NEW |