diff options
| author | scatterflower <2956568+scatterflower@users.noreply.github.com> | 2020-08-19 16:40:37 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-19 16:40:37 -0500 |
| commit | 9eb0f53db1ae87058458eae267f2a72e3a0a8091 (patch) | |
| tree | dbf5ccd4d3a70a49cebfb84798e7b2b77583835f /src/aoapplication.cpp | |
| parent | cef0ebc6eb2ac549a5475bee332be35ab7f565fc (diff) | |
Reset BASS when switching devices; drop Qt Multimedia support (#262)
* Allow changing audio device on the fly while in a server
* Use default audio device if device in config doesn't exist
* Automatically change audio device to default when current one is invalid
* Destroy Qt Multimedia support
It was decided that there was not enough attention being given to Qt
Multimedia support to justify its continued maintenance simply as a
libre alternative to BASS. While substantial changes to audio were being
made in 2.8, the Qt Multimedia support code fell behind in disrepair.
It's clear that there is no vested interest in implementing audio
features twice for the sake of licensing.
When it's time to switch to another audio library, it will be done
unilaterally.
* CI: Use BASS for Linux build
Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com>
Diffstat (limited to 'src/aoapplication.cpp')
| -rw-r--r-- | src/aoapplication.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/aoapplication.cpp b/src/aoapplication.cpp index e1e9e7fe..fa58ab84 100644 --- a/src/aoapplication.cpp +++ b/src/aoapplication.cpp @@ -177,3 +177,64 @@ void AOApplication::call_announce_menu(Courtroom *court) AOCaseAnnouncerDialog announcer(nullptr, this, court); announcer.exec(); } + +// Callback for when BASS device is lost +void CALLBACK AOApplication::BASSreset(HSTREAM handle, DWORD channel, + DWORD data, void *user) +{ + doBASSreset(); +} + +void AOApplication::doBASSreset() +{ + BASS_Free(); + BASS_Init(-1, 48000, BASS_DEVICE_LATENCY, nullptr, nullptr); + load_bass_opus_plugin(); +} + +void AOApplication::initBASS() +{ + BASS_Free(); + // Change the default audio output device to be the one the user has given + // in his config.ini file for now. + unsigned int a = 0; + BASS_DEVICEINFO info; + + if (get_audio_output_device() == "default") { + BASS_Init(-1, 48000, BASS_DEVICE_LATENCY, nullptr, nullptr); + load_bass_opus_plugin(); + } + else { + for (a = 0; BASS_GetDeviceInfo(a, &info); a++) { + if (get_audio_output_device() == info.name) { + BASS_SetDevice(a); + BASS_Init(static_cast<int>(a), 48000, BASS_DEVICE_LATENCY, nullptr, + nullptr); + load_bass_opus_plugin(); + qDebug() << info.name << "was set as the default audio output device."; + return; + } + } + BASS_Init(-1, 48000, BASS_DEVICE_LATENCY, nullptr, nullptr); + load_bass_opus_plugin(); + } +} + +#if (defined(_WIN32) || defined(_WIN64)) +void AOApplication::load_bass_opus_plugin() +{ + BASS_PluginLoad("bassopus.dll", 0); +} +#elif (defined(LINUX) || defined(__linux__)) +void AOApplication::load_bass_opus_plugin() +{ + BASS_PluginLoad("libbassopus.so", 0); +} +#elif defined __APPLE__ +void AOApplication::load_bass_opus_plugin() +{ + BASS_PluginLoad("libbassopus.dylib", 0); +} +#else +#error This operating system is unsupported for BASS plugins. +#endif |
