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:
pajlada
2023-11-26 22:06:12 +01:00
committed by GitHub
parent 1f09035bfb
commit a240797b68
17 changed files with 578 additions and 360 deletions
+12 -1
View File
@@ -22,6 +22,7 @@ class HighlightController;
class HotkeyController;
class IUserDataController;
class UserDataController;
class ISoundController;
class SoundController;
class ITwitchLiveController;
class TwitchLiveController;
@@ -67,6 +68,7 @@ public:
virtual FfzBadges *getFfzBadges() = 0;
virtual SeventvBadges *getSeventvBadges() = 0;
virtual IUserDataController *getUserData() = 0;
virtual ISoundController *getSound() = 0;
virtual ITwitchLiveController *getTwitchLiveController() = 0;
virtual ImageUploader *getImageUploader() = 0;
virtual SeventvAPI *getSeventvAPI() = 0;
@@ -109,7 +111,7 @@ public:
FfzBadges *const ffzBadges{};
SeventvBadges *const seventvBadges{};
UserDataController *const userData{};
SoundController *const sound{};
ISoundController *const sound{};
private:
TwitchLiveController *const twitchLiveController{};
@@ -172,6 +174,7 @@ public:
return this->seventvBadges;
}
IUserDataController *getUserData() override;
ISoundController *getSound() override;
ITwitchLiveController *getTwitchLiveController() override;
ImageUploader *getImageUploader() override
{
@@ -200,6 +203,14 @@ private:
return *t;
}
template <typename T,
typename = std::enable_if_t<std::is_base_of<Singleton, T>::value>>
T &emplace(T *t)
{
this->singletons_.push_back(std::unique_ptr<T>(t));
return *t;
}
NativeMessagingServer nmServer{};
};