Restart the sound device if it's been stopped (#4549)

Fixes a bug where we don't check if the sound device is active before trying to play a sound to it

We fix this by checking its state before every sound we try to play, and if the device is not in the started state we try to restart it.
This commit is contained in:
pajlada 2023-04-16 13:16:12 +02:00 committed by GitHub
parent d6ef48d4ef
commit 8124ab439c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View file

@ -13,6 +13,7 @@
- Minor: Added system message for empty mod list. (#4546) - Minor: Added system message for empty mod list. (#4546)
- Minor: Added `/lowtrust` command to open the suspicious user activity feed in browser. (#4542) - Minor: Added `/lowtrust` command to open the suspicious user activity feed in browser. (#4542)
- Minor: Migrated badges to Helix API. (#4537) - Minor: Migrated badges to Helix API. (#4537)
- Bugfix: Fixed an issue where Chatterino could lose track of the sound device in certain scenarios. (#4549)
- Bugfix: Fixed an issue where animated emotes would render on top of zero-width emotes. (#4314) - Bugfix: Fixed an issue where animated emotes would render on top of zero-width emotes. (#4314)
- Bugfix: Fixed an issue where it was difficult to hover a zero-width emote. (#4314) - Bugfix: Fixed an issue where it was difficult to hover a zero-width emote. (#4314)
- Bugfix: Fixed an issue where context-menu items for zero-width emotes displayed the wrong provider. (#4460) - Bugfix: Fixed an issue where context-menu items for zero-width emotes displayed the wrong provider. (#4460)

View file

@ -190,6 +190,26 @@ void SoundController::play(const QUrl &sound)
return; return;
} }
auto deviceState = ma_device_get_state(this->device.get());
if (deviceState != ma_device_state_started)
{
// Device state is not as it should be, try to restart it
qCWarning(chatterinoSound)
<< "Sound device was not started, attempting to restart it"
<< deviceState;
auto result = ma_device_start(this->device.get());
if (result != MA_SUCCESS)
{
qCWarning(chatterinoSound)
<< "Failed to start the sound device" << result;
return;
}
qCInfo(chatterinoSound) << "Successfully restarted the sound device";
}
if (sound.isLocalFile()) if (sound.isLocalFile())
{ {
auto soundPath = sound.toLocalFile(); auto soundPath = sound.toLocalFile();