cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / media / midi / midi_manager_mac.h
blob2397b8034f75585f06df97b994bf1983483b8b5e
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>
9 #include <map>
10 #include <string>
11 #include <vector>
13 #include "base/basictypes.h"
14 #include "base/compiler_specific.h"
15 #include "media/midi/midi_manager.h"
16 #include "media/midi/midi_port_info.h"
18 namespace media {
20 class MEDIA_EXPORT MIDIManagerMac : public MIDIManager {
21 public:
22 MIDIManagerMac();
23 virtual ~MIDIManagerMac();
25 // MIDIManager implementation.
26 virtual bool Initialize() OVERRIDE;
27 virtual void SendMIDIData(MIDIManagerClient* client,
28 uint32 port_index,
29 const std::vector<uint8>& data,
30 double timestamp) OVERRIDE;
32 private:
33 // CoreMIDI callback for MIDI data.
34 // Each callback can contain multiple packets, each of which can contain
35 // multiple MIDI messages.
36 static void ReadMIDIDispatch(
37 const MIDIPacketList *pktlist,
38 void *read_proc_refcon,
39 void *src_conn_refcon);
40 virtual void ReadMIDI(MIDIEndpointRef source, const MIDIPacketList *pktlist);
42 // Helper
43 static media::MIDIPortInfo GetPortInfoFromEndpoint(MIDIEndpointRef endpoint);
44 static double MIDITimeStampToSeconds(MIDITimeStamp timestamp);
45 static MIDITimeStamp SecondsToMIDITimeStamp(double seconds);
47 // CoreMIDI
48 MIDIClientRef midi_client_;
49 MIDIPortRef coremidi_input_;
50 MIDIPortRef coremidi_output_;
52 enum{ kMaxPacketListSize = 512 };
53 char midi_buffer_[kMaxPacketListSize];
54 MIDIPacketList* packet_list_;
55 MIDIPacket* midi_packet_;
57 typedef std::map<MIDIEndpointRef, uint32> SourceMap;
59 // Keeps track of the index (0-based) for each of our sources.
60 SourceMap source_map_;
62 // Keeps track of all destinations.
63 std::vector<MIDIEndpointRef> destinations_;
65 DISALLOW_COPY_AND_ASSIGN(MIDIManagerMac);
68 } // namespace media
70 #endif // MEDIA_MIDI_MIDI_MANAGER_MAC_H_