mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #2698 from janisozaur/audio-device
Skip "Default sound device" on Linux
This commit is contained in:
commit
c6ab870404
|
@ -78,18 +78,26 @@ void audio_populate_devices()
|
||||||
if (gAudioDeviceCount <= 0)
|
if (gAudioDeviceCount <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gAudioDeviceCount++;
|
audio_device *systemAudioDevices = malloc(gAudioDeviceCount * sizeof(audio_device));
|
||||||
gAudioDevices = malloc(gAudioDeviceCount * sizeof(audio_device));
|
for (int i = 0; i < gAudioDeviceCount; i++) {
|
||||||
safe_strncpy(gAudioDevices[0].name, language_get_string(5510), AUDIO_DEVICE_NAME_SIZE);
|
const char *utf8Name = SDL_GetAudioDeviceName(i, SDL_FALSE);
|
||||||
|
|
||||||
for (int i = 1; i < gAudioDeviceCount; i++) {
|
|
||||||
const char *utf8Name = SDL_GetAudioDeviceName(i - 1, SDL_FALSE);
|
|
||||||
if (utf8Name == NULL)
|
if (utf8Name == NULL)
|
||||||
utf8Name = language_get_string(5511);
|
utf8Name = language_get_string(5511);
|
||||||
|
|
||||||
safe_strncpy(gAudioDevices[i].name, utf8Name, AUDIO_DEVICE_NAME_SIZE);
|
safe_strncpy(systemAudioDevices[i].name, utf8Name, AUDIO_DEVICE_NAME_SIZE);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#ifndef __linux__
|
||||||
|
gAudioDeviceCount++;
|
||||||
|
gAudioDevices = malloc(gAudioDeviceCount * sizeof(audio_device));
|
||||||
|
safe_strncpy(gAudioDevices[0].name, language_get_string(5510), AUDIO_DEVICE_NAME_SIZE);
|
||||||
|
memcpy(&gAudioDevices[1], systemAudioDevices, (gAudioDeviceCount - 1) * sizeof(audio_device));
|
||||||
|
#else
|
||||||
|
gAudioDevices = malloc(gAudioDeviceCount * sizeof(audio_device));
|
||||||
|
memcpy(gAudioDevices, systemAudioDevices, gAudioDeviceCount * sizeof(audio_device));
|
||||||
|
#endif // __linux__
|
||||||
|
|
||||||
|
free(systemAudioDevices);
|
||||||
|
}
|
||||||
|
|
||||||
int audio_play_sound_panned(int soundId, int pan, sint16 x, sint16 y, sint16 z)
|
int audio_play_sound_panned(int soundId, int pan, sint16 x, sint16 y, sint16 z)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1316,9 +1316,11 @@ static void window_options_invalidate(rct_window *w)
|
||||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = STR_SOUND_NONE;
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = STR_SOUND_NONE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
#ifndef __linux__
|
||||||
if (currentSoundDevice == 0)
|
if (currentSoundDevice == 0)
|
||||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = 5510;
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = 5510;
|
||||||
else
|
else
|
||||||
|
#endif // __linux__
|
||||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = 1170;
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = 1170;
|
||||||
|
|
||||||
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 2, uint32) = (uint32)gAudioDevices[currentSoundDevice].name;
|
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 2, uint32) = (uint32)gAudioDevices[currentSoundDevice].name;
|
||||||
|
|
Loading…
Reference in New Issue