diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 8b747e33..f75fed21 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -135,9 +135,11 @@ The default behaviour is to advertise minimum, preferred and maximum buffer sizes of 1 ms, 20 ms and 1 s, respectively. However, in practice the minimum buffer size will be advertised as 10 ms as long as the (default) DirectSound backend is used and the input device isn't disabled; this is to work around a -[known issue](https://github.com/dechamps/FlexASIO/issues/50) with DirectSound -and small input buffer sizes. The resulting sizes in samples are computed based -on whatever sample rate the driver is set to when the application enquires. +[known issue][issue50] with DirectSound and small input buffer sizes. The +resulting sizes in samples are computed based on whatever sample rate the driver +is set to when the application enquires. In addition, by default, FlexASIO will +not advertise any buffer sizes smaller than 32 samples as that tends to [confuse +some applications][issue88]. ### `[input]` and `[output]` sections @@ -366,6 +368,8 @@ automatic conversion mechanism as the one this option controls.) [device]: #option-device [GUI]: https://en.wikipedia.org/wiki/Graphical_user_interface [INI files]: https://en.wikipedia.org/wiki/INI_file +[issue50]: https://github.com/dechamps/FlexASIO/issues/50 +[issue88]: https://github.com/dechamps/FlexASIO/issues/88 [logging]: README.md#logging [official TOML documentation]: https://github.com/toml-lang/toml#toml [portaudio287]: https://app.assembla.com/spaces/portaudio/tickets/287-wasapi-interprets-a-zero-suggestedlatency-in-surprising-ways diff --git a/src/flexasio/FlexASIO/flexasio.cpp b/src/flexasio/FlexASIO/flexasio.cpp index d54d2b8a..74c4e098 100644 --- a/src/flexasio/FlexASIO/flexasio.cpp +++ b/src/flexasio/FlexASIO/flexasio.cpp @@ -387,12 +387,13 @@ namespace flexasio { } else { Log() << "Calculating default buffer size based on " << sampleRate << " Hz sample rate"; - *minSize = long(sampleRate * (hostApi.info.type == paDirectSound && inputDevice.has_value() ? + // We enforce a minimum of 32 samples as applications tend to choke on extremely small buffers - see https://github.com/dechamps/FlexASIO/issues/88 + *minSize = (std::max)(32, long(sampleRate * (hostApi.info.type == paDirectSound && inputDevice.has_value() ? 0.010 : // Cap the min buffer size to 10 ms when using DirectSound with an input device to work around https://github.com/dechamps/FlexASIO/issues/50 0.001 // 1 ms, there's basically no chance we'll get glitch-free streaming below this - )); - *maxSize = long(sampleRate); // 1 second, more would be silly - *preferredSize = long(sampleRate * 0.02); // 20 ms + ))); + *maxSize = (std::max)(32, long(sampleRate)); // 1 second, more would be silly + *preferredSize = (std::max)(32, long(sampleRate * 0.02)); // 20 ms *granularity = 1; // Don't care } Log() << "Returning: min buffer size " << *minSize << ", max buffer size " << *maxSize << ", preferred buffer size " << *preferredSize << ", granularity " << *granularity;