chore: unsingletonize SoundController (#5462)
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
- Bugfix: Fixed message history occasionally not loading after a sleep. (#5457)
|
- Bugfix: Fixed message history occasionally not loading after a sleep. (#5457)
|
||||||
- Dev: Update Windows build from Qt 6.5.0 to Qt 6.7.1. (#5420)
|
- Dev: Update Windows build from Qt 6.5.0 to Qt 6.7.1. (#5420)
|
||||||
- Dev: Update vcpkg build Qt from 6.5.0 to 6.7.0, boost from 1.83.0 to 1.85.0, openssl from 3.1.3 to 3.3.0. (#5422)
|
- Dev: Update vcpkg build Qt from 6.5.0 to 6.7.0, boost from 1.83.0 to 1.85.0, openssl from 3.1.3 to 3.3.0. (#5422)
|
||||||
|
- Dev: Unsingletonize `ISoundController`. (#5462)
|
||||||
- Dev: Use Qt's high DPI scaling. (#4868, #5400)
|
- Dev: Use Qt's high DPI scaling. (#4868, #5400)
|
||||||
- Dev: Add doxygen build target. (#5377)
|
- Dev: Add doxygen build target. (#5377)
|
||||||
- Dev: Make printing of strings in tests easier. (#5379)
|
- Dev: Make printing of strings in tests easier. (#5379)
|
||||||
|
|||||||
+3
-2
@@ -136,7 +136,7 @@ Application::Application(Settings &_settings, const Paths &paths,
|
|||||||
, ffzBadges(&this->emplace<FfzBadges>())
|
, ffzBadges(&this->emplace<FfzBadges>())
|
||||||
, seventvBadges(&this->emplace<SeventvBadges>())
|
, seventvBadges(&this->emplace<SeventvBadges>())
|
||||||
, userData(new UserDataController(paths))
|
, userData(new UserDataController(paths))
|
||||||
, sound(&this->emplace<ISoundController>(makeSoundController(_settings)))
|
, sound(makeSoundController(_settings))
|
||||||
, twitchLiveController(&this->emplace<TwitchLiveController>())
|
, twitchLiveController(&this->emplace<TwitchLiveController>())
|
||||||
, twitchPubSub(new PubSub(TWITCH_PUBSUB_URL))
|
, twitchPubSub(new PubSub(TWITCH_PUBSUB_URL))
|
||||||
, twitchBadges(new TwitchBadges)
|
, twitchBadges(new TwitchBadges)
|
||||||
@@ -173,6 +173,7 @@ void Application::fakeDtor()
|
|||||||
this->seventvEmotes.reset();
|
this->seventvEmotes.reset();
|
||||||
// this->twitch.reset();
|
// this->twitch.reset();
|
||||||
this->fonts.reset();
|
this->fonts.reset();
|
||||||
|
this->sound.reset();
|
||||||
this->userData.reset();
|
this->userData.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,7 +436,7 @@ ISoundController *Application::getSound()
|
|||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
|
||||||
return this->sound;
|
return this->sound.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
ITwitchLiveController *Application::getTwitchLiveController()
|
ITwitchLiveController *Application::getTwitchLiveController()
|
||||||
|
|||||||
+1
-1
@@ -161,7 +161,7 @@ private:
|
|||||||
FfzBadges *const ffzBadges{};
|
FfzBadges *const ffzBadges{};
|
||||||
SeventvBadges *const seventvBadges{};
|
SeventvBadges *const seventvBadges{};
|
||||||
std::unique_ptr<UserDataController> userData;
|
std::unique_ptr<UserDataController> userData;
|
||||||
ISoundController *const sound{};
|
std::unique_ptr<ISoundController> sound;
|
||||||
TwitchLiveController *const twitchLiveController{};
|
TwitchLiveController *const twitchLiveController{};
|
||||||
std::unique_ptr<PubSub> twitchPubSub;
|
std::unique_ptr<PubSub> twitchPubSub;
|
||||||
std::unique_ptr<TwitchBadges> twitchBadges;
|
std::unique_ptr<TwitchBadges> twitchBadges;
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Singleton.hpp"
|
|
||||||
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class Settings;
|
|
||||||
class Paths;
|
|
||||||
|
|
||||||
enum class SoundBackend {
|
enum class SoundBackend {
|
||||||
Miniaudio,
|
Miniaudio,
|
||||||
Null,
|
Null,
|
||||||
@@ -17,11 +12,11 @@ enum class SoundBackend {
|
|||||||
/**
|
/**
|
||||||
* @brief Handles sound loading & playback
|
* @brief Handles sound loading & playback
|
||||||
**/
|
**/
|
||||||
class ISoundController : public Singleton
|
class ISoundController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ISoundController() = default;
|
ISoundController() = default;
|
||||||
~ISoundController() override = default;
|
virtual ~ISoundController() = default;
|
||||||
ISoundController(const ISoundController &) = delete;
|
ISoundController(const ISoundController &) = delete;
|
||||||
ISoundController(ISoundController &&) = delete;
|
ISoundController(ISoundController &&) = delete;
|
||||||
ISoundController &operator=(const 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
|
// NUM_SOUNDS specifies how many simultaneous default ping sounds & decoders to create
|
||||||
constexpr const auto NUM_SOUNDS = 4;
|
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);
|
qCInfo(chatterinoSound) << "Initializing miniaudio sound backend";
|
||||||
(void)(paths);
|
|
||||||
|
|
||||||
boost::asio::post(this->ioContext, [this] {
|
boost::asio::post(this->ioContext, [this] {
|
||||||
ma_result result{};
|
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()
|
MiniaudioBackend::~MiniaudioBackend()
|
||||||
{
|
{
|
||||||
// NOTE: This destructor is never called because the `runGui` function calls _exit before that happens
|
// 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
|
class MiniaudioBackend : public ISoundController
|
||||||
{
|
{
|
||||||
void initialize(Settings &settings, const Paths &paths) override;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MiniaudioBackend();
|
MiniaudioBackend();
|
||||||
~MiniaudioBackend() override;
|
~MiniaudioBackend() override;
|
||||||
|
|||||||
Reference in New Issue
Block a user