| 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 #include "media/midi/midi_manager_mac.h" | 5 #include "media/midi/midi_manager_mac.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 reinterpret_cast<const MIDIObjectAddRemoveNotification*>(message); | 216 reinterpret_cast<const MIDIObjectAddRemoveNotification*>(message); |
| 217 MIDIEndpointRef endpoint = | 217 MIDIEndpointRef endpoint = |
| 218 static_cast<MIDIEndpointRef>(notification->child); | 218 static_cast<MIDIEndpointRef>(notification->child); |
| 219 if (notification->childType == kMIDIObjectType_Source) { | 219 if (notification->childType == kMIDIObjectType_Source) { |
| 220 SourceMap::iterator it = source_map_.find(endpoint); | 220 SourceMap::iterator it = source_map_.find(endpoint); |
| 221 if (it == source_map_.end()) { | 221 if (it == source_map_.end()) { |
| 222 uint32 index = source_map_.size(); | 222 uint32 index = source_map_.size(); |
| 223 source_map_[endpoint] = index; | 223 source_map_[endpoint] = index; |
| 224 MidiPortInfo info = GetPortInfoFromEndpoint(endpoint); | 224 MidiPortInfo info = GetPortInfoFromEndpoint(endpoint); |
| 225 AddInputPort(info); | 225 AddInputPort(info); |
| 226 MIDIPortConnectSource( |
| 227 coremidi_input_, endpoint, reinterpret_cast<void*>(endpoint)); |
| 226 } else { | 228 } else { |
| 227 uint32 index = it->second; | 229 uint32 index = it->second; |
| 228 SetInputPortState(index, MIDI_PORT_OPENED); | 230 SetInputPortState(index, MIDI_PORT_OPENED); |
| 229 } | 231 } |
| 230 } else if (notification->childType == kMIDIObjectType_Destination) { | 232 } else if (notification->childType == kMIDIObjectType_Destination) { |
| 231 auto i = std::find(destinations_.begin(), destinations_.end(), endpoint); | 233 auto i = std::find(destinations_.begin(), destinations_.end(), endpoint); |
| 232 if (i != destinations_.end()) { | 234 if (i != destinations_.end()) { |
| 233 SetOutputPortState(i - destinations_.begin(), MIDI_PORT_OPENED); | 235 SetOutputPortState(i - destinations_.begin(), MIDI_PORT_OPENED); |
| 234 } else { | 236 } else { |
| 235 destinations_.push_back(endpoint); | 237 destinations_.push_back(endpoint); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 | 327 |
| 326 MIDISend(coremidi_output_, destination, packet_list_); | 328 MIDISend(coremidi_output_, destination, packet_list_); |
| 327 | 329 |
| 328 // Re-initialize for next time. | 330 // Re-initialize for next time. |
| 329 midi_packet_ = MIDIPacketListInit(packet_list_); | 331 midi_packet_ = MIDIPacketListInit(packet_list_); |
| 330 | 332 |
| 331 client->AccumulateMidiBytesSent(data.size()); | 333 client->AccumulateMidiBytesSent(data.size()); |
| 332 } | 334 } |
| 333 | 335 |
| 334 } // namespace media | 336 } // namespace media |
| OLD | NEW |