Fix audio dialog crash when audio device doesn't exist
This commit is contained in:
parent
56bbfe7586
commit
736813fae1
|
@ -211,17 +211,26 @@ VOID RefreshAudioAdapter()
|
||||||
|
|
||||||
GUID binGUID;
|
GUID binGUID;
|
||||||
|
|
||||||
if (pGUID) {
|
// Check if pGUID doesn't have CB_ERR. (source of cause to crash)
|
||||||
|
if (pGUID != nullptr && pGUID != (LPGUID)CB_ERR) {
|
||||||
binGUID = *pGUID;
|
binGUID = *pGUID;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
binGUID = { 0 };
|
binGUID = { 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
if(binGUID != oldGUID)
|
if(binGUID != oldGUID) {
|
||||||
{
|
|
||||||
g_bHasChanges = TRUE;
|
g_bHasChanges = TRUE;
|
||||||
|
|
||||||
g_XBAudio.SetAudioAdapter(binGUID);
|
g_XBAudio.SetAudioAdapter(binGUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Force save default audio device if selected audo device is invalid.
|
||||||
|
if (pGUID == (LPGUID)CB_ERR) {
|
||||||
|
SendMessage(g_hAudioAdapter, CB_SETCURSEL, 0, 0);
|
||||||
|
g_EmuShared->SetXBAudio(&g_XBAudio);
|
||||||
|
MessageBox(nullptr, "Your selected audio device is invalid,\n"
|
||||||
|
"reverting to default audio device.", "Cxbx-Reloaded", MB_OK | MB_ICONEXCLAMATION);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue