Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: media/midi/midi_manager.cc

Issue 16025005: Web MIDI API back-end (work-in-progress) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use int64 in ParamTraits Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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(Client* 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(Client* 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 };
scherkus (not reviewing) 2013/06/12 01:28:47 remove extra ;
Chris Rogers 2013/06/12 20:34:35 Done.
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698