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

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

Issue 17288018: Re-land 16025005 with fix for statics perf issue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « media/midi/midi_manager.h ('k') | media/midi/midi_manager_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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
OLDNEW
« no previous file with comments | « media/midi/midi_manager.h ('k') | media/midi/midi_manager_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698