From 07717abdfd64f3ae3e614e4342d94b9812a6118c Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Tue, 14 Jul 2015 23:59:29 +0100 Subject: [PATCH] fix audio initialisation bug when device is not set in config --- src/openrct2.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/openrct2.c b/src/openrct2.c index d912c9921f..3ac3b6eb3d 100644 --- a/src/openrct2.c +++ b/src/openrct2.c @@ -33,9 +33,10 @@ #include "openrct2.h" #include "platform/platform.h" #include "ride/ride.h" -#include "util/sawyercoding.h" -#include "world/mapgen.h" #include "title.h" +#include "util/sawyercoding.h" +#include "util/util.h" +#include "world/mapgen.h" int gOpenRCT2StartupAction = STARTUP_ACTION_TITLE; char gOpenRCT2StartupActionPath[512] = { 0 }; @@ -198,16 +199,19 @@ bool openrct2_initialise() openrct2_copy_original_user_files_over(); - char* devicename = gConfigSound.device; - if (strlen(devicename) == 0) { - devicename = NULL; - } - Mixer_Init(devicename); - for (int i = 0; i < gAudioDeviceCount; i++) { - if (strcmp(gAudioDevices[i].name, gConfigSound.device) == 0) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = i; + // TODO move to audio initialise function + if (str_is_null_or_empty(gConfigSound.device)) { + Mixer_Init(NULL); + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = 0; + } else { + Mixer_Init(gConfigSound.device); + for (int i = 0; i < gAudioDeviceCount; i++) { + if (strcmp(gAudioDevices[i].name, gConfigSound.device) == 0) { + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = i; + } } } + return true; }