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

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

Issue 18858006: Implement MIDIOutput.send() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add support for regular Array Created 7 years, 5 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: Source/modules/webmidi/MIDIOutput.cpp
diff --git a/Source/modules/webmidi/MIDIOutput.cpp b/Source/modules/webmidi/MIDIOutput.cpp
index e9066f0561fc600d24a8c1dd0fe59623522c6950..40244e469b0a43877f8288907b962db08f207304 100644
--- a/Source/modules/webmidi/MIDIOutput.cpp
+++ b/Source/modules/webmidi/MIDIOutput.cpp
@@ -31,30 +31,42 @@
#include "config.h"
#include "modules/webmidi/MIDIOutput.h"
+#include "modules/webmidi/MIDIAccess.h"
+
namespace WebCore {
-PassRefPtr<MIDIOutput> MIDIOutput::create(ScriptExecutionContext* context, const String& id, const String& manufacturer, const String& name, const String& version)
+PassRefPtr<MIDIOutput> MIDIOutput::create(MIDIAccess* access, unsigned portIndex, ScriptExecutionContext* context, const String& id, const String& manufacturer, const String& name, const String& version)
{
- return adoptRef(new MIDIOutput(context, id, manufacturer, name, version));
+ return adoptRef(new MIDIOutput(access, portIndex, context, id, manufacturer, name, version));
}
-MIDIOutput::MIDIOutput(ScriptExecutionContext* context, const String& id, const String& manufacturer, const String& name, const String& version)
+MIDIOutput::MIDIOutput(MIDIAccess* access, unsigned portIndex, ScriptExecutionContext* context, const String& id, const String& manufacturer, const String& name, const String& version)
: MIDIPort(context, id, manufacturer, name, MIDIPortTypeOutput, version)
+ , m_access(access)
+ , m_portIndex(portIndex)
{
ScriptWrappable::init(this);
}
void MIDIOutput::send(Uint8Array* data, double timestamp)
{
- // FIXME: Implement MIDI protocol validation here. System exclusive
- // messages must be checked at the same time.
- // Actual sending operation will be implemented in core/platform/midi.
+ if (!data)
+ return;
+
+ m_access->sendMIDIData(m_portIndex, data->data(), data->length(), timestamp);
}
-void MIDIOutput::send(Vector<unsigned>, double timestamp)
+void MIDIOutput::send(Vector<unsigned> unsignedData, double timestamp)
{
- // FIXME: Ditto. Implementation will be shared between these two send
- // functions.
+ RefPtr<Uint8Array> array = Uint8Array::create(unsignedData.size());
+
+ for (size_t i = 0; i < unsignedData.size(); ++i) {
+ // FIXME: see if spec should throw an exception if unsigned value is out of bounds.
+ unsigned char value = unsignedData[i] & 0xff;
+ array->set(i, value);
+ }
+
+ m_access->sendMIDIData(m_portIndex, array->data(), array->length(), timestamp);
}
} // namespace WebCore
« Source/modules/webmidi/MIDIAccess.cpp ('K') | « Source/modules/webmidi/MIDIOutput.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698