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_MIDIMessageQueue_h
8 #define mozilla_dom_MIDIMessageQueue_h
10 #include "mozilla/Mutex.h"
13 // XXX Avoid including this here by moving function implementations to the cpp
15 #include "mozilla/dom/MIDITypes.h"
26 * Since some MIDI Messages can be scheduled to be sent in the future, the
27 * MIDIMessageQueue is responsible for making sure all MIDI messages are
28 * scheduled and sent in order.
30 class MIDIMessageQueue
{
33 ~MIDIMessageQueue() = default;
34 // Adds an array of possibly out-of-order messages to our queue.
35 void Add(nsTArray
<MIDIMessage
>& aMsg
);
36 // Retrieve all pending messages before the time specified.
37 void GetMessagesBefore(TimeStamp aTimestamp
,
38 nsTArray
<MIDIMessage
>& aMsgQueue
);
39 // Get all pending messages.
40 void GetMessages(nsTArray
<MIDIMessage
>& aMsgQueue
);
41 // Erase all pending messages.
43 // Erase all pending messages that would be sent in the future. Useful for
44 // when ports are closed, as we must send all messages with timestamps in the
49 // Array of messages to be sent.
50 nsTArray
<MIDIMessage
> mMessageQueue
;
51 // Mutex for coordinating cross thread array access.
52 Mutex mMutex MOZ_UNANNOTATED
;
56 } // namespace mozilla
58 #endif // mozilla_dom_MIDIMessageQueue_h