| Index: media/midi/midi_manager_mac.cc
|
| diff --git a/media/midi/midi_manager_mac.cc b/media/midi/midi_manager_mac.cc
|
| index 7bc8f2332e02f02fbd32342564fcf0eb933397b5..4477944e7738e79734c668ed913825bf073da96d 100644
|
| --- a/media/midi/midi_manager_mac.cc
|
| +++ b/media/midi/midi_manager_mac.cc
|
| @@ -54,7 +54,7 @@ bool MIDIManagerMac::Initialize() {
|
| result = MIDIInputPortCreate(
|
| midi_client_,
|
| CFSTR("MIDI Input"),
|
| - ReadMidiDispatch,
|
| + ReadMIDIDispatch,
|
| this,
|
| &coremidi_input_);
|
| if (result != noErr)
|
| @@ -67,10 +67,10 @@ bool MIDIManagerMac::Initialize() {
|
| if (result != noErr)
|
| return false;
|
|
|
| - int destination_count = MIDIGetNumberOfDestinations();
|
| + uint32 destination_count = MIDIGetNumberOfDestinations();
|
| destinations_.resize(destination_count);
|
|
|
| - for (int i = 0; i < destination_count ; i++) {
|
| + for (uint32 i = 0; i < destination_count ; i++) {
|
| MIDIEndpointRef destination = MIDIGetDestination(i);
|
|
|
| // Keep track of all destinations (known as outputs by the Web MIDI API).
|
| @@ -82,9 +82,9 @@ bool MIDIManagerMac::Initialize() {
|
| }
|
|
|
| // Open connections from all sources.
|
| - int source_count = MIDIGetNumberOfSources();
|
| + uint32 source_count = MIDIGetNumberOfSources();
|
|
|
| - for (int i = 0; i < source_count; ++i) {
|
| + for (uint32 i = 0; i < source_count; ++i) {
|
| // Receive from all sources.
|
| MIDIEndpointRef src = MIDIGetSource(i);
|
| MIDIPortConnectSource(coremidi_input_, src, reinterpret_cast<void*>(src));
|
| @@ -110,7 +110,7 @@ MIDIManagerMac::~MIDIManagerMac() {
|
| MIDIPortDispose(coremidi_output_);
|
| }
|
|
|
| -void MIDIManagerMac::ReadMidiDispatch(const MIDIPacketList* packet_list,
|
| +void MIDIManagerMac::ReadMIDIDispatch(const MIDIPacketList* packet_list,
|
| void* read_proc_refcon,
|
| void* src_conn_refcon) {
|
| MIDIManagerMac* manager = static_cast<MIDIManagerMac*>(read_proc_refcon);
|
| @@ -121,16 +121,16 @@ void MIDIManagerMac::ReadMidiDispatch(const MIDIPacketList* packet_list,
|
| #endif
|
|
|
| // Dispatch to class method.
|
| - manager->ReadMidi(source, packet_list);
|
| + manager->ReadMIDI(source, packet_list);
|
| }
|
|
|
| -void MIDIManagerMac::ReadMidi(MIDIEndpointRef source,
|
| +void MIDIManagerMac::ReadMIDI(MIDIEndpointRef source,
|
| const MIDIPacketList* packet_list) {
|
| // Lookup the port index based on the source.
|
| SourceMap::iterator j = source_map_.find(source);
|
| if (j == source_map_.end())
|
| return;
|
| - int port_index = source_map_[source];
|
| + uint32 port_index = source_map_[source];
|
|
|
| // Go through each packet and process separately.
|
| for(size_t i = 0; i < packet_list->numPackets; i++) {
|
| @@ -147,10 +147,11 @@ void MIDIManagerMac::ReadMidi(MIDIEndpointRef source,
|
| }
|
|
|
| void MIDIManagerMac::SendMIDIData(MIDIManagerClient* client,
|
| - int port_index,
|
| - const uint8* data,
|
| - size_t length,
|
| + uint32 port_index,
|
| + const std::vector<uint8>& data,
|
| double timestamp) {
|
| + DCHECK(CurrentlyOnMIDISendThread());
|
| +
|
| // System Exclusive has already been filtered.
|
| MIDITimeStamp coremidi_timestamp = SecondsToMIDITimeStamp(timestamp);
|
|
|
| @@ -159,14 +160,11 @@ void MIDIManagerMac::SendMIDIData(MIDIManagerClient* client,
|
| kMaxPacketListSize,
|
| midi_packet_,
|
| coremidi_timestamp,
|
| - length,
|
| - data);
|
| + data.size(),
|
| + &data[0]);
|
|
|
| // Lookup the destination based on the port index.
|
| - // TODO(crogers): re-factor |port_index| to use unsigned
|
| - // to avoid the need for this check.
|
| - if (port_index < 0 ||
|
| - static_cast<size_t>(port_index) >= destinations_.size())
|
| + if (static_cast<size_t>(port_index) >= destinations_.size())
|
| return;
|
|
|
| MIDIEndpointRef destination = destinations_[port_index];
|
| @@ -176,7 +174,7 @@ void MIDIManagerMac::SendMIDIData(MIDIManagerClient* client,
|
| // Re-initialize for next time.
|
| midi_packet_ = MIDIPacketListInit(packet_list_);
|
|
|
| - client->AccumulateMIDIBytesSent(length);
|
| + client->AccumulateMIDIBytesSent(data.size());
|
| }
|
|
|
| MIDIPortInfo MIDIManagerMac::GetPortInfoFromEndpoint(
|
|
|