mirror of
https://github.com/shadps4-emu/ext-SDL.git
synced 2024-11-24 02:29:43 +00:00
audio: Handle non-power-of-two spec.samples when unsupported
Fixes #3685
This commit is contained in:
parent
d21a18c65f
commit
90b86b132a
@ -1413,6 +1413,19 @@ open_audio_device(const char *devname, int iscapture,
|
||||
}
|
||||
}
|
||||
|
||||
/* For backends that require a power-of-two value for spec.samples, take the
|
||||
* value we got from 'desired' and round up to the nearest value
|
||||
*/
|
||||
if (!current_audio.impl.SupportsNonPow2Samples && device->spec.samples > 0) {
|
||||
device->spec.samples -= 1;
|
||||
device->spec.samples |= device->spec.samples >> 1;
|
||||
device->spec.samples |= device->spec.samples >> 2;
|
||||
device->spec.samples |= device->spec.samples >> 4;
|
||||
device->spec.samples |= device->spec.samples >> 8;
|
||||
device->spec.samples |= device->spec.samples >> 16;
|
||||
device->spec.samples += 1;
|
||||
}
|
||||
|
||||
if (current_audio.impl.OpenDevice(device, devname) < 0) {
|
||||
close_audio_device(device);
|
||||
return 0;
|
||||
|
@ -88,6 +88,7 @@ typedef struct SDL_AudioDriverImpl
|
||||
SDL_bool OnlyHasDefaultOutputDevice;
|
||||
SDL_bool OnlyHasDefaultCaptureDevice;
|
||||
SDL_bool AllowsArbitraryDeviceNames;
|
||||
SDL_bool SupportsNonPow2Samples;
|
||||
} SDL_AudioDriverImpl;
|
||||
|
||||
|
||||
|
@ -1009,6 +1009,7 @@ ALSA_Init(SDL_AudioDriverImpl * impl)
|
||||
impl->FlushCapture = ALSA_FlushCapture;
|
||||
|
||||
impl->HasCaptureSupport = SDL_TRUE;
|
||||
impl->SupportsNonPow2Samples = SDL_TRUE;
|
||||
|
||||
return SDL_TRUE; /* this audio target is available. */
|
||||
}
|
||||
|
@ -1173,6 +1173,7 @@ COREAUDIO_Init(SDL_AudioDriverImpl * impl)
|
||||
|
||||
impl->ProvidesOwnCallbackThread = SDL_TRUE;
|
||||
impl->HasCaptureSupport = SDL_TRUE;
|
||||
impl->SupportsNonPow2Samples = SDL_TRUE;
|
||||
|
||||
return SDL_TRUE; /* this audio target is available. */
|
||||
}
|
||||
|
@ -668,6 +668,7 @@ DSOUND_Init(SDL_AudioDriverImpl * impl)
|
||||
impl->GetDefaultAudioInfo = DSOUND_GetDefaultAudioInfo;
|
||||
|
||||
impl->HasCaptureSupport = SDL_TRUE;
|
||||
impl->SupportsNonPow2Samples = SDL_TRUE;
|
||||
|
||||
return SDL_TRUE; /* this audio target is available. */
|
||||
}
|
||||
|
@ -195,6 +195,7 @@ DISKAUDIO_Init(SDL_AudioDriverImpl * impl)
|
||||
|
||||
impl->AllowsArbitraryDeviceNames = SDL_TRUE;
|
||||
impl->HasCaptureSupport = SDL_TRUE;
|
||||
impl->SupportsNonPow2Samples = SDL_TRUE;
|
||||
|
||||
return SDL_TRUE; /* this audio target is available. */
|
||||
}
|
||||
|
@ -1417,6 +1417,7 @@ PIPEWIRE_Init(SDL_AudioDriverImpl *impl)
|
||||
|
||||
impl->HasCaptureSupport = SDL_TRUE;
|
||||
impl->ProvidesOwnCallbackThread = SDL_TRUE;
|
||||
impl->SupportsNonPow2Samples = SDL_TRUE;
|
||||
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
@ -945,6 +945,7 @@ PULSEAUDIO_Init(SDL_AudioDriverImpl * impl)
|
||||
impl->GetDefaultAudioInfo = PULSEAUDIO_GetDefaultAudioInfo;
|
||||
|
||||
impl->HasCaptureSupport = SDL_TRUE;
|
||||
impl->SupportsNonPow2Samples = SDL_TRUE;
|
||||
|
||||
return SDL_TRUE; /* this audio target is available. */
|
||||
}
|
||||
|
@ -617,6 +617,7 @@ WASAPI_Init(SDL_AudioDriverImpl * impl)
|
||||
impl->Deinitialize = WASAPI_Deinitialize;
|
||||
impl->GetDefaultAudioInfo = WASAPI_GetDefaultAudioInfo;
|
||||
impl->HasCaptureSupport = SDL_TRUE;
|
||||
impl->SupportsNonPow2Samples = SDL_TRUE;
|
||||
|
||||
return SDL_TRUE; /* this audio target is available. */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user