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