Chromium Code Reviews| 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()) { |
|
Takashi Toyoshima
2015/02/09 06:34:41
Can you add TODO(toyoshim) here?
I think we should
yhirano
2015/02/09 08:41:12
Done.
| |
| 47 // |port_index| is provided by a renderer so we can't believe that it is | |
| 48 // in the valid range. | |
| 49 return; | |
| 50 } | |
| 47 output_streams_[port_index]->Send(data); | 51 output_streams_[port_index]->Send(data); |
| 48 client->AccumulateMidiBytesSent(data.size()); | 52 client->AccumulateMidiBytesSent(data.size()); |
| 49 } | 53 } |
| 50 | 54 |
| 51 void MidiManagerUsb::ReceiveUsbMidiData(UsbMidiDevice* device, | 55 void MidiManagerUsb::ReceiveUsbMidiData(UsbMidiDevice* device, |
| 52 int endpoint_number, | 56 int endpoint_number, |
| 53 const uint8* data, | 57 const uint8* data, |
| 54 size_t size, | 58 size_t size, |
| 55 base::TimeTicks time) { | 59 base::TimeTicks time) { |
| 56 if (!input_stream_) | 60 if (!input_stream_) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 static_cast<long>(j)); | 118 static_cast<long>(j)); |
| 115 AddInputPort(port); | 119 AddInputPort(port); |
| 116 } | 120 } |
| 117 } | 121 } |
| 118 input_stream_.reset(new UsbMidiInputStream(input_jacks, this)); | 122 input_stream_.reset(new UsbMidiInputStream(input_jacks, this)); |
| 119 } | 123 } |
| 120 initialize_callback_.Run(MIDI_OK); | 124 initialize_callback_.Run(MIDI_OK); |
| 121 } | 125 } |
| 122 | 126 |
| 123 } // namespace media | 127 } // namespace media |
| OLD | NEW |