PassRefPtrWillBeRawPtr<MIDIAccess> MIDIAccess::create(ExecutionContext* context, MIDIAccessPromise* promise) { RefPtrWillBeRawPtr<MIDIAccess> midiAccess(adoptRefWillBeRefCountedGarbageCollected(new MIDIAccess(context, promise))); midiAccess->suspendIfNeeded(); midiAccess->startRequest(); return midiAccess.release(); }
void MIDIInput::didReceiveMIDIData(unsigned portIndex, const unsigned char* data, size_t length, double timeStamp) { ASSERT(isMainThread()); if (!length) 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. if (data[0] == 0xf0 && !midiAccess()->sysexEnabled()) return; RefPtr<Uint8Array> array = Uint8Array::create(data, length); dispatchEvent(MIDIMessageEvent::create(timeStamp, array)); }