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_MIDIPortParent_h 8 #define mozilla_dom_MIDIPortParent_h 9 10 #include "mozilla/dom/PMIDIPortParent.h" 11 #include "mozilla/dom/MIDIPortBinding.h" 12 #include "mozilla/dom/MIDIPortInterface.h" 13 14 // Header file contents 15 namespace mozilla { 16 namespace dom { 17 18 /** 19 * Actor representing the parent (PBackground thread) side of a MIDIPort object. 20 * 21 */ 22 class MIDIPortParent final : public PMIDIPortParent, public MIDIPortInterface { 23 public: 24 NS_INLINE_DECL_REFCOUNTING(MIDIPortParent); 25 void ActorDestroy(ActorDestroyReason) override; 26 mozilla::ipc::IPCResult RecvSend(nsTArray<MIDIMessage>&& aMsg); 27 mozilla::ipc::IPCResult RecvOpen(); 28 mozilla::ipc::IPCResult RecvClose(); 29 mozilla::ipc::IPCResult RecvClear(); 30 mozilla::ipc::IPCResult RecvShutdown(); 31 MOZ_IMPLICIT MIDIPortParent(const MIDIPortInfo& aPortInfo, 32 const bool aSysexEnabled); 33 // Sends the current port status to the child actor. May also send message 34 // buffer if required. 35 bool SendUpdateStatus(const MIDIPortDeviceState& aState, 36 const MIDIPortConnectionState& aConnection); GetInternalId()37 uint32_t GetInternalId() const { return mInternalId; } 38 void Teardown(); 39 40 protected: 41 ~MIDIPortParent() = default; 42 // Queue of messages that needs to be sent. Since sending a message on a 43 // closed port opens it, we sometimes have to buffer messages from the time 44 // Send() is called until the time we get a device state change to Opened. 45 nsTArray<MIDIMessage> mMessageQueue; 46 const uint32_t mInternalId; 47 }; 48 } // namespace dom 49 } // namespace mozilla 50 51 #endif 52