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/. */
7 #ifndef mozilla_dom_MIDIPortParent_h
8 #define mozilla_dom_MIDIPortParent_h
10 #include "mozilla/dom/PMIDIPortParent.h"
11 #include "mozilla/dom/MIDIPortBinding.h"
12 #include "mozilla/dom/MIDIPortInterface.h"
14 // Header file contents
15 namespace mozilla::dom
{
18 * Actor representing the parent (PBackground thread) side of a MIDIPort object.
21 class MIDIPortParent final
: public PMIDIPortParent
, public MIDIPortInterface
{
23 NS_INLINE_DECL_REFCOUNTING(MIDIPortParent
);
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
; }
40 ~MIDIPortParent() = default;
41 // Queue of messages that needs to be sent. Since sending a message on a
42 // closed port opens it, we sometimes have to buffer messages from the time
43 // Send() is called until the time we get a device state change to Opened.
44 nsTArray
<MIDIMessage
> mMessageQueue
;
45 const uint32_t mInternalId
;
48 } // namespace mozilla::dom