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 #include "base/bind.h" 8 #include "base/bind_helpers.h" 9 10 namespace media { 11 12 #if !defined(OS_MACOSX) && !defined(OS_WIN) 13 // TODO(crogers): implement MIDIManager for other platforms. Create()14MIDIManager* MIDIManager::Create() { 15 return NULL; 16 } 17 #endif 18 MIDIManager()19MIDIManager::MIDIManager() 20 : initialized_(false) { 21 } 22 ~MIDIManager()23MIDIManager::~MIDIManager() { 24 } 25 StartSession(MIDIManagerClient * client)26bool MIDIManager::StartSession(MIDIManagerClient* client) { 27 // Lazily initialize the MIDI back-end. 28 if (!initialized_) 29 initialized_ = Initialize(); 30 31 if (initialized_) { 32 base::AutoLock auto_lock(clients_lock_); 33 clients_.insert(client); 34 } 35 36 return initialized_; 37 } 38 EndSession(MIDIManagerClient * client)39void MIDIManager::EndSession(MIDIManagerClient* client) { 40 base::AutoLock auto_lock(clients_lock_); 41 ClientList::iterator i = clients_.find(client); 42 if (i != clients_.end()) 43 clients_.erase(i); 44 } 45 AddInputPort(const MIDIPortInfo & info)46void MIDIManager::AddInputPort(const MIDIPortInfo& info) { 47 input_ports_.push_back(info); 48 } 49 AddOutputPort(const MIDIPortInfo & info)50void MIDIManager::AddOutputPort(const MIDIPortInfo& info) { 51 output_ports_.push_back(info); 52 } 53 ReceiveMIDIData(uint32 port_index,const uint8 * data,size_t length,double timestamp)54void MIDIManager::ReceiveMIDIData( 55 uint32 port_index, 56 const uint8* data, 57 size_t length, 58 double timestamp) { 59 base::AutoLock auto_lock(clients_lock_); 60 61 for (ClientList::iterator i = clients_.begin(); i != clients_.end(); ++i) 62 (*i)->ReceiveMIDIData(port_index, data, length, timestamp); 63 } 64 65 } // namespace media 66