mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-29 01:35:06 +01:00
Fix #4522: Theme music doesn't stop when connected to paused server
Refactor audio initialisation and stop all music and sounds when the screen mode changes.
This commit is contained in:
@@ -121,11 +121,22 @@ void audio_stop_channel(void **channel);
|
||||
void audio_init()
|
||||
{
|
||||
int result = SDL_Init(SDL_INIT_AUDIO);
|
||||
if (result >= 0)
|
||||
if (result < 0) {
|
||||
log_error("SDL_Init %s", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
|
||||
log_fatal("SDL_Init %s", SDL_GetError());
|
||||
exit(-1);
|
||||
if (str_is_null_or_empty(gConfigSound.device)) {
|
||||
Mixer_Init(NULL);
|
||||
gAudioCurrentDevice = 0;
|
||||
} else {
|
||||
Mixer_Init(gConfigSound.device);
|
||||
for (int i = 0; i < gAudioDeviceCount; i++) {
|
||||
if (strcmp(gAudioDevices[i].name, gConfigSound.device) == 0) {
|
||||
gAudioCurrentDevice = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void audio_quit()
|
||||
@@ -296,6 +307,15 @@ void audio_stop_ride_music()
|
||||
}
|
||||
}
|
||||
|
||||
void audio_stop_all_music_and_sounds()
|
||||
{
|
||||
audio_stop_title_music();
|
||||
audio_stop_vehicle_sounds();
|
||||
audio_stop_ride_music();
|
||||
audio_stop_crowd_sound();
|
||||
audio_stop_rain_sound();
|
||||
}
|
||||
|
||||
void audio_stop_crowd_sound()
|
||||
{
|
||||
audio_stop_channel(&gCrowdSoundChannel);
|
||||
|
||||
@@ -281,4 +281,6 @@ void audio_toggle_all_sounds();
|
||||
*/
|
||||
void audio_unpause_sounds();
|
||||
|
||||
void audio_stop_all_music_and_sounds();
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user