mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-07 12:07:09 +03:00
fixed cspot crash when switching with LMS
This commit is contained in:
@@ -103,6 +103,8 @@ namespace bell
|
|||||||
//delete m_queue.front();
|
//delete m_queue.front();
|
||||||
m_queue.pop();
|
m_queue.pop();
|
||||||
}
|
}
|
||||||
|
lk.unlock();
|
||||||
|
m_cv.notify_one();
|
||||||
}
|
}
|
||||||
/// <summary> Check queue in forced exit state. </summary>
|
/// <summary> Check queue in forced exit state. </summary>
|
||||||
bool isExit() const
|
bool isExit() const
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ private:
|
|||||||
std::map<uint64_t, mercuryCallback> callbacks;
|
std::map<uint64_t, mercuryCallback> callbacks;
|
||||||
std::mutex reconnectionMutex;
|
std::mutex reconnectionMutex;
|
||||||
std::mutex runningMutex;
|
std::mutex runningMutex;
|
||||||
|
std::mutex stopMutex;
|
||||||
std::map<std::string, mercuryCallback> subscriptions;
|
std::map<std::string, mercuryCallback> subscriptions;
|
||||||
std::unique_ptr<Session> session;
|
std::unique_ptr<Session> session;
|
||||||
std::shared_ptr<LoginBlob> lastAuthBlob;
|
std::shared_ptr<LoginBlob> lastAuthBlob;
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ void AudioChunkManager::close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AudioChunkManager::runTask() {
|
void AudioChunkManager::runTask() {
|
||||||
this->isRunning = true;
|
|
||||||
std::scoped_lock lock(this->runningMutex);
|
std::scoped_lock lock(this->runningMutex);
|
||||||
|
this->isRunning = true;
|
||||||
while (isRunning) {
|
while (isRunning) {
|
||||||
std::pair<std::vector<uint8_t>, bool> audioPair;
|
std::pair<std::vector<uint8_t>, bool> audioPair;
|
||||||
if (this->audioChunkDataQueue.wtpop(audioPair, 100)) {
|
if (this->audioChunkDataQueue.wtpop(audioPair, 100)) {
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ MercuryManager::MercuryManager(std::unique_ptr<Session> session): bell::Task("me
|
|||||||
|
|
||||||
bool MercuryManager::timeoutHandler()
|
bool MercuryManager::timeoutHandler()
|
||||||
{
|
{
|
||||||
|
if (!isRunning) return true;
|
||||||
|
|
||||||
auto currentTimestamp = timeProvider->getSyncedTimestamp();
|
auto currentTimestamp = timeProvider->getSyncedTimestamp();
|
||||||
|
|
||||||
if (this->lastRequestTimestamp != -1 && currentTimestamp - this->lastRequestTimestamp > AUDIOCHUNK_TIMEOUT_MS)
|
if (this->lastRequestTimestamp != -1 && currentTimestamp - this->lastRequestTimestamp > AUDIOCHUNK_TIMEOUT_MS)
|
||||||
@@ -161,7 +163,7 @@ void MercuryManager::runTask()
|
|||||||
}
|
}
|
||||||
catch (const std::runtime_error& e)
|
catch (const std::runtime_error& e)
|
||||||
{
|
{
|
||||||
if (!isRunning) break;
|
if (!isRunning) break;
|
||||||
// Reconnection required
|
// Reconnection required
|
||||||
this->reconnect();
|
this->reconnect();
|
||||||
this->reconnectedCallback();
|
this->reconnectedCallback();
|
||||||
@@ -189,10 +191,11 @@ void MercuryManager::runTask()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MercuryManager::stop() {
|
void MercuryManager::stop() {
|
||||||
|
std::scoped_lock stop(this->stopMutex);
|
||||||
CSPOT_LOG(debug, "Stopping mercury manager");
|
CSPOT_LOG(debug, "Stopping mercury manager");
|
||||||
isRunning = false;
|
isRunning = false;
|
||||||
audioChunkManager->close();
|
audioChunkManager->close();
|
||||||
std::scoped_lock lock(audioChunkManager->runningMutex, this->runningMutex);
|
std::scoped_lock lock(this->runningMutex);
|
||||||
CSPOT_LOG(debug, "mercury stopped");
|
CSPOT_LOG(debug, "mercury stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,6 +277,8 @@ void MercuryManager::handleQueue()
|
|||||||
{
|
{
|
||||||
this->updateQueue();
|
this->updateQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::scoped_lock lock(this->stopMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t MercuryManager::execute(MercuryType method, std::string uri, mercuryCallback& callback, mercuryCallback& subscription, mercuryParts& payload)
|
uint64_t MercuryManager::execute(MercuryType method, std::string uri, mercuryCallback& callback, mercuryCallback& subscription, mercuryParts& payload)
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ void SpircController::disconnect(void) {
|
|||||||
player->cancelCurrentTrack();
|
player->cancelCurrentTrack();
|
||||||
state->setActive(false);
|
state->setActive(false);
|
||||||
notify();
|
notify();
|
||||||
sendEvent(CSpotEventType::DISC);
|
// Send the event at the end at it might be a last gasp
|
||||||
|
sendEvent(CSpotEventType::DISC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpircController::playToggle() {
|
void SpircController::playToggle() {
|
||||||
|
|||||||
Reference in New Issue
Block a user