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

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

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 #ifndef MEDIA_MIDI_MIDI_MANAGER_H_
6 #define MEDIA_MIDI_MIDI_MANAGER_H_
7
8 #include <set>
9
10 #include "base/basictypes.h"
11 #include "base/synchronization/lock.h"
12 #include "media/base/media_export.h"
13 #include "media/midi/midi_port_info.h"
14
15 namespace media {
16
17 // Manages access to all MIDI hardware.
18 class MEDIA_EXPORT MIDIManager {
19 public:
20 enum AccessType {
21 kNoSystemExclusive,
22 kSystemExclusive
23 };
24
25 class Client {
scherkus (not reviewing) 2013/06/12 01:28:47 although it is prevalent elsewhere in media code,
Chris Rogers 2013/06/12 20:34:35 Done.
26 public:
27 virtual ~Client() {}
28 virtual void ReceiveMIDIData(
scherkus (not reviewing) 2013/06/12 01:28:47 needs docs
Chris Rogers 2013/06/12 20:34:35 Added comments for this and similar methods in thi
29 int port_index,
30 const uint8* data,
31 size_t length,
32 double timestamp) = 0;
33 };
34
35 static MIDIManager* Create();
36
37 MIDIManager();
38 virtual ~MIDIManager();
39
40 // If access is approved, lazily initializes the MIDI system
41 // and registers the client to receive MIDI data.
42 // Returns |true| if access is approved.
43 bool RequestAccess(Client* client, int access);
44 void ReleaseAccess(Client* client);
45
46 // Send one or more messages at the given time.
47 virtual void SendMIDIData(int port_index,
48 const uint8* data,
49 size_t length,
50 double timestamp) = 0;
51
52 const MIDIPortInfoList& input_ports() { return input_ports_; }
53 const MIDIPortInfoList& output_ports() { return output_ports_; }
54
55 protected:
56 // Initializes the MIDI system, returning |true| on success.
57 virtual bool Initialize() = 0;
58
59 void AddInputPort(const MIDIPortInfo& info);
60 void AddOutputPort(const MIDIPortInfo& info);
61
62 // Dispatches to all clients.
63 void ReceiveMIDIData(
64 int port_index,
65 const uint8* data,
66 size_t length,
67 double timestamp);
68
69 bool initialized_;
70
71 // Keeps track of all clients who wish to receive MIDI data.
72 typedef std::set<Client*> ClientList;
73 ClientList clients_;
74
75 // Protects access to our clients.
76 base::Lock clients_lock_;
77
78 MIDIPortInfoList input_ports_;
79 MIDIPortInfoList output_ports_;
80
81 DISALLOW_COPY_AND_ASSIGN(MIDIManager);
82 };
83
84 } // namespace media
85
86 #endif // MEDIA_MIDI_MIDI_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698