crogers@google.com | 27356e4 | 2013-06-22 04:03:03 +0000 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "media/midi/midi_manager.h" |
| 6 | |
toyoshim@chromium.org | c1e05fb | 2014-05-06 16:39:20 +0000 | [diff] [blame] | 7 | #include "base/bind.h" |
fdoray | a05bf57 | 2016-06-09 08:42:38 -0700 | [diff] [blame] | 8 | #include "base/location.h" |
toyoshim | f1b8896 | 2015-07-09 14:14:51 -0700 | [diff] [blame] | 9 | #include "base/metrics/histogram_macros.h" |
Patrick Monette | 54c53f4 | 2021-10-08 20:27:23 +0000 | [diff] [blame^] | 10 | #include "base/task/single_thread_task_runner_forward.h" |
fdoray | a05bf57 | 2016-06-09 08:42:38 -0700 | [diff] [blame] | 11 | #include "base/threading/thread_task_runner_handle.h" |
ssid | 9134444 | 2015-01-28 04:13:15 -0800 | [diff] [blame] | 12 | #include "base/trace_event/trace_event.h" |
avi | 793390d | 2015-12-22 22:22:36 -0800 | [diff] [blame] | 13 | #include "build/build_config.h" |
crogers@google.com | 542a43a | 2013-07-31 05:16:49 +0000 | [diff] [blame] | 14 | |
toyoshim | e147c5e | 2015-05-07 21:58:31 -0700 | [diff] [blame] | 15 | namespace midi { |
crogers@google.com | 27356e4 | 2013-06-22 04:03:03 +0000 | [diff] [blame] | 16 | |
toyoshim | 715385c | 2015-08-09 23:00:26 -0700 | [diff] [blame] | 17 | namespace { |
| 18 | |
| 19 | using Sample = base::HistogramBase::Sample; |
toyoshim | ec2570a | 2016-10-21 02:15:27 -0700 | [diff] [blame] | 20 | using midi::mojom::PortState; |
toyoshim | 2f3a48f | 2016-10-17 01:54:13 -0700 | [diff] [blame] | 21 | using midi::mojom::Result; |
toyoshim | 715385c | 2015-08-09 23:00:26 -0700 | [diff] [blame] | 22 | |
Takashi Toyoshima | 6fb495c | 2017-06-27 15:25:17 +0900 | [diff] [blame] | 23 | // Used to count events for usage histogram. The item order should not be |
| 24 | // changed, and new items should be just appended. |
toyoshim | 715385c | 2015-08-09 23:00:26 -0700 | [diff] [blame] | 25 | enum class Usage { |
| 26 | CREATED, |
| 27 | CREATED_ON_UNSUPPORTED_PLATFORMS, |
| 28 | SESSION_STARTED, |
| 29 | SESSION_ENDED, |
| 30 | INITIALIZED, |
| 31 | INPUT_PORT_ADDED, |
| 32 | OUTPUT_PORT_ADDED, |
Takashi Toyoshima | 3d5585f | 2019-06-25 06:15:27 +0000 | [diff] [blame] | 33 | ERROR_OBSERVED, |
toyoshim | 715385c | 2015-08-09 23:00:26 -0700 | [diff] [blame] | 34 | |
| 35 | // New items should be inserted here, and |MAX| should point the last item. |
Takashi Toyoshima | 3d5585f | 2019-06-25 06:15:27 +0000 | [diff] [blame] | 36 | MAX = ERROR_OBSERVED, |
toyoshim | 715385c | 2015-08-09 23:00:26 -0700 | [diff] [blame] | 37 | }; |
| 38 | |
Takashi Toyoshima | 6fb495c | 2017-06-27 15:25:17 +0900 | [diff] [blame] | 39 | // Used to count events for transaction usage histogram. The item order should |
| 40 | // not be changed, and new items should be just appended. |
| 41 | enum class SendReceiveUsage { |
| 42 | NO_USE, |
| 43 | SENT, |
| 44 | RECEIVED, |
| 45 | SENT_AND_RECEIVED, |
| 46 | |
| 47 | // New items should be inserted here, and |MAX| should point the last item. |
| 48 | MAX = SENT_AND_RECEIVED, |
| 49 | }; |
| 50 | |
toyoshim | 715385c | 2015-08-09 23:00:26 -0700 | [diff] [blame] | 51 | void ReportUsage(Usage usage) { |
Takashi Toyoshima | 6fb495c | 2017-06-27 15:25:17 +0900 | [diff] [blame] | 52 | UMA_HISTOGRAM_ENUMERATION("Media.Midi.Usage", usage, |
toyoshim | 715385c | 2015-08-09 23:00:26 -0700 | [diff] [blame] | 53 | static_cast<Sample>(Usage::MAX) + 1); |
| 54 | } |
| 55 | |
| 56 | } // namespace |
| 57 | |
Takashi Toyoshima | d4f37cd | 2018-10-01 07:43:39 +0000 | [diff] [blame] | 58 | MidiManager::MidiManager(MidiService* service) : service_(service) { |
toyoshim | 715385c | 2015-08-09 23:00:26 -0700 | [diff] [blame] | 59 | ReportUsage(Usage::CREATED); |
crogers@google.com | 27356e4 | 2013-06-22 04:03:03 +0000 | [diff] [blame] | 60 | } |
| 61 | |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 62 | MidiManager::~MidiManager() { |
Takashi Toyoshima | 408b79f | 2018-01-09 20:30:07 +0900 | [diff] [blame] | 63 | base::AutoLock auto_lock(lock_); |
Adithya Srinivasan | c262ed3 | 2018-12-26 06:20:53 +0000 | [diff] [blame] | 64 | DCHECK(pending_clients_.empty() && clients_.empty()); |
| 65 | |
Takashi Toyoshima | d4f37cd | 2018-10-01 07:43:39 +0000 | [diff] [blame] | 66 | if (session_thread_runner_) { |
Takashi Toyoshima | 408b79f | 2018-01-09 20:30:07 +0900 | [diff] [blame] | 67 | DCHECK(session_thread_runner_->BelongsToCurrentThread()); |
Takashi Toyoshima | d4f37cd | 2018-10-01 07:43:39 +0000 | [diff] [blame] | 68 | session_thread_runner_ = nullptr; |
| 69 | } |
Takashi Toyoshima | 408b79f | 2018-01-09 20:30:07 +0900 | [diff] [blame] | 70 | |
Takashi Toyoshima | 3d5585f | 2019-06-25 06:15:27 +0000 | [diff] [blame] | 71 | if (result_ == Result::INITIALIZATION_ERROR) |
| 72 | ReportUsage(Usage::ERROR_OBSERVED); |
Takashi Toyoshima | 408b79f | 2018-01-09 20:30:07 +0900 | [diff] [blame] | 73 | |
| 74 | UMA_HISTOGRAM_ENUMERATION( |
| 75 | "Media.Midi.SendReceiveUsage", |
| 76 | data_sent_ ? (data_received_ ? SendReceiveUsage::SENT_AND_RECEIVED |
| 77 | : SendReceiveUsage::SENT) |
| 78 | : (data_received_ ? SendReceiveUsage::RECEIVED |
| 79 | : SendReceiveUsage::NO_USE), |
| 80 | static_cast<Sample>(SendReceiveUsage::MAX) + 1); |
toyoshim | 7a80966 | 2015-10-06 00:54:21 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Avi Drissman | 56d38b6 | 2020-07-29 19:29:27 +0000 | [diff] [blame] | 83 | #if !defined(OS_MAC) && !defined(OS_WIN) && \ |
Takashi Toyoshima | e8240ab | 2018-10-03 09:30:11 +0000 | [diff] [blame] | 84 | !(defined(USE_ALSA) && defined(USE_UDEV)) && !defined(OS_ANDROID) |
| 85 | MidiManager* MidiManager::Create(MidiService* service) { |
| 86 | ReportUsage(Usage::CREATED_ON_UNSUPPORTED_PLATFORMS); |
| 87 | return new MidiManager(service); |
| 88 | } |
| 89 | #endif |
| 90 | |
toyoshim | a485ff9 | 2014-10-23 00:17:59 -0700 | [diff] [blame] | 91 | void MidiManager::StartSession(MidiManagerClient* client) { |
toyoshim | 715385c | 2015-08-09 23:00:26 -0700 | [diff] [blame] | 92 | ReportUsage(Usage::SESSION_STARTED); |
| 93 | |
shaochuan | 8ba1cb6 | 2016-10-24 04:34:31 -0700 | [diff] [blame] | 94 | bool needs_initialization = false; |
toyoshim@chromium.org | 51c7f53 | 2014-05-01 17:17:32 +0000 | [diff] [blame] | 95 | |
| 96 | { |
toyoshim@chromium.org | c1e05fb | 2014-05-06 16:39:20 +0000 | [diff] [blame] | 97 | base::AutoLock auto_lock(lock_); |
Takashi Toyoshima | 408b79f | 2018-01-09 20:30:07 +0900 | [diff] [blame] | 98 | |
toyoshim | a485ff9 | 2014-10-23 00:17:59 -0700 | [diff] [blame] | 99 | if (clients_.find(client) != clients_.end() || |
| 100 | pending_clients_.find(client) != pending_clients_.end()) { |
| 101 | // Should not happen. But just in case the renderer is compromised. |
| 102 | NOTREACHED(); |
| 103 | return; |
| 104 | } |
toyoshim@chromium.org | fc2002e | 2014-05-07 08:10:34 +0000 | [diff] [blame] | 105 | |
shaochuan | 8ba1cb6 | 2016-10-24 04:34:31 -0700 | [diff] [blame] | 106 | if (initialization_state_ == InitializationState::COMPLETED) { |
toyoshim | 7a80966 | 2015-10-06 00:54:21 -0700 | [diff] [blame] | 107 | // Platform dependent initialization was already finished for previously |
| 108 | // initialized clients. |
Takashi Toyoshima | 5a6e6a3 | 2018-09-27 11:20:52 +0000 | [diff] [blame] | 109 | if (result_ == Result::OK) { |
| 110 | for (const auto& info : input_ports_) |
| 111 | client->AddInputPort(info); |
| 112 | for (const auto& info : output_ports_) |
| 113 | client->AddOutputPort(info); |
| 114 | } |
Takashi Toyoshima | ec05edf | 2017-11-28 11:21:20 +0000 | [diff] [blame] | 115 | |
toyoshim | 7a80966 | 2015-10-06 00:54:21 -0700 | [diff] [blame] | 116 | // Complete synchronously with |result_|; |
Takashi Toyoshima | ec05edf | 2017-11-28 11:21:20 +0000 | [diff] [blame] | 117 | clients_.insert(client); |
shaochuan | 8ba1cb6 | 2016-10-24 04:34:31 -0700 | [diff] [blame] | 118 | client->CompleteStartSession(result_); |
ochang | ae3bae9 | 2016-01-12 19:42:10 -0800 | [diff] [blame] | 119 | return; |
| 120 | } |
shaochuan | 8ba1cb6 | 2016-10-24 04:34:31 -0700 | [diff] [blame] | 121 | |
| 122 | // Do not accept a new request if the pending client list contains too |
| 123 | // many clients. |
| 124 | if (pending_clients_.size() >= kMaxPendingClientCount) { |
| 125 | client->CompleteStartSession(Result::INITIALIZATION_ERROR); |
| 126 | return; |
| 127 | } |
| 128 | |
| 129 | if (initialization_state_ == InitializationState::NOT_STARTED) { |
| 130 | // Set fields protected by |lock_| here and call StartInitialization() |
| 131 | // later. |
| 132 | needs_initialization = true; |
| 133 | session_thread_runner_ = base::ThreadTaskRunnerHandle::Get(); |
| 134 | initialization_state_ = InitializationState::STARTED; |
| 135 | } |
| 136 | |
| 137 | pending_clients_.insert(client); |
toyoshim@chromium.org | f77a1e6 | 2014-04-11 13:16:24 +0000 | [diff] [blame] | 138 | } |
crogers@google.com | 27356e4 | 2013-06-22 04:03:03 +0000 | [diff] [blame] | 139 | |
shaochuan | 8ba1cb6 | 2016-10-24 04:34:31 -0700 | [diff] [blame] | 140 | if (needs_initialization) { |
toyoshim | 7a80966 | 2015-10-06 00:54:21 -0700 | [diff] [blame] | 141 | // Lazily initialize the MIDI back-end. |
| 142 | TRACE_EVENT0("midi", "MidiManager::StartInitialization"); |
toyoshim@chromium.org | 51c7f53 | 2014-05-01 17:17:32 +0000 | [diff] [blame] | 143 | // CompleteInitialization() will be called asynchronously when platform |
| 144 | // dependent initialization is finished. |
toyoshim | 7a80966 | 2015-10-06 00:54:21 -0700 | [diff] [blame] | 145 | StartInitialization(); |
crogers@google.com | 27356e4 | 2013-06-22 04:03:03 +0000 | [diff] [blame] | 146 | } |
crogers@google.com | 27356e4 | 2013-06-22 04:03:03 +0000 | [diff] [blame] | 147 | } |
| 148 | |
Takashi Toyoshima | 150b443 | 2017-08-21 12:08:09 +0000 | [diff] [blame] | 149 | bool MidiManager::EndSession(MidiManagerClient* client) { |
toyoshim | 715385c | 2015-08-09 23:00:26 -0700 | [diff] [blame] | 150 | ReportUsage(Usage::SESSION_ENDED); |
| 151 | |
toyoshim | a485ff9 | 2014-10-23 00:17:59 -0700 | [diff] [blame] | 152 | // At this point, |client| can be in the destruction process, and calling |
ochang | ae3bae9 | 2016-01-12 19:42:10 -0800 | [diff] [blame] | 153 | // any method of |client| is dangerous. Calls on clients *must* be protected |
| 154 | // by |lock_| to prevent race conditions. |
toyoshim@chromium.org | c1e05fb | 2014-05-06 16:39:20 +0000 | [diff] [blame] | 155 | base::AutoLock auto_lock(lock_); |
Takashi Toyoshima | 150b443 | 2017-08-21 12:08:09 +0000 | [diff] [blame] | 156 | if (clients_.find(client) == clients_.end() && |
| 157 | pending_clients_.find(client) == pending_clients_.end()) { |
| 158 | return false; |
| 159 | } |
| 160 | |
toyoshim@chromium.org | 1fa678a | 2014-06-13 09:40:33 +0000 | [diff] [blame] | 161 | clients_.erase(client); |
| 162 | pending_clients_.erase(client); |
Takashi Toyoshima | 150b443 | 2017-08-21 12:08:09 +0000 | [diff] [blame] | 163 | return true; |
| 164 | } |
| 165 | |
| 166 | bool MidiManager::HasOpenSession() { |
| 167 | base::AutoLock auto_lock(lock_); |
| 168 | return clients_.size() != 0u; |
crogers@google.com | 27356e4 | 2013-06-22 04:03:03 +0000 | [diff] [blame] | 169 | } |
| 170 | |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 171 | void MidiManager::DispatchSendMidiData(MidiManagerClient* client, |
Avi Drissman | 3528fd0 | 2015-12-18 20:11:31 -0500 | [diff] [blame] | 172 | uint32_t port_index, |
| 173 | const std::vector<uint8_t>& data, |
tzik | 925e2c6 | 2018-02-02 07:39:45 +0000 | [diff] [blame] | 174 | base::TimeTicks timestamp) { |
yhirano@chromium.org | c6d5b7b | 2013-12-20 07:27:23 +0000 | [diff] [blame] | 175 | NOTREACHED(); |
| 176 | } |
| 177 | |
Adithya Srinivasan | c262ed3 | 2018-12-26 06:20:53 +0000 | [diff] [blame] | 178 | void MidiManager::EndAllSessions() { |
| 179 | base::AutoLock lock(lock_); |
| 180 | for (auto* client : pending_clients_) |
| 181 | client->Detach(); |
| 182 | for (auto* client : clients_) |
| 183 | client->Detach(); |
| 184 | pending_clients_.clear(); |
| 185 | clients_.clear(); |
| 186 | } |
| 187 | |
toyoshim@chromium.org | 51c7f53 | 2014-05-01 17:17:32 +0000 | [diff] [blame] | 188 | void MidiManager::StartInitialization() { |
toyoshim | f1b8896 | 2015-07-09 14:14:51 -0700 | [diff] [blame] | 189 | CompleteInitialization(Result::NOT_SUPPORTED); |
toyoshim@chromium.org | 51c7f53 | 2014-05-01 17:17:32 +0000 | [diff] [blame] | 190 | } |
| 191 | |
toyoshim | f1b8896 | 2015-07-09 14:14:51 -0700 | [diff] [blame] | 192 | void MidiManager::CompleteInitialization(Result result) { |
Takashi Toyoshima | d4f37cd | 2018-10-01 07:43:39 +0000 | [diff] [blame] | 193 | DCHECK_EQ(InitializationState::STARTED, initialization_state_); |
| 194 | |
Takashi Toyoshima | 5a6e6a3 | 2018-09-27 11:20:52 +0000 | [diff] [blame] | 195 | TRACE_EVENT0("midi", "MidiManager::CompleteInitialization"); |
| 196 | ReportUsage(Usage::INITIALIZED); |
| 197 | |
| 198 | base::AutoLock auto_lock(lock_); |
Takashi Toyoshima | d4f37cd | 2018-10-01 07:43:39 +0000 | [diff] [blame] | 199 | if (!session_thread_runner_) |
| 200 | return; |
| 201 | DCHECK(session_thread_runner_->BelongsToCurrentThread()); |
| 202 | |
Takashi Toyoshima | 5a6e6a3 | 2018-09-27 11:20:52 +0000 | [diff] [blame] | 203 | DCHECK(clients_.empty()); |
Takashi Toyoshima | 5a6e6a3 | 2018-09-27 11:20:52 +0000 | [diff] [blame] | 204 | initialization_state_ = InitializationState::COMPLETED; |
| 205 | result_ = result; |
| 206 | |
| 207 | for (auto* client : pending_clients_) { |
| 208 | if (result_ == Result::OK) { |
| 209 | for (const auto& info : input_ports_) |
| 210 | client->AddInputPort(info); |
| 211 | for (const auto& info : output_ports_) |
| 212 | client->AddOutputPort(info); |
toyoshim | d28b59c | 2017-02-20 11:07:37 -0800 | [diff] [blame] | 213 | } |
Takashi Toyoshima | 5a6e6a3 | 2018-09-27 11:20:52 +0000 | [diff] [blame] | 214 | |
| 215 | clients_.insert(client); |
| 216 | client->CompleteStartSession(result_); |
toyoshim | 7a80966 | 2015-10-06 00:54:21 -0700 | [diff] [blame] | 217 | } |
Takashi Toyoshima | 5a6e6a3 | 2018-09-27 11:20:52 +0000 | [diff] [blame] | 218 | pending_clients_.clear(); |
yhirano@chromium.org | c6d5b7b | 2013-12-20 07:27:23 +0000 | [diff] [blame] | 219 | } |
| 220 | |
Adithya Srinivasan | 3325273 | 2018-10-17 15:59:40 +0000 | [diff] [blame] | 221 | void MidiManager::AddInputPort(const mojom::PortInfo& info) { |
toyoshim | 715385c | 2015-08-09 23:00:26 -0700 | [diff] [blame] | 222 | ReportUsage(Usage::INPUT_PORT_ADDED); |
toyoshim | a62d674 | 2014-10-23 09:05:03 -0700 | [diff] [blame] | 223 | base::AutoLock auto_lock(lock_); |
crogers@google.com | 27356e4 | 2013-06-22 04:03:03 +0000 | [diff] [blame] | 224 | input_ports_.push_back(info); |
vmpstr | 0205abb | 2016-06-28 18:50:56 -0700 | [diff] [blame] | 225 | for (auto* client : clients_) |
toyoshim | a62d674 | 2014-10-23 09:05:03 -0700 | [diff] [blame] | 226 | client->AddInputPort(info); |
crogers@google.com | 27356e4 | 2013-06-22 04:03:03 +0000 | [diff] [blame] | 227 | } |
| 228 | |
Adithya Srinivasan | 3325273 | 2018-10-17 15:59:40 +0000 | [diff] [blame] | 229 | void MidiManager::AddOutputPort(const mojom::PortInfo& info) { |
toyoshim | 715385c | 2015-08-09 23:00:26 -0700 | [diff] [blame] | 230 | ReportUsage(Usage::OUTPUT_PORT_ADDED); |
toyoshim | a62d674 | 2014-10-23 09:05:03 -0700 | [diff] [blame] | 231 | base::AutoLock auto_lock(lock_); |
crogers@google.com | 27356e4 | 2013-06-22 04:03:03 +0000 | [diff] [blame] | 232 | output_ports_.push_back(info); |
vmpstr | 0205abb | 2016-06-28 18:50:56 -0700 | [diff] [blame] | 233 | for (auto* client : clients_) |
toyoshim | a62d674 | 2014-10-23 09:05:03 -0700 | [diff] [blame] | 234 | client->AddOutputPort(info); |
crogers@google.com | 27356e4 | 2013-06-22 04:03:03 +0000 | [diff] [blame] | 235 | } |
| 236 | |
toyoshim | ec2570a | 2016-10-21 02:15:27 -0700 | [diff] [blame] | 237 | void MidiManager::SetInputPortState(uint32_t port_index, PortState state) { |
toyoshim | 5c6fe4b | 2015-02-18 23:28:09 -0800 | [diff] [blame] | 238 | base::AutoLock auto_lock(lock_); |
| 239 | DCHECK_LT(port_index, input_ports_.size()); |
| 240 | input_ports_[port_index].state = state; |
vmpstr | 0205abb | 2016-06-28 18:50:56 -0700 | [diff] [blame] | 241 | for (auto* client : clients_) |
toyoshim | 5c6fe4b | 2015-02-18 23:28:09 -0800 | [diff] [blame] | 242 | client->SetInputPortState(port_index, state); |
| 243 | } |
| 244 | |
toyoshim | ec2570a | 2016-10-21 02:15:27 -0700 | [diff] [blame] | 245 | void MidiManager::SetOutputPortState(uint32_t port_index, PortState state) { |
toyoshim | 5c6fe4b | 2015-02-18 23:28:09 -0800 | [diff] [blame] | 246 | base::AutoLock auto_lock(lock_); |
| 247 | DCHECK_LT(port_index, output_ports_.size()); |
| 248 | output_ports_[port_index].state = state; |
vmpstr | 0205abb | 2016-06-28 18:50:56 -0700 | [diff] [blame] | 249 | for (auto* client : clients_) |
toyoshim | 5c6fe4b | 2015-02-18 23:28:09 -0800 | [diff] [blame] | 250 | client->SetOutputPortState(port_index, state); |
| 251 | } |
| 252 | |
Takashi Toyoshima | 5a6e6a3 | 2018-09-27 11:20:52 +0000 | [diff] [blame] | 253 | mojom::PortState MidiManager::GetOutputPortState(uint32_t port_index) { |
| 254 | base::AutoLock auto_lock(lock_); |
| 255 | DCHECK_LT(port_index, output_ports_.size()); |
| 256 | return output_ports_[port_index].state; |
| 257 | } |
| 258 | |
| 259 | void MidiManager::AccumulateMidiBytesSent(MidiManagerClient* client, size_t n) { |
| 260 | base::AutoLock auto_lock(lock_); |
| 261 | data_sent_ = true; |
| 262 | if (clients_.find(client) == clients_.end()) |
| 263 | return; |
| 264 | |
| 265 | // Continue to hold lock_ here in case another thread is currently doing |
| 266 | // EndSession. |
| 267 | client->AccumulateMidiBytesSent(n); |
| 268 | } |
| 269 | |
Avi Drissman | 3528fd0 | 2015-12-18 20:11:31 -0500 | [diff] [blame] | 270 | void MidiManager::ReceiveMidiData(uint32_t port_index, |
| 271 | const uint8_t* data, |
| 272 | size_t length, |
tzik | 925e2c6 | 2018-02-02 07:39:45 +0000 | [diff] [blame] | 273 | base::TimeTicks timestamp) { |
toyoshim@chromium.org | c1e05fb | 2014-05-06 16:39:20 +0000 | [diff] [blame] | 274 | base::AutoLock auto_lock(lock_); |
Takashi Toyoshima | 6fb495c | 2017-06-27 15:25:17 +0900 | [diff] [blame] | 275 | data_received_ = true; |
crogers@google.com | 27356e4 | 2013-06-22 04:03:03 +0000 | [diff] [blame] | 276 | |
vmpstr | 0205abb | 2016-06-28 18:50:56 -0700 | [diff] [blame] | 277 | for (auto* client : clients_) |
toyoshim | a485ff9 | 2014-10-23 00:17:59 -0700 | [diff] [blame] | 278 | client->ReceiveMidiData(port_index, data, length, timestamp); |
crogers@google.com | 542a43a | 2013-07-31 05:16:49 +0000 | [diff] [blame] | 279 | } |
| 280 | |
Takashi Toyoshima | d4f37cd | 2018-10-01 07:43:39 +0000 | [diff] [blame] | 281 | size_t MidiManager::GetClientCountForTesting() { |
| 282 | base::AutoLock auto_lock(lock_); |
| 283 | return clients_.size(); |
| 284 | } |
| 285 | |
| 286 | size_t MidiManager::GetPendingClientCountForTesting() { |
Adithya Srinivasan | c262ed3 | 2018-12-26 06:20:53 +0000 | [diff] [blame] | 287 | base::AutoLock auto_lock(lock_); |
Takashi Toyoshima | d4f37cd | 2018-10-01 07:43:39 +0000 | [diff] [blame] | 288 | return pending_clients_.size(); |
| 289 | } |
| 290 | |
toyoshim | e147c5e | 2015-05-07 21:58:31 -0700 | [diff] [blame] | 291 | } // namespace midi |