| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "media/midi/midi_scheduler.h" | 12 #include "media/midi/midi_scheduler.h" |
| 13 #include "media/midi/usb_midi_descriptor_parser.h" | 13 #include "media/midi/usb_midi_descriptor_parser.h" |
| 14 | 14 |
| 15 namespace media { | 15 namespace media { |
| 16 namespace midi { | 16 namespace midi { |
| 17 | 17 |
| 18 MidiManagerUsb::MidiManagerUsb(scoped_ptr<UsbMidiDevice::Factory> factory) | 18 MidiManagerUsb::MidiManagerUsb(std::unique_ptr<UsbMidiDevice::Factory> factory) |
| 19 : device_factory_(std::move(factory)) {} | 19 : device_factory_(std::move(factory)) {} |
| 20 | 20 |
| 21 MidiManagerUsb::~MidiManagerUsb() { | 21 MidiManagerUsb::~MidiManagerUsb() { |
| 22 } | 22 } |
| 23 | 23 |
| 24 void MidiManagerUsb::StartInitialization() { | 24 void MidiManagerUsb::StartInitialization() { |
| 25 Initialize( | 25 Initialize( |
| 26 base::Bind(&MidiManager::CompleteInitialization, base::Unretained(this))); | 26 base::Bind(&MidiManager::CompleteInitialization, base::Unretained(this))); |
| 27 } | 27 } |
| 28 | 28 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 base::TimeTicks time) { | 61 base::TimeTicks time) { |
| 62 if (!input_stream_) | 62 if (!input_stream_) |
| 63 return; | 63 return; |
| 64 input_stream_->OnReceivedData(device, | 64 input_stream_->OnReceivedData(device, |
| 65 endpoint_number, | 65 endpoint_number, |
| 66 data, | 66 data, |
| 67 size, | 67 size, |
| 68 time); | 68 time); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void MidiManagerUsb::OnDeviceAttached(scoped_ptr<UsbMidiDevice> device) { | 71 void MidiManagerUsb::OnDeviceAttached(std::unique_ptr<UsbMidiDevice> device) { |
| 72 int device_id = static_cast<int>(devices_.size()); | 72 int device_id = static_cast<int>(devices_.size()); |
| 73 devices_.push_back(std::move(device)); | 73 devices_.push_back(std::move(device)); |
| 74 AddPorts(devices_.back(), device_id); | 74 AddPorts(devices_.back(), device_id); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void MidiManagerUsb::OnDeviceDetached(size_t index) { | 77 void MidiManagerUsb::OnDeviceDetached(size_t index) { |
| 78 if (index >= devices_.size()) { | 78 if (index >= devices_.size()) { |
| 79 return; | 79 return; |
| 80 } | 80 } |
| 81 UsbMidiDevice* device = devices_[index]; | 81 UsbMidiDevice* device = devices_[index]; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 input_stream_->Add(jacks[j]); | 148 input_stream_->Add(jacks[j]); |
| 149 AddInputPort(MidiPortInfo(id, manufacturer, product_name, version, | 149 AddInputPort(MidiPortInfo(id, manufacturer, product_name, version, |
| 150 MIDI_PORT_OPENED)); | 150 MIDI_PORT_OPENED)); |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 return true; | 153 return true; |
| 154 } | 154 } |
| 155 | 155 |
| 156 } // namespace midi | 156 } // namespace midi |
| 157 } // namespace media | 157 } // namespace media |
| OLD | NEW |