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