40 static const std::array<unsigned, 13> rates{8000, 11025, 16000, 22050, 32000, 44100, 48000,
41 88200, 96000, 176400, 192000, 352800, 384000};
50 std::vector<double> out;
53 auto in_range = [&](
unsigned r) {
return r >= caps.
rate_min && r <= caps.
rate_max; };
55 std::vector<unsigned> picked;
70 std::sort(picked.begin(), picked.end());
71 picked.erase(std::unique(picked.begin(), picked.end()), picked.end());
72 out.reserve(picked.size());
73 for (
unsigned r : picked)
74 out.push_back(
static_cast<double>(r));
82 unsigned periods_per_buffer = 2) {
86 if (periods_per_buffer == 0)
87 periods_per_buffer = 1;
88 auto fits = [&](
unsigned long p) {
89 if (p < caps.period_min || p > caps.
period_max)
95 for (
unsigned long p = 16; p <= 16384; p *= 2) {
97 out.push_back(
static_cast<int>(p));
100 out.push_back(
static_cast<int>(caps.
period_min));
108 std::set_intersection(a.begin(), a.end(), b.begin(), b.end(), std::back_inserter(out));
127 const std::optional<PcmCapabilities>& capture) {
128 auto usable = [](
const std::optional<PcmCapabilities>& c) {
129 return c && c->channels_max > 0 && c->channels_min <= c->channels_max;
131 const bool has_play = usable(
playback);
132 const bool has_cap = usable(capture);
135 if (!has_play && !has_cap) {
139 out.
buffer_sizes = {64, 128, 256, 512, 1024, 2048, 4096};
146 if (has_play && has_cap) {
152 const auto& only = has_play ? *
playback : *capture;
std::vector< T > intersect_sorted(const std::vector< T > &a, const std::vector< T > &b)
Definition pcm_capabilities.hpp:106
Definition analyzer_provider.hpp:12
std::vector< int > buffer_sizes_from(const PcmCapabilities &caps, unsigned periods_per_buffer=2)
Callback buffer sizes (frames), ascending: the powers of two inside the driver's period range such th...
Definition pcm_capabilities.hpp:81
std::vector< double > sample_rates_from(const PcmCapabilities &caps)
Sample rates the device supports, ascending.
Definition pcm_capabilities.hpp:49
PcmDeviceSummary summarize_pcm_capabilities(const std::optional< PcmCapabilities > &playback, const std::optional< PcmCapabilities > &capture)
Summarise the probed directions.
Definition pcm_capabilities.hpp:126
const std::array< unsigned, 13 > & standard_sample_rates()
Rates worth offering when a driver reports a continuous range.
Definition pcm_capabilities.hpp:39
Definition audio_renderer.hpp:20
What one direction (playback or capture) of a device can do.
Definition pcm_capabilities.hpp:20
unsigned channels_min
Definition pcm_capabilities.hpp:28
std::vector< unsigned > accepted_rates
Rates the driver confirmed one by one.
Definition pcm_capabilities.hpp:25
unsigned rate_max
Definition pcm_capabilities.hpp:22
unsigned long period_max
Definition pcm_capabilities.hpp:33
unsigned long period_min
Frames per callback the driver will accept.
Definition pcm_capabilities.hpp:32
unsigned long buffer_max
Largest total buffer in frames; 0 when the driver gives no bound.
Definition pcm_capabilities.hpp:35
unsigned rate_min
Definition pcm_capabilities.hpp:21
bool rates_tested
Definition pcm_capabilities.hpp:26
unsigned channels_max
Definition pcm_capabilities.hpp:29
The lists and channel counts a DeviceInfo carries for one device.
Definition pcm_capabilities.hpp:114
std::vector< double > sample_rates
Definition pcm_capabilities.hpp:115
std::vector< int > buffer_sizes
Definition pcm_capabilities.hpp:116
int max_input_channels
Definition pcm_capabilities.hpp:117
int max_output_channels
Definition pcm_capabilities.hpp:118