mirror of
https://github.com/Ryujinx/libsoundio.git
synced 2024-12-22 22:45:28 +00:00
WASAPI: shared mode devices support any sample rate
This commit is contained in:
parent
c420bf9e71
commit
ba65bdb131
|
@ -29,7 +29,7 @@ behavior on every platform.
|
|||
* Supports optimal usage of each supported backend. The same API does the
|
||||
right thing whether the backend has a fixed buffer size, such as on JACK and
|
||||
CoreAudio, or whether it allows directly managing the buffer, such as on
|
||||
ALSA or PulseAudio.
|
||||
ALSA, PulseAudio, and WASAPI.
|
||||
* C library. Depends only on the respective backend API libraries and libc.
|
||||
Does *not* depend on libstdc++, and does *not* have exceptions, run-time type
|
||||
information, or [setjmp](http://latentcontent.net/2007/12/05/libpng-worst-api-ever/).
|
||||
|
@ -251,7 +251,6 @@ view `coverage/index.html` in a browser.
|
|||
|
||||
0. implement WASAPI (Windows) backend, get examples working
|
||||
- list devices
|
||||
- buffer duration
|
||||
- raw mode
|
||||
- watching
|
||||
- sine wave
|
||||
|
|
|
@ -358,6 +358,7 @@ struct SoundIoDevice {
|
|||
// are used. You may check that the current backend is PulseAudio and
|
||||
// ignore these min/max values.
|
||||
// For JACK and CoreAudio, buffer duration and period duration are the same.
|
||||
// For WASAPI, buffer duration is unknown.
|
||||
double buffer_duration_min;
|
||||
double buffer_duration_max;
|
||||
double buffer_duration_current;
|
||||
|
|
|
@ -367,8 +367,8 @@ static void set_all_device_sample_rates(SoundIoDevice *device) {
|
|||
SoundIoDevicePrivate *dev = (SoundIoDevicePrivate *)device;
|
||||
device->sample_rate_count = 1;
|
||||
device->sample_rates = &dev->prealloc_sample_rate_range;
|
||||
device->sample_rates[0].min = 8000;
|
||||
device->sample_rates[0].max = 5644800;
|
||||
device->sample_rates[0].min = SOUNDIO_MIN_SAMPLE_RATE;
|
||||
device->sample_rates[0].max = SOUNDIO_MAX_SAMPLE_RATE;
|
||||
}
|
||||
|
||||
static int set_all_device_channel_layouts(SoundIoDevice *device) {
|
||||
|
|
|
@ -296,8 +296,8 @@ static void sink_info_callback(pa_context *pulse_context, const pa_sink_info *in
|
|||
// some reasonable min and max values.
|
||||
device->sample_rate_count = 1;
|
||||
device->sample_rates = &dev->prealloc_sample_rate_range;
|
||||
device->sample_rates[0].min = min(8000, device->sample_rate_current);
|
||||
device->sample_rates[0].max = max(5644800, device->sample_rate_current);
|
||||
device->sample_rates[0].min = min(SOUNDIO_MIN_SAMPLE_RATE, device->sample_rate_current);
|
||||
device->sample_rates[0].max = max(SOUNDIO_MAX_SAMPLE_RATE, device->sample_rate_current);
|
||||
|
||||
device->current_format = from_pulseaudio_format(info->sample_spec);
|
||||
// PulseAudio performs sample format conversion, so any PulseAudio
|
||||
|
|
|
@ -169,5 +169,7 @@ struct SoundIoDevicePrivate {
|
|||
|
||||
void soundio_destroy_devices_info(struct SoundIoDevicesInfo *devices_info);
|
||||
|
||||
static const int SOUNDIO_MIN_SAMPLE_RATE = 8000;
|
||||
static const int SOUNDIO_MAX_SAMPLE_RATE = 5644800;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -353,11 +353,13 @@ static int refresh_devices(SoundIoPrivate *si) {
|
|||
deinit_refresh_devices(&rd);
|
||||
return SoundIoErrorOpeningDevice;
|
||||
}
|
||||
rd.device->sample_rate_current = rd.wave_format->Format.nSamplesPerSec;
|
||||
// WASAPI performs resampling in shared mode, so any value is valid.
|
||||
// Let's pick some reasonable min and max values.
|
||||
rd.device->sample_rate_count = 1;
|
||||
rd.device->sample_rates = &dev->prealloc_sample_rate_range;
|
||||
rd.device->sample_rate_current = rd.wave_format->Format.nSamplesPerSec;
|
||||
rd.device->sample_rates[0].min = rd.device->sample_rate_current;
|
||||
rd.device->sample_rates[0].max = rd.device->sample_rate_current;
|
||||
rd.device->sample_rates[0].min = min(SOUNDIO_MIN_SAMPLE_RATE, rd.device->sample_rate_current);
|
||||
rd.device->sample_rates[0].max = max(SOUNDIO_MAX_SAMPLE_RATE, rd.device->sample_rate_current);
|
||||
|
||||
rd.device->current_format = from_wave_format_format(rd.wave_format);
|
||||
rd.device->format_count = 1;
|
||||
|
|
Loading…
Reference in a new issue