OLD | NEW |
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.h" | 5 #include "media/midi/midi_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 155 |
156 // Continue to hold lock_ here in case another thread is currently doing | 156 // Continue to hold lock_ here in case another thread is currently doing |
157 // EndSession. | 157 // EndSession. |
158 // Note that if we are in EndSession, then a destructor is being called and | 158 // Note that if we are in EndSession, then a destructor is being called and |
159 // it isn't really safe to call this method. But we don't have another way to | 159 // it isn't really safe to call this method. But we don't have another way to |
160 // check this right now. | 160 // check this right now. |
161 client->AccumulateMidiBytesSent(n); | 161 client->AccumulateMidiBytesSent(n); |
162 } | 162 } |
163 | 163 |
164 void MidiManager::DispatchSendMidiData(MidiManagerClient* client, | 164 void MidiManager::DispatchSendMidiData(MidiManagerClient* client, |
165 uint32 port_index, | 165 uint32_t port_index, |
166 const std::vector<uint8>& data, | 166 const std::vector<uint8_t>& data, |
167 double timestamp) { | 167 double timestamp) { |
168 NOTREACHED(); | 168 NOTREACHED(); |
169 } | 169 } |
170 | 170 |
171 void MidiManager::StartInitialization() { | 171 void MidiManager::StartInitialization() { |
172 CompleteInitialization(Result::NOT_SUPPORTED); | 172 CompleteInitialization(Result::NOT_SUPPORTED); |
173 } | 173 } |
174 | 174 |
175 void MidiManager::CompleteInitialization(Result result) { | 175 void MidiManager::CompleteInitialization(Result result) { |
176 base::AutoLock auto_lock(lock_); | 176 base::AutoLock auto_lock(lock_); |
(...skipping 13 matching lines...) Expand all Loading... |
190 } | 190 } |
191 | 191 |
192 void MidiManager::AddOutputPort(const MidiPortInfo& info) { | 192 void MidiManager::AddOutputPort(const MidiPortInfo& info) { |
193 ReportUsage(Usage::OUTPUT_PORT_ADDED); | 193 ReportUsage(Usage::OUTPUT_PORT_ADDED); |
194 base::AutoLock auto_lock(lock_); | 194 base::AutoLock auto_lock(lock_); |
195 output_ports_.push_back(info); | 195 output_ports_.push_back(info); |
196 for (auto client : clients_) | 196 for (auto client : clients_) |
197 client->AddOutputPort(info); | 197 client->AddOutputPort(info); |
198 } | 198 } |
199 | 199 |
200 void MidiManager::SetInputPortState(uint32 port_index, MidiPortState state) { | 200 void MidiManager::SetInputPortState(uint32_t port_index, MidiPortState state) { |
201 base::AutoLock auto_lock(lock_); | 201 base::AutoLock auto_lock(lock_); |
202 DCHECK_LT(port_index, input_ports_.size()); | 202 DCHECK_LT(port_index, input_ports_.size()); |
203 input_ports_[port_index].state = state; | 203 input_ports_[port_index].state = state; |
204 for (auto client : clients_) | 204 for (auto client : clients_) |
205 client->SetInputPortState(port_index, state); | 205 client->SetInputPortState(port_index, state); |
206 } | 206 } |
207 | 207 |
208 void MidiManager::SetOutputPortState(uint32 port_index, MidiPortState state) { | 208 void MidiManager::SetOutputPortState(uint32_t port_index, MidiPortState state) { |
209 base::AutoLock auto_lock(lock_); | 209 base::AutoLock auto_lock(lock_); |
210 DCHECK_LT(port_index, output_ports_.size()); | 210 DCHECK_LT(port_index, output_ports_.size()); |
211 output_ports_[port_index].state = state; | 211 output_ports_[port_index].state = state; |
212 for (auto client : clients_) | 212 for (auto client : clients_) |
213 client->SetOutputPortState(port_index, state); | 213 client->SetOutputPortState(port_index, state); |
214 } | 214 } |
215 | 215 |
216 void MidiManager::ReceiveMidiData( | 216 void MidiManager::ReceiveMidiData(uint32_t port_index, |
217 uint32 port_index, | 217 const uint8_t* data, |
218 const uint8* data, | 218 size_t length, |
219 size_t length, | 219 double timestamp) { |
220 double timestamp) { | |
221 base::AutoLock auto_lock(lock_); | 220 base::AutoLock auto_lock(lock_); |
222 | 221 |
223 for (auto client : clients_) | 222 for (auto client : clients_) |
224 client->ReceiveMidiData(port_index, data, length, timestamp); | 223 client->ReceiveMidiData(port_index, data, length, timestamp); |
225 } | 224 } |
226 | 225 |
227 void MidiManager::CompleteInitializationInternal(Result result) { | 226 void MidiManager::CompleteInitializationInternal(Result result) { |
228 TRACE_EVENT0("midi", "MidiManager::CompleteInitialization"); | 227 TRACE_EVENT0("midi", "MidiManager::CompleteInitialization"); |
229 ReportUsage(Usage::INITIALIZED); | 228 ReportUsage(Usage::INITIALIZED); |
230 UMA_HISTOGRAM_ENUMERATION("Media.Midi.InputPorts", | 229 UMA_HISTOGRAM_ENUMERATION("Media.Midi.InputPorts", |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 base::AutoLock auto_lock(lock_); | 263 base::AutoLock auto_lock(lock_); |
265 finalized_ = true; | 264 finalized_ = true; |
266 | 265 |
267 // Detach all clients so that they do not call MidiManager methods any more. | 266 // Detach all clients so that they do not call MidiManager methods any more. |
268 for (auto client : clients_) | 267 for (auto client : clients_) |
269 client->Detach(); | 268 client->Detach(); |
270 } | 269 } |
271 | 270 |
272 } // namespace midi | 271 } // namespace midi |
273 } // namespace media | 272 } // namespace media |
OLD | NEW |