fix: force quit miniaudio thread after 1s (#5896)
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
- Bugfix: Fixed announcements not showing up in mentions tab. (#5857)
|
- Bugfix: Fixed announcements not showing up in mentions tab. (#5857)
|
||||||
- Bugfix: Fixed the reply button showing for inline whispers and announcements. (#5863)
|
- Bugfix: Fixed the reply button showing for inline whispers and announcements. (#5863)
|
||||||
- Bugfix: Fixed suspicious user treatment update messages not being searchable. (#5865)
|
- Bugfix: Fixed suspicious user treatment update messages not being searchable. (#5865)
|
||||||
|
- Bugfix: Ensure miniaudio backend exits even if it doesn't exit cleanly. (#5896)
|
||||||
- Dev: Add initial experimental EventSub support. (#5837, #5895)
|
- Dev: Add initial experimental EventSub support. (#5837, #5895)
|
||||||
- Dev: Highlight checks now use non-capturing groups for the boundaries. (#5784)
|
- Dev: Highlight checks now use non-capturing groups for the boundaries. (#5784)
|
||||||
- Dev: Updated Conan dependencies. (#5776)
|
- Dev: Updated Conan dependencies. (#5776)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#define MINIAUDIO_IMPLEMENTATION
|
#define MINIAUDIO_IMPLEMENTATION
|
||||||
#include <miniaudio.h>
|
#include <miniaudio.h>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QScopeGuard>
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -192,6 +193,10 @@ MiniaudioBackend::MiniaudioBackend()
|
|||||||
});
|
});
|
||||||
|
|
||||||
this->audioThread = std::make_unique<std::thread>([this] {
|
this->audioThread = std::make_unique<std::thread>([this] {
|
||||||
|
auto guard = qScopeGuard([&] {
|
||||||
|
this->stoppedFlag.set();
|
||||||
|
});
|
||||||
|
|
||||||
this->ioContext.run();
|
this->ioContext.run();
|
||||||
});
|
});
|
||||||
renameThread(*this->audioThread, "C2Miniaudio");
|
renameThread(*this->audioThread, "C2Miniaudio");
|
||||||
@@ -218,14 +223,20 @@ MiniaudioBackend::~MiniaudioBackend()
|
|||||||
this->workGuard.reset();
|
this->workGuard.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this->audioThread->joinable())
|
if (!this->audioThread->joinable())
|
||||||
{
|
|
||||||
this->audioThread->join();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
qCWarning(chatterinoSound) << "Audio thread not joinable";
|
qCWarning(chatterinoSound) << "Audio thread not joinable";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->stoppedFlag.waitFor(std::chrono::seconds{1}))
|
||||||
|
{
|
||||||
|
this->audioThread->join();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qCWarning(chatterinoSound) << "Audio thread did not stop within 1 second";
|
||||||
|
this->audioThread->detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MiniaudioBackend::play(const QUrl &sound)
|
void MiniaudioBackend::play(const QUrl &sound)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "controllers/sound/ISoundController.hpp"
|
#include "controllers/sound/ISoundController.hpp"
|
||||||
|
#include "util/OnceFlag.hpp"
|
||||||
#include "util/ThreadGuard.hpp"
|
#include "util/ThreadGuard.hpp"
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
@@ -59,6 +60,7 @@ private:
|
|||||||
boost::asio::executor_work_guard<boost::asio::io_context::executor_type>
|
boost::asio::executor_work_guard<boost::asio::io_context::executor_type>
|
||||||
workGuard;
|
workGuard;
|
||||||
std::unique_ptr<std::thread> audioThread;
|
std::unique_ptr<std::thread> audioThread;
|
||||||
|
OnceFlag stoppedFlag;
|
||||||
boost::asio::steady_timer sleepTimer;
|
boost::asio::steady_timer sleepTimer;
|
||||||
|
|
||||||
bool initialized{false};
|
bool initialized{false};
|
||||||
|
|||||||
Reference in New Issue
Block a user