summaryrefslogtreecommitdiff
path: root/libs/backends
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-04-28 03:28:34 +0200
committerRobin Gareus <robin@gareus.org>2020-04-28 03:28:34 +0200
commitd3d120fa281134735fc4b113d0bcd7e4e1929ea9 (patch)
treee3ae74952bfc85103dd24956ab7fe1fd6f58cf8f /libs/backends
parent13ed8da2bca65f41dc2dca008502596ac2c538be (diff)
Prepare to allow using ALSA backend with nperiods > 3
This will still need an update for Alsa_pcmi::set_hwpar() capture channel (which is fixed at 2, unless FRAG_NEAR is used).
Diffstat (limited to 'libs/backends')
-rw-r--r--libs/backends/alsa/alsa_audiobackend.cc27
1 files changed, 23 insertions, 4 deletions
diff --git a/libs/backends/alsa/alsa_audiobackend.cc b/libs/backends/alsa/alsa_audiobackend.cc
index 7dec3eb738..6c931b08cb 100644
--- a/libs/backends/alsa/alsa_audiobackend.cc
+++ b/libs/backends/alsa/alsa_audiobackend.cc
@@ -270,8 +270,27 @@ std::vector<uint32_t>
AlsaAudioBackend::available_period_sizes (const std::string& driver) const
{
std::vector<uint32_t> ps;
- ps.push_back (2);
- ps.push_back (3);
+
+ ALSADeviceInfo *nfo = NULL;
+ if (device == get_standard_device_name(DeviceNone)) {
+ return ps;
+ }
+ if (device == _output_audio_device && _output_audio_device_info.valid) {
+ nfo = &_output_audio_device_info;
+ } else {
+ ps.push_back (2);
+ return ps;
+ }
+
+ if (nfo->min_nper == 2) {
+ ps.push_back (2);
+ if (nfo->max_nper >= 3) {
+ ps.push_back (3);
+ }
+ } else {
+ ps.push_back (nfo->min_nper);
+ }
+
return ps;
}
@@ -370,7 +389,7 @@ AlsaAudioBackend::set_sample_rate (float sr)
int
AlsaAudioBackend::set_peridod_size (uint32_t n)
{
- if (n == 0 || n > 3) {
+ if (n == 0) {
return -1;
}
if (_run) {
@@ -830,7 +849,7 @@ AlsaAudioBackend::_start (bool for_latency_measurement)
(duplex & 1) ? alsa_device.c_str() : NULL,
/* ctrl name */ 0,
_samplerate, _samples_per_period,
- _periods_per_cycle, /* _periods_per_cycle */ 2,
+ _periods_per_cycle, /* capture p/c */ 2,
/* debug */ 0);
AudioBackend::ErrorCode error_code = NoError;