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

[WIP,DRAFT] Fix disabled Music & sound crash #1050

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vincele
Copy link
Contributor

@vincele vincele commented Mar 2, 2025

Issue is that audio system initialization order was not right and some audio processing was not properly guarded by checks.

More details in the commit message.

Code Changes:

Issues:

  • Not fully tested
    • tested that music enabled in config file plays properly
    • both music & sound disabled don't crash any more

On void-linux x86_64 musl libc, bare ALSA sound system (no pulseaudio, no pipewire, nor jack).

But music disabled & "All Sounds" enabled did not output anything, I don't know if this has been broken or if there are any sounds that should have been played...

Please test under windows, macos, and other linuxes...

Purpose:

@vincele
Copy link
Contributor Author

vincele commented Mar 2, 2025

OK, I tested a bit more and I'm hearing music & laser shooting sounds, also voice communications.

But the two separate settings in config file are now broken, if you enable music, you'll also have sounds.
And if you disable music and enable sounds you get nothing.

But at least the crash is gone...

@vincele vincele changed the title Fix disabled Music & sound crash [WIP] Fix disabled Music & sound crash Mar 2, 2025
@royfalk royfalk requested review from royfalk, stephengtuggy and BenjamenMeyer and removed request for royfalk and stephengtuggy March 2, 2025 14:46
Copy link
Contributor

@stephengtuggy stephengtuggy left a comment

Choose a reason for hiding this comment

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

This looks really good, @vincele . Thanks for the PR. Tentatively approving, pending further testing.

@vincele
Copy link
Contributor Author

vincele commented Mar 3, 2025

I'll keep this as WIP until I understand why the "music off" option also disable the sounds. Either we want a single option or both should be properly working independently.

Copy link
Member

@BenjamenMeyer BenjamenMeyer left a comment

Choose a reason for hiding this comment

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

seems reasonable; let's get this play tested to validate

@vincele vincele force-pushed the fix_nosound_crash branch 3 times, most recently from 72f2440 to 7e63edc Compare March 9, 2025 10:04
Issue is that audio system initialization order was not right and some
audio processing was not properly guarded by checks.

* `AUDInit()` returns a boolean value telling audio system initialization
  status, use that to set `g_game.sound_enabled` which is now used
  everywhere needed. This reflects either failures, or music & sound
  being disabled in the config file.

Then only call the other initialization / close functions:
* `initALRenderer()`
* `Music::InitMuzak()`
* `initSceneManager()`
* `initScenes()`
* `closeRenderer()`
if the audio susbystem has been properly initialized

Then the `initALRenderer()` function does not need to check for the
sound system being enabled.

Call `Music::InitMuzak()` after `initALRenderer()`, not sure if this is
absolutely required, but seemed sensible anyways.

Move the `Music::MuzakCycle()` function out of `bootstrap_draw()` into a
more sensible place in `bootstrap_first_loop()`.

Then guard:
* `Music::MuzakCycle()`
* `muzak->GotoSong()`
with an `if (g_game.sound_enabled)` check.

Remove the FIXME comment in OpenALRenderer.cpp `RendererData::suspend()`
as the exception is not thrown there any more.

Fixes issue: vegastrike#1040
Related issue: vegastrike#859

Signed-off-by: Vincent Legoll <[email protected]>
@vincele vincele force-pushed the fix_nosound_crash branch from 7e63edc to 0f6ac8b Compare March 9, 2025 10:10
@vincele
Copy link
Contributor Author

vincele commented Mar 9, 2025

Still WIP, but slight progress:

  • remove some missed g_game.sound_enabled comment & modification in engine/src/aldrv/al_init.cpp

@vincele vincele changed the title [WIP] Fix disabled Music & sound crash [WIP,DRAFT] Fix disabled Music & sound crash Mar 9, 2025
@stephengtuggy stephengtuggy marked this pull request as draft March 9, 2025 19:48
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.

3 participants