From c8e2d55631b1806552d34a54162bd7dafea4ba1d Mon Sep 17 00:00:00 2001 From: casey langen Date: Sun, 26 Jan 2020 21:33:34 -0800 Subject: [PATCH] Had a couple issues that were preventing a clean shutdown. Seems fine now? --- src/core/audio/PlaybackService.cpp | 1 + src/core/audio/PlaybackService.h | 2 +- src/plugins/server/main.cpp | 11 ++++++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/core/audio/PlaybackService.cpp b/src/core/audio/PlaybackService.cpp index 35e42b2f6..8a5e64330 100755 --- a/src/core/audio/PlaybackService.cpp +++ b/src/core/audio/PlaybackService.cpp @@ -169,6 +169,7 @@ PlaybackService::PlaybackService( PlaybackService::~PlaybackService() { playback::SavePlaybackContext(appPrefs, library, *this); + this->messageQueue.Remove(this); savePreferences(*this, playbackPrefs); this->Stop(); this->ResetRemotes(); diff --git a/src/core/audio/PlaybackService.h b/src/core/audio/PlaybackService.h index 28deabf89..1ef5445f4 100755 --- a/src/core/audio/PlaybackService.h +++ b/src/core/audio/PlaybackService.h @@ -76,7 +76,7 @@ namespace musik { namespace core { namespace audio { musik::core::runtime::IMessageQueue& messageQueue, musik::core::ILibraryPtr library); - ~PlaybackService(); + virtual ~PlaybackService(); /* IMessageTarget */ virtual void ProcessMessage(musik::core::runtime::IMessage &message) override; diff --git a/src/plugins/server/main.cpp b/src/plugins/server/main.cpp index 482b65818..9167d5d77 100644 --- a/src/plugins/server/main.cpp +++ b/src/plugins/server/main.cpp @@ -85,6 +85,7 @@ static class PlaybackRemote : public IPlaybackRemote { void CheckRunningStatus() { if (!thread && context.environment && context.playback && context.prefs && context.metadataProxy) { + this->Start(); thread.reset(new std::thread(std::bind(&PlaybackRemote::ThreadProc, this))); } else if (thread && (!context.environment || !context.playback || !context.prefs || !context.metadataProxy)) { @@ -124,22 +125,22 @@ static class PlaybackRemote : public IPlaybackRemote { private: void ThreadProc() { + httpServer.Wait(); + webSocketServer.Wait(); + } + + void Start() { if (context.prefs->GetBool(prefs::http_server_enabled.c_str(), true)) { httpServer.Start(); } - if (context.prefs->GetBool(prefs::websocket_server_enabled.c_str(), true)) { webSocketServer.Start(); } - - httpServer.Wait(); - webSocketServer.Wait(); } void Stop() { httpServer.Stop(); webSocketServer.Stop(); - if (this->thread) { this->thread->join(); this->thread.reset();