Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(918)

Side by Side Diff: media/midi/midi_manager_mac.cc

Issue 965793002: Web MIDI: MIDI input messages may be lost or cause a crash on OS X (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 280
281 // Lookup the port index based on the source. 281 // Lookup the port index based on the source.
282 SourceMap::iterator j = source_map_.find(source); 282 SourceMap::iterator j = source_map_.find(source);
283 if (j == source_map_.end()) 283 if (j == source_map_.end())
284 return; 284 return;
285 // This is safe since MidiManagerMac does not remove any existing 285 // This is safe since MidiManagerMac does not remove any existing
286 // MIDIEndpointRef, and the order is saved. 286 // MIDIEndpointRef, and the order is saved.
287 uint32 port_index = source_map_[source]; 287 uint32 port_index = source_map_[source];
288 288
289 // Go through each packet and process separately. 289 // Go through each packet and process separately.
290 const MIDIPacket* packet = &packet_list->packet[0];
290 for (size_t i = 0; i < packet_list->numPackets; i++) { 291 for (size_t i = 0; i < packet_list->numPackets; i++) {
291 // Each packet contains MIDI data for one or more messages (like note-on). 292 // Each packet contains MIDI data for one or more messages (like note-on).
292 const MIDIPacket &packet = packet_list->packet[i]; 293 double timestamp_seconds = MIDITimeStampToSeconds(packet->timeStamp);
293 double timestamp_seconds = MIDITimeStampToSeconds(packet.timeStamp);
294 294
295 ReceiveMidiData( 295 ReceiveMidiData(
296 port_index, 296 port_index,
297 packet.data, 297 packet->data,
298 packet.length, 298 packet->length,
299 timestamp_seconds); 299 timestamp_seconds);
300
301 packet = MIDIPacketNext(packet);
300 } 302 }
301 } 303 }
302 304
303 void MidiManagerMac::SendMidiData(MidiManagerClient* client, 305 void MidiManagerMac::SendMidiData(MidiManagerClient* client,
304 uint32 port_index, 306 uint32 port_index,
305 const std::vector<uint8>& data, 307 const std::vector<uint8>& data,
306 double timestamp) { 308 double timestamp) {
307 DCHECK(client_thread_.message_loop_proxy()->BelongsToCurrentThread()); 309 DCHECK(client_thread_.message_loop_proxy()->BelongsToCurrentThread());
308 310
309 // System Exclusive has already been filtered. 311 // System Exclusive has already been filtered.
(...skipping 15 matching lines...) Expand all
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698