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