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

Fix for audio problems on Nintendo Switch after resuming from suspend #382

Closed
wants to merge 1 commit into from

Conversation

nusgart
Copy link
Contributor

@nusgart nusgart commented Nov 22, 2023

The problem is that audio becomes "crunchy/laggy" as described in Shipwright issue 3317 (HarbourMasters/Shipwright#3317). The specific fix here is somewhat overbroad and reinitializes SDL audio whenever the application gains focus, but I haven't seen any noticeable side effects.

…o problems

The problem is that audio becomes "crunchy/laggy" as described in Shipwright
issue 3317 (HarbourMasters/Shipwright#3317).  The
specific fix here is somewhat overbroad and reinitializes SDL audio whenever
the application gains focus, but I haven't seen any noticable side effects.
@metronidazole
Copy link

Can this get reviewed/merged?

Copy link
Owner

@Kenix3 Kenix3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SDLAudioPlayer's destructor should then be the one to call SDL_QuitSubSystem(SDL_INIT_AUDIO);

LUS::Switch::ApplyOverclock();
// reinitialize audio subsystem to fix audio problems after resuming from sleep
// see https://github.com/HarbourMasters/Shipwright/issues/3317
LUSLOG_INFO("%s", "restarting SDL audio system to work around audio problems on resume");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LUSLOG_INFO("%s", "restarting SDL audio system to work around audio problems on resume");
SPDLOG_INFO("restarting SDL audio system to work around audio problems on resume");

Comment on lines +175 to +176
SDL_QuitSubSystem(SDL_INIT_AUDIO);
LUS::Context::GetInstance()->GetAudio()->GetAudioPlayer()->Init();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SDL_QuitSubSystem(SDL_INIT_AUDIO);
LUS::Context::GetInstance()->GetAudio()->GetAudioPlayer()->Init();
LUS::Context::GetInstance()->GetAudio()->SetAudioBackend(AudioBackend::SDL);

@briaguya-ai
Copy link
Collaborator

@nusgart Thank you so much for this PR! In order to get this into the next SoH bugfix release it needed to point to the 1.x branch, so I went ahead and made #388 to address @Kenix3's comments and get it onto that branch.

I made sure to list you as a co-author on the commit so you will still have credit in the git history.

Thanks again for figuring this one out! It's always wonderful to see people coming up with bugfixes!

@nusgart
Copy link
Contributor Author

nusgart commented Nov 30, 2023

@briaguya-ai No problem, I've been busy with work for the past few days, so thank you for getting this resolved. Honestly, I just wanted the problem fixed and just implemented the suggestions in the linked issue (actually it might have been in one of the dupes). The credit is appreciated but it would have been fine either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants