Skip to content

Commit

Permalink
stop playback when opening preferences
Browse files Browse the repository at this point in the history
to avoid potential problems when changing buffer size, output device, etc.
  • Loading branch information
RomanPudashkin committed Jun 26, 2024
1 parent ec1022f commit af65bb5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/appshell/internal/applicationactioncontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,25 @@ void ApplicationActionController::openAskForHelpPage()
}

void ApplicationActionController::openPreferencesDialog()
{
const context::IPlaybackStatePtr state = globalContext()->playbackState();
if (state->playbackStatus() == audio::PlaybackStatus::Running) {
dispatcher()->dispatch("stop");

async::Channel<audio::PlaybackStatus> statusChanged = state->playbackStatusChanged();
statusChanged.onReceive(this, [statusChanged, this](audio::PlaybackStatus) {
auto statusChangedMut = statusChanged;
statusChangedMut.resetOnReceive(this);
doOpenPreferencesDialog();
});

return;
}

doOpenPreferencesDialog();
}

void ApplicationActionController::doOpenPreferencesDialog()
{
if (multiInstancesProvider()->isPreferencesAlreadyOpened()) {
multiInstancesProvider()->activateWindowWithOpenedPreferences();
Expand Down
3 changes: 3 additions & 0 deletions src/appshell/internal/applicationactioncontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "istartupscenario.h"
#include "iapplication.h"
#include "extensions/iextensioninstaller.h"
#include "context/iglobalcontext.h"

namespace mu::appshell {
class ApplicationActionController : public QObject, public muse::actions::Actionable, public muse::async::Asyncable
Expand All @@ -55,6 +56,7 @@ class ApplicationActionController : public QObject, public muse::actions::Action
muse::Inject<IStartupScenario> startupScenario;
muse::Inject<muse::IApplication> application;
muse::Inject<muse::extensions::IExtensionInstaller> extensionInstaller;
muse::Inject<context::IGlobalContext> globalContext;

public:
void preInit();
Expand Down Expand Up @@ -91,6 +93,7 @@ class ApplicationActionController : public QObject, public muse::actions::Action
void openOnlineHandbookPage();
void openAskForHelpPage();
void openPreferencesDialog();
void doOpenPreferencesDialog();

void revertToFactorySettings();

Expand Down

0 comments on commit af65bb5

Please sign in to comment.