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.
5 #include "media/midi/midi_manager.h"
8 #include "base/bind_helpers.h"
12 #if !defined(OS_MACOSX) && !defined(OS_WIN) && !defined(USE_ALSA)
13 // TODO(toyoshim): implement MIDIManager for other platforms.
14 MIDIManager
* MIDIManager::Create() {
15 return new MIDIManager
;
19 MIDIManager::MIDIManager()
20 : initialized_(false) {
23 MIDIManager::~MIDIManager() {
26 bool MIDIManager::StartSession(MIDIManagerClient
* client
) {
27 // Lazily initialize the MIDI back-end.
29 initialized_
= Initialize();
32 base::AutoLock
auto_lock(clients_lock_
);
33 clients_
.insert(client
);
39 void MIDIManager::EndSession(MIDIManagerClient
* client
) {
40 base::AutoLock
auto_lock(clients_lock_
);
41 ClientList::iterator i
= clients_
.find(client
);
42 if (i
!= clients_
.end())
46 void MIDIManager::DispatchSendMIDIData(MIDIManagerClient
* client
,
48 const std::vector
<uint8
>& data
,
53 bool MIDIManager::Initialize() {
57 void MIDIManager::AddInputPort(const MIDIPortInfo
& info
) {
58 input_ports_
.push_back(info
);
61 void MIDIManager::AddOutputPort(const MIDIPortInfo
& info
) {
62 output_ports_
.push_back(info
);
65 void MIDIManager::ReceiveMIDIData(
70 base::AutoLock
auto_lock(clients_lock_
);
72 for (ClientList::iterator i
= clients_
.begin(); i
!= clients_
.end(); ++i
)
73 (*i
)->ReceiveMIDIData(port_index
, data
, length
, timestamp
);