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

Unified Diff: Source/modules/webmidi/MIDIAccess.cpp

Issue 16288002: Web MIDI API (work in progress) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add accessApproved() 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
« no previous file with comments | « Source/modules/webmidi/MIDIAccess.h ('k') | Source/modules/webmidi/MIDIAccessFuture.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webmidi/MIDIAccess.cpp
diff --git a/Source/modules/webmidi/MIDIAccess.cpp b/Source/modules/webmidi/MIDIAccess.cpp
index 04b563d35778659d28ad6a5de5e14d9febd7eeb0..3779e91e07c73fa702e0567909d6bb295f6f688b 100644
--- a/Source/modules/webmidi/MIDIAccess.cpp
+++ b/Source/modules/webmidi/MIDIAccess.cpp
@@ -54,7 +54,42 @@ MIDIAccess::~MIDIAccess()
MIDIAccess::MIDIAccess(ScriptExecutionContext* context)
: ActiveDOMObject(context)
{
- ScriptWrappable::init(this);
+ // !!!!!!! Just for testing
+ RefPtr<MIDIInput> input = MIDIInput::create(context, "id", "manufacturer", "name", "version");
+ m_inputs.append(input);
+
+ m_midiAccessor = MIDIAccessor::create(this);
+
+ // For now just ask for basic access.
+ // FIXME: use dictionary information to determine the value here.
+ m_midiAccessor->requestAccess(0);
+}
+
+void MIDIAccess::receiveMIDIData(unsigned portIndex, const unsigned char* data, size_t length, double timeStamp)
+{
+ // FIXME: for now ignore portIndex and always use port 0 -- see "Just for testing" above.
+ // printf("ignoring port: %d\n", portIndex);
+ portIndex = 0;
+
+ if (portIndex < m_inputs.size())
+ m_inputs[portIndex]->receiveMIDIData(portIndex, data, length, timeStamp);
+}
+
+void MIDIAccess::addInputPort(const String& id, const String& manufacturer, const String& name, const String& version)
+{
+ RefPtr<MIDIInput> input = MIDIInput::create(scriptExecutionContext(), id, manufacturer, name, version);
+ m_inputs.append(input);
+}
+
+void MIDIAccess::addOutputPort(const String& id, const String& manufacturer, const String& name, const String& version)
+{
+ RefPtr<MIDIOutput> output = MIDIOutput::create(scriptExecutionContext(), id, manufacturer, name, version);
+ m_outputs.append(output);
+}
+
+void MIDIAccess::accessApproved(bool approved)
+{
+ // FIXME: call callbacks.
}
} // namespace WebCore
« no previous file with comments | « Source/modules/webmidi/MIDIAccess.h ('k') | Source/modules/webmidi/MIDIAccessFuture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698