Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2026 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #include "transporteventsdispatcher.h"
24 :
25 : #include "audio/common/rpc/rpcpacker.h"
26 : #include "audio/common/audiosanitizer.h"
27 :
28 : using namespace muse::audio::engine;
29 : using namespace muse::audio::rpc;
30 :
31 0 : TransportEventsDispatcher::TransportEventsDispatcher()
32 0 : : m_eventsReceived(async::makeOpt()
33 0 : .name("audio::engine::TransportEventsDispatcher::m_eventsReceived")
34 0 : .disableWaitPendingsOnSend())
35 : {
36 0 : }
37 :
38 0 : void TransportEventsDispatcher::init()
39 : {
40 : ONLY_AUDIO_ENGINE_THREAD;
41 :
42 0 : m_eventsReceived.onReceive(this, [this](const TransportEvents& events) {
43 0 : for (const TransportEvent& event : events) {
44 : //! TODO These events are contextual, we need to add context passing here
45 0 : Msg msg = rpc::make_notification(rpc::GLOBAL_CTX_ID, MsgCode::TransportEventReceived, RpcPacker::pack(event));
46 0 : rpcChannel()->send(msg);
47 0 : }
48 0 : });
49 0 : }
50 :
51 0 : void TransportEventsDispatcher::dispatch(const TransportEvents& events)
52 : {
53 : ONLY_AUDIO_PROC_THREAD;
54 :
55 : //! Transfer events to the audio engine thread
56 0 : m_eventsReceived.send(events);
57 0 : }
|