Chromium Code Reviews| Index: media/midi/midi_manager.cc |
| diff --git a/media/midi/midi_manager.cc b/media/midi/midi_manager.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fa8bb237841da142de1bd19c3db0fe5b601252c3 |
| --- /dev/null |
| +++ b/media/midi/midi_manager.cc |
| @@ -0,0 +1,60 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "media/midi/midi_manager.h" |
| + |
| +namespace media { |
| + |
| +MIDIManager::MIDIManager() |
| + : initialized_(false) { |
| +} |
| + |
| +MIDIManager::~MIDIManager() {} |
| + |
| +bool MIDIManager::RequestAccess(Client* client, int access) { |
| + // TODO(crogers): determine if user prompt is necessary here. |
| + // For now, simply don't allow sysex. |
| + if (access != kNoSystemExclusive) |
| + return false; |
| + |
| + // Lazily initialize the MIDI back-end. |
| + if (!initialized_) |
| + initialized_ = Initialize(); |
| + |
| + if (initialized_) { |
| + base::AutoLock auto_lock(clients_lock_); |
| + clients_.insert(client); |
| + } |
| + |
| + return initialized_; |
| +} |
| + |
| +void MIDIManager::ReleaseAccess(Client* client) { |
| + base::AutoLock auto_lock(clients_lock_); |
| + ClientList::iterator i = clients_.find(client); |
| + if (i != clients_.end()) |
| + clients_.erase(i); |
| +}; |
|
scherkus (not reviewing)
2013/06/12 01:28:47
remove extra ;
Chris Rogers
2013/06/12 20:34:35
Done.
|
| + |
| +void MIDIManager::AddInputPort(const MIDIPortInfo& info) { |
| + input_ports_.push_back(info); |
| +} |
| + |
| +void MIDIManager::AddOutputPort(const MIDIPortInfo& info) { |
| + output_ports_.push_back(info); |
| +} |
| + |
| +void MIDIManager::ReceiveMIDIData( |
| + int port_index, |
| + const uint8* data, |
| + size_t length, |
| + double timestamp) { |
| + base::AutoLock auto_lock(clients_lock_); |
| + |
| + // TODO(crogers): Filter out sysex. |
| + for (ClientList::iterator i = clients_.begin(); i != clients_.end(); ++i) |
| + (*i)->ReceiveMIDIData(port_index, data, length, timestamp); |
| +}; |
| + |
| +} // namespace media |