OLD | NEW |
(Empty) | |
| 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 |
| 7 namespace media { |
| 8 |
| 9 MIDIManager::MIDIManager() |
| 10 : initialized_(false) { |
| 11 } |
| 12 |
| 13 MIDIManager::~MIDIManager() {} |
| 14 |
| 15 bool MIDIManager::RequestAccess(MIDIManagerClient* client, int access) { |
| 16 // TODO(crogers): determine if user prompt is necessary here. |
| 17 // For now, simply don't allow sysex. |
| 18 if (access != kNoSystemExclusive) |
| 19 return false; |
| 20 |
| 21 // Lazily initialize the MIDI back-end. |
| 22 if (!initialized_) |
| 23 initialized_ = Initialize(); |
| 24 |
| 25 if (initialized_) { |
| 26 base::AutoLock auto_lock(clients_lock_); |
| 27 clients_.insert(client); |
| 28 } |
| 29 |
| 30 return initialized_; |
| 31 } |
| 32 |
| 33 void MIDIManager::ReleaseAccess(MIDIManagerClient* client) { |
| 34 base::AutoLock auto_lock(clients_lock_); |
| 35 ClientList::iterator i = clients_.find(client); |
| 36 if (i != clients_.end()) |
| 37 clients_.erase(i); |
| 38 } |
| 39 |
| 40 void MIDIManager::AddInputPort(const MIDIPortInfo& info) { |
| 41 input_ports_.push_back(info); |
| 42 } |
| 43 |
| 44 void MIDIManager::AddOutputPort(const MIDIPortInfo& info) { |
| 45 output_ports_.push_back(info); |
| 46 } |
| 47 |
| 48 void MIDIManager::ReceiveMIDIData( |
| 49 int port_index, |
| 50 const uint8* data, |
| 51 size_t length, |
| 52 double timestamp) { |
| 53 base::AutoLock auto_lock(clients_lock_); |
| 54 |
| 55 // TODO(crogers): Filter out sysex. |
| 56 for (ClientList::iterator i = clients_.begin(); i != clients_.end(); ++i) |
| 57 (*i)->ReceiveMIDIData(port_index, data, length, timestamp); |
| 58 }; |
| 59 |
| 60 } // namespace media |
OLD | NEW |