Add support for sound backends & some miniaudio changes (#4978)
Miniaudio now runs everything in a separate audio thread - this uses boost::asio's io_context. Our miniaudio implementation is now also much simplified - it does not use its own resource manager or device. This might end up being stupid if sounds don't work after changing output device or locking or w/e I've made the sound controller into an interface, meaning we can support multiple sound backends in Chatterino. I've added a Null sound backend that disables all sound. A QMediaPlayer or QSoundEffect or Qt backend could be added. Miniaudio might idle & disable the device now too, not sure I've added some unrelated changes in the form of a new setting type, and a new setting page helper function for it, which will hopefully make adding new enum settings easier in the future. This setting stores its value as a string instead of an int, and uses magic_enum to convert between that string value and its enum value.
This commit is contained in:
+37
-2
@@ -10,12 +10,14 @@
|
||||
#include "controllers/hotkeys/HotkeyController.hpp"
|
||||
#include "controllers/ignores/IgnoreController.hpp"
|
||||
#include "controllers/notifications/NotificationController.hpp"
|
||||
#include "controllers/sound/ISoundController.hpp"
|
||||
#include "providers/seventv/SeventvAPI.hpp"
|
||||
#include "singletons/ImageUploader.hpp"
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
# include "controllers/plugins/PluginController.hpp"
|
||||
#endif
|
||||
#include "controllers/sound/SoundController.hpp"
|
||||
#include "controllers/sound/MiniaudioBackend.hpp"
|
||||
#include "controllers/sound/NullBackend.hpp"
|
||||
#include "controllers/twitch/LiveController.hpp"
|
||||
#include "controllers/userdata/UserDataController.hpp"
|
||||
#include "debug/AssertInGuiThread.hpp"
|
||||
@@ -57,6 +59,34 @@
|
||||
|
||||
#include <atomic>
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace chatterino;
|
||||
|
||||
ISoundController *makeSoundController(Settings &settings)
|
||||
{
|
||||
SoundBackend soundBackend = settings.soundBackend;
|
||||
switch (soundBackend)
|
||||
{
|
||||
case SoundBackend::Miniaudio: {
|
||||
return new MiniaudioBackend();
|
||||
}
|
||||
break;
|
||||
|
||||
case SoundBackend::Null: {
|
||||
return new NullBackend();
|
||||
}
|
||||
break;
|
||||
|
||||
default: {
|
||||
return new MiniaudioBackend();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
static std::atomic<bool> isAppInitialized{false};
|
||||
@@ -92,7 +122,7 @@ Application::Application(Settings &_settings, Paths &_paths)
|
||||
, ffzBadges(&this->emplace<FfzBadges>())
|
||||
, seventvBadges(&this->emplace<SeventvBadges>())
|
||||
, userData(&this->emplace<UserDataController>())
|
||||
, sound(&this->emplace<SoundController>())
|
||||
, sound(&this->emplace<ISoundController>(makeSoundController(_settings)))
|
||||
, twitchLiveController(&this->emplace<TwitchLiveController>())
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
, plugins(&this->emplace<PluginController>())
|
||||
@@ -260,6 +290,11 @@ IUserDataController *Application::getUserData()
|
||||
return this->userData;
|
||||
}
|
||||
|
||||
ISoundController *Application::getSound()
|
||||
{
|
||||
return this->sound;
|
||||
}
|
||||
|
||||
ITwitchLiveController *Application::getTwitchLiveController()
|
||||
{
|
||||
return this->twitchLiveController;
|
||||
|
||||
Reference in New Issue
Block a user