chore: unsingletonize SoundController (#5462)
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/Singleton.hpp"
|
||||
|
||||
#include <QUrl>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class Settings;
|
||||
class Paths;
|
||||
|
||||
enum class SoundBackend {
|
||||
Miniaudio,
|
||||
Null,
|
||||
@@ -17,11 +12,11 @@ enum class SoundBackend {
|
||||
/**
|
||||
* @brief Handles sound loading & playback
|
||||
**/
|
||||
class ISoundController : public Singleton
|
||||
class ISoundController
|
||||
{
|
||||
public:
|
||||
ISoundController() = default;
|
||||
~ISoundController() override = default;
|
||||
virtual ~ISoundController() = default;
|
||||
ISoundController(const ISoundController &) = delete;
|
||||
ISoundController(ISoundController &&) = delete;
|
||||
ISoundController &operator=(const ISoundController &) = delete;
|
||||
|
||||
@@ -68,10 +68,13 @@ namespace chatterino {
|
||||
// NUM_SOUNDS specifies how many simultaneous default ping sounds & decoders to create
|
||||
constexpr const auto NUM_SOUNDS = 4;
|
||||
|
||||
void MiniaudioBackend::initialize(Settings &settings, const Paths &paths)
|
||||
MiniaudioBackend::MiniaudioBackend()
|
||||
: context(std::make_unique<ma_context>())
|
||||
, engine(std::make_unique<ma_engine>())
|
||||
, workGuard(boost::asio::make_work_guard(this->ioContext))
|
||||
, sleepTimer(this->ioContext)
|
||||
{
|
||||
(void)(settings);
|
||||
(void)(paths);
|
||||
qCInfo(chatterinoSound) << "Initializing miniaudio sound backend";
|
||||
|
||||
boost::asio::post(this->ioContext, [this] {
|
||||
ma_result result{};
|
||||
@@ -192,15 +195,6 @@ void MiniaudioBackend::initialize(Settings &settings, const Paths &paths)
|
||||
});
|
||||
}
|
||||
|
||||
MiniaudioBackend::MiniaudioBackend()
|
||||
: context(std::make_unique<ma_context>())
|
||||
, engine(std::make_unique<ma_engine>())
|
||||
, workGuard(boost::asio::make_work_guard(this->ioContext))
|
||||
, sleepTimer(this->ioContext)
|
||||
{
|
||||
qCInfo(chatterinoSound) << "Initializing miniaudio sound backend";
|
||||
}
|
||||
|
||||
MiniaudioBackend::~MiniaudioBackend()
|
||||
{
|
||||
// NOTE: This destructor is never called because the `runGui` function calls _exit before that happens
|
||||
|
||||
@@ -25,8 +25,6 @@ namespace chatterino {
|
||||
**/
|
||||
class MiniaudioBackend : public ISoundController
|
||||
{
|
||||
void initialize(Settings &settings, const Paths &paths) override;
|
||||
|
||||
public:
|
||||
MiniaudioBackend();
|
||||
~MiniaudioBackend() override;
|
||||
|
||||
Reference in New Issue
Block a user