| 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
|
|
|