| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_usb.h" | 5 #include "media/midi/midi_manager_usb.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 device_factory_->EnumerateDevices( | 36 device_factory_->EnumerateDevices( |
| 37 this, | 37 this, |
| 38 base::Bind(&MidiManagerUsb::OnEnumerateDevicesDone, | 38 base::Bind(&MidiManagerUsb::OnEnumerateDevicesDone, |
| 39 base::Unretained(this))); | 39 base::Unretained(this))); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void MidiManagerUsb::DispatchSendMidiData(MidiManagerClient* client, | 42 void MidiManagerUsb::DispatchSendMidiData(MidiManagerClient* client, |
| 43 uint32_t port_index, | 43 uint32_t port_index, |
| 44 const std::vector<uint8>& data, | 44 const std::vector<uint8>& data, |
| 45 double timestamp) { | 45 double timestamp) { |
| 46 DCHECK_LT(port_index, output_streams_.size()); | 46 if (port_index >= output_streams_.size()) { |
| 47 // |port_index| is provided by a renderer so we can't believe that it is |
| 48 // in the valid range. |
| 49 // TODO(toyoshim): Move this check to MidiHost and kill the renderer when |
| 50 // it fails. |
| 51 return; |
| 52 } |
| 47 output_streams_[port_index]->Send(data); | 53 output_streams_[port_index]->Send(data); |
| 48 client->AccumulateMidiBytesSent(data.size()); | 54 client->AccumulateMidiBytesSent(data.size()); |
| 49 } | 55 } |
| 50 | 56 |
| 51 void MidiManagerUsb::ReceiveUsbMidiData(UsbMidiDevice* device, | 57 void MidiManagerUsb::ReceiveUsbMidiData(UsbMidiDevice* device, |
| 52 int endpoint_number, | 58 int endpoint_number, |
| 53 const uint8* data, | 59 const uint8* data, |
| 54 size_t size, | 60 size_t size, |
| 55 base::TimeTicks time) { | 61 base::TimeTicks time) { |
| 56 if (!input_stream_) | 62 if (!input_stream_) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 static_cast<long>(j)); | 120 static_cast<long>(j)); |
| 115 AddInputPort(port); | 121 AddInputPort(port); |
| 116 } | 122 } |
| 117 } | 123 } |
| 118 input_stream_.reset(new UsbMidiInputStream(input_jacks, this)); | 124 input_stream_.reset(new UsbMidiInputStream(input_jacks, this)); |
| 119 } | 125 } |
| 120 initialize_callback_.Run(MIDI_OK); | 126 initialize_callback_.Run(MIDI_OK); |
| 121 } | 127 } |
| 122 | 128 |
| 123 } // namespace media | 129 } // namespace media |
| OLD | NEW |