LCOV - code coverage report
Current view: top level - muse/framework/audio/main/internal - transporteventscontroller.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 29 0
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-Studio-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 "transporteventscontroller.h"
      24              : 
      25              : #include "audio/common/audiosanitizer.h"
      26              : #include "rcommand/commandtypes.h"
      27              : 
      28              : using namespace muse::audio;
      29              : using namespace muse::audio::rpc;
      30              : 
      31            0 : void TransportEventsController::init()
      32              : {
      33              :     ONLY_AUDIO_MAIN_THREAD;
      34              : 
      35              :     //! TODO These events are contextual, we need to add context passing here
      36            0 :     channel()->onNotification(rpc::GLOBAL_CTX_ID, MsgCode::TransportEventReceived, [this](const Msg& msg) {
      37              :         ONLY_AUDIO_MAIN_THREAD;
      38              : 
      39            0 :         TransportEvent event;
      40            0 :         IF_ASSERT_FAILED(RpcPacker::unpack(msg.data, event)) {
      41            0 :             return;
      42              :         }
      43              : 
      44            0 :         onEventReceived(event);
      45              :     });
      46            0 : }
      47              : 
      48            0 : void TransportEventsController::deinit()
      49              : {
      50              :     ONLY_AUDIO_MAIN_THREAD;
      51              :     //! TODO These events are contextual, we need to add context passing here
      52            0 :     channel()->onNotification(rpc::GLOBAL_CTX_ID, MsgCode::TransportEventReceived, nullptr);
      53            0 : }
      54              : 
      55            0 : void TransportEventsController::onEventReceived(const TransportEvent& event)
      56              : {
      57              :     ONLY_AUDIO_MAIN_THREAD;
      58              : 
      59            0 :     switch (event.type) {
      60            0 :     case TransportEvent::Type::Play:
      61            0 :         commandDispatcher()->dispatch(rcommand::Command("command://playback/play"));
      62            0 :         break;
      63            0 :     case TransportEvent::Type::Pause:
      64            0 :         commandDispatcher()->dispatch(rcommand::Command("command://playback/pause"));
      65            0 :         break;
      66            0 :     case TransportEvent::Type::Stop:
      67            0 :         commandDispatcher()->dispatch(rcommand::Command("command://playback/stop"));
      68            0 :         break;
      69            0 :     case TransportEvent::Type::Seek:
      70            0 :         if (std::holds_alternative<TransportEvent::SeekData>(event.data)) {
      71            0 :             const secs_t pos = std::get<TransportEvent::SeekData>(event.data).position;
      72            0 :             commandDispatcher()->dispatch(rcommand::Command("command://playback/rewind"), { { "position", Val(pos) } });
      73              :         }
      74            0 :         break;
      75            0 :     case TransportEvent::Type::Unknown:
      76            0 :         break;
      77              :     }
      78            0 : }
        

Generated by: LCOV version 2.0-1