Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(549)

Side by Side Diff: media/midi/midi_manager.cc

Issue 662233002: Web MIDI: make MidiManagerMac notify device connections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + cleanup Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 client->AddInputPort(info); 123 client->AddInputPort(info);
124 } 124 }
125 125
126 void MidiManager::AddOutputPort(const MidiPortInfo& info) { 126 void MidiManager::AddOutputPort(const MidiPortInfo& info) {
127 base::AutoLock auto_lock(lock_); 127 base::AutoLock auto_lock(lock_);
128 output_ports_.push_back(info); 128 output_ports_.push_back(info);
129 for (auto client : clients_) 129 for (auto client : clients_)
130 client->AddOutputPort(info); 130 client->AddOutputPort(info);
131 } 131 }
132 132
133 void MidiManager::SetInputPortState(uint32 port_index, bool connected) {
134 base::AutoLock auto_lock(lock_);
135 DCHECK_LT(port_index, input_ports_.size());
136 input_ports_[port_index].connected = connected;
137 for (auto client : clients_)
138 client->SetInputPortState(port_index, connected);
139 }
140
141 void MidiManager::SetOutputPortState(uint32 port_index, bool connected) {
142 base::AutoLock auto_lock(lock_);
143 DCHECK_LT(port_index, output_ports_.size());
144 output_ports_[port_index].connected = connected;
145 for (auto client : clients_)
146 client->SetOutputPortState(port_index, connected);
147 }
148
133 void MidiManager::ReceiveMidiData( 149 void MidiManager::ReceiveMidiData(
134 uint32 port_index, 150 uint32 port_index,
135 const uint8* data, 151 const uint8* data,
136 size_t length, 152 size_t length,
137 double timestamp) { 153 double timestamp) {
138 base::AutoLock auto_lock(lock_); 154 base::AutoLock auto_lock(lock_);
139 155
140 for (auto client : clients_) 156 for (auto client : clients_)
141 client->ReceiveMidiData(port_index, data, length, timestamp); 157 client->ReceiveMidiData(port_index, data, length, timestamp);
142 } 158 }
(...skipping 20 matching lines...) Expand all
163 void MidiManager::AddInitialPorts(MidiManagerClient* client) { 179 void MidiManager::AddInitialPorts(MidiManagerClient* client) {
164 lock_.AssertAcquired(); 180 lock_.AssertAcquired();
165 181
166 for (const auto& info : input_ports_) 182 for (const auto& info : input_ports_)
167 client->AddInputPort(info); 183 client->AddInputPort(info);
168 for (const auto& info : output_ports_) 184 for (const auto& info : output_ports_)
169 client->AddOutputPort(info); 185 client->AddOutputPort(info);
170 } 186 }
171 187
172 } // namespace media 188 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698