Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Minor: Added system message for empty mod list. (#4546)
- Minor: Added `/lowtrust` command to open the suspicious user activity feed in browser. (#4542)
- 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 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)
Expand Down
20 changes: 20 additions & 0 deletions src/controllers/sound/SoundController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,26 @@ void SoundController::play(const QUrl &sound)
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())
{
auto soundPath = sound.toLocalFile();
Expand Down