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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: media/midi/midi_manager.h
diff --git a/media/midi/midi_manager.h b/media/midi/midi_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..55030cb0b10798bdb8af22990e41abe3cc8f42a0
--- /dev/null
+++ b/media/midi/midi_manager.h
@@ -0,0 +1,86 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_MIDI_MIDI_MANAGER_H_
+#define MEDIA_MIDI_MIDI_MANAGER_H_
+
+#include <set>
+
+#include "base/basictypes.h"
+#include "base/synchronization/lock.h"
+#include "media/base/media_export.h"
+#include "media/midi/midi_port_info.h"
+
+namespace media {
+
+// Manages access to all MIDI hardware.
+class MEDIA_EXPORT MIDIManager {
+ public:
+ enum AccessType {
+ kNoSystemExclusive,
+ kSystemExclusive
+ };
+
+ 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.
+ public:
+ virtual ~Client() {}
+ 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
+ int port_index,
+ const uint8* data,
+ size_t length,
+ double timestamp) = 0;
+ };
+
+ static MIDIManager* Create();
+
+ MIDIManager();
+ virtual ~MIDIManager();
+
+ // If access is approved, lazily initializes the MIDI system
+ // and registers the client to receive MIDI data.
+ // Returns |true| if access is approved.
+ bool RequestAccess(Client* client, int access);
+ void ReleaseAccess(Client* client);
+
+ // Send one or more messages at the given time.
+ virtual void SendMIDIData(int port_index,
+ const uint8* data,
+ size_t length,
+ double timestamp) = 0;
+
+ const MIDIPortInfoList& input_ports() { return input_ports_; }
+ const MIDIPortInfoList& output_ports() { return output_ports_; }
+
+ protected:
+ // Initializes the MIDI system, returning |true| on success.
+ virtual bool Initialize() = 0;
+
+ void AddInputPort(const MIDIPortInfo& info);
+ void AddOutputPort(const MIDIPortInfo& info);
+
+ // Dispatches to all clients.
+ void ReceiveMIDIData(
+ int port_index,
+ const uint8* data,
+ size_t length,
+ double timestamp);
+
+ bool initialized_;
+
+ // Keeps track of all clients who wish to receive MIDI data.
+ typedef std::set<Client*> ClientList;
+ ClientList clients_;
+
+ // Protects access to our clients.
+ base::Lock clients_lock_;
+
+ MIDIPortInfoList input_ports_;
+ MIDIPortInfoList output_ports_;
+
+ DISALLOW_COPY_AND_ASSIGN(MIDIManager);
+};
+
+} // namespace media
+
+#endif // MEDIA_MIDI_MIDI_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698