Index: Source/modules/webmidi/MIDIInput.cpp |
diff --git a/Source/modules/webmidi/MIDIInput.cpp b/Source/modules/webmidi/MIDIInput.cpp |
index 45da45e39b8ac4e5cc3e3584de1e75edfc0726e7..68317d04edce5c95dd3e6759c775d5b592c5884e 100644 |
--- a/Source/modules/webmidi/MIDIInput.cpp |
+++ b/Source/modules/webmidi/MIDIInput.cpp |
@@ -50,6 +50,20 @@ MIDIInput::MIDIInput(MIDIAccess* access, const String& id, const String& manufac |
{ |
} |
+EventListener* MIDIInput::onmidimessage() |
+{ |
+ return getAttributeEventListener(EventTypeNames::midimessage); |
+} |
+ |
+void MIDIInput::setOnmidimessage(PassRefPtr<EventListener> listener) |
+{ |
+ // Implicit open. It does nothing if the port is already opened. |
+ // See http://www.w3.org/TR/webmidi/#widl-MIDIPort-open-Promise-MIDIPort |
+ open(); |
+ |
+ setAttributeEventListener(EventTypeNames::midimessage, listener); |
+} |
+ |
void MIDIInput::didReceiveMIDIData(unsigned portIndex, const unsigned char* data, size_t length, double timeStamp) |
{ |
ASSERT(isMainThread()); |
@@ -57,6 +71,9 @@ void MIDIInput::didReceiveMIDIData(unsigned portIndex, const unsigned char* data |
if (!length) |
return; |
+ if (getConnection() != ConnectionStateOpen) |
+ return; |
+ |
// Drop sysex message here when the client does not request it. Note that this is not a security check but an |
// automatic filtering for clients that do not want sysex message. Also note that sysex message will never be sent |
// unless the current process has an explicit permission to handle sysex message. |