MIDIInput.h (1652B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_MIDIInput_h 8 #define mozilla_dom_MIDIInput_h 9 10 #include "mozilla/dom/MIDIPort.h" 11 12 struct JSContext; 13 14 namespace mozilla::dom { 15 16 class MIDIPortInfo; 17 18 /** 19 * Represents a MIDI Input Port, handles generating incoming message events. 20 * 21 */ 22 class MIDIInput final : public MIDIPort { 23 public: 24 static RefPtr<MIDIInput> Create(nsPIDOMWindowInner* aWindow, 25 MIDIAccess* aMIDIAccessParent, 26 const MIDIPortInfo& aPortInfo, 27 const bool aSysexEnabled); 28 ~MIDIInput() = default; 29 30 JSObject* WrapObject(JSContext* aCx, 31 JS::Handle<JSObject*> aGivenProto) override; 32 33 IMPL_EVENT_HANDLER(midimessage); 34 35 void StateChange() override; 36 void EventListenerAdded(nsAtom* aType) override; 37 void DisconnectFromOwner() override; 38 39 private: 40 explicit MIDIInput(nsPIDOMWindowInner* aWindow); 41 // Takes an array of IPC MIDIMessage objects and turns them into 42 // MIDIMessageEvents, which it then fires. 43 void Receive(const nsTArray<MIDIMessage>& aMsgs) override; 44 45 void KeepAliveOnMidimessage(); 46 void DontKeepAliveOnMidimessage(); 47 48 // If true this object will be kept alive even without direct JS references 49 bool mKeepAlive; 50 }; 51 52 } // namespace mozilla::dom 53 54 #endif // mozilla_dom_MIDIInput_h