summaryrefslogtreecommitdiff
path: root/libs/ardouralsautil
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/ardouralsautil
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/ardouralsautil')
-rw-r--r--libs/ardouralsautil/ardouralsautil/deviceinfo.h1
-rw-r--r--libs/ardouralsautil/deviceparams.cc19
2 files changed, 7 insertions, 13 deletions
diff --git a/libs/ardouralsautil/ardouralsautil/deviceinfo.h b/libs/ardouralsautil/ardouralsautil/deviceinfo.h
index d0a1b7ec18..e217a0d575 100644
--- a/libs/ardouralsautil/ardouralsautil/deviceinfo.h
+++ b/libs/ardouralsautil/ardouralsautil/deviceinfo.h
@@ -24,6 +24,7 @@ namespace ARDOUR {
struct ALSADeviceInfo {
unsigned int max_channels;
unsigned int min_rate, max_rate;
+ unsigned int min_nper, min_nper;
unsigned long min_size, max_size;
bool valid;
};
diff --git a/libs/ardouralsautil/deviceparams.cc b/libs/ardouralsautil/deviceparams.cc
index 2e9bca95f6..613eac76e0 100644
--- a/libs/ardouralsautil/deviceparams.cc
+++ b/libs/ardouralsautil/deviceparams.cc
@@ -34,7 +34,6 @@ ARDOUR::get_alsa_device_parameters (const char* device_name, const bool play, AL
unsigned long min_psiz, max_psiz;
unsigned long min_bufz, max_bufz;
- unsigned int min_nper, max_nper;
err = snd_pcm_open (&pcm, device_name,
play ? SND_PCM_STREAM_PLAYBACK : SND_PCM_STREAM_CAPTURE,
@@ -91,12 +90,12 @@ ARDOUR::get_alsa_device_parameters (const char* device_name, const bool play, AL
goto error_out;
}
- err = snd_pcm_hw_params_get_periods_min (hw_params, &min_nper, 0);
+ err = snd_pcm_hw_params_get_periods_min (hw_params, &nfo->min_nper, 0);
if (err < 0) {
errmsg = "Cannot get minimum period count";
goto error_out;
}
- err = snd_pcm_hw_params_get_periods_max (hw_params, &max_nper, 0);
+ err = snd_pcm_hw_params_get_periods_max (hw_params, &nfo->max_nper, 0);
if (err < 0) {
errmsg = "Cannot get maximum period count";
goto error_out;
@@ -117,19 +116,13 @@ ARDOUR::get_alsa_device_parameters (const char* device_name, const bool play, AL
fprintf (stdout, " max_psiz : %lu\n", nfo->max_size);
fprintf (stdout, " min_bufz : %lu\n", min_bufz);
fprintf (stdout, " max_bufz : %lu\n", max_bufz);
- fprintf (stdout, " min_nper : %d\n", min_nper);
- fprintf (stdout, " max_nper : %d\n", max_nper);
+ fprintf (stdout, " min_nper : %d\n", nfo->min_nper);
+ fprintf (stdout, " max_nper : %d\n", nfo->max_nper);
fprintf (stdout, " possible : %lu .. %lu\n", nfo->min_size, nfo->max_size);
}
- /* AlsaAudioBackend supports n-periods 2, 3 */
- if (min_nper > 2 || max_nper < 3) {
- errmsg = "Unsupported period count";
- return 1;
- }
-
- nfo->min_size = std::max (min_psiz, min_bufz / 3);
- nfo->max_size = std::min (max_psiz, max_bufz / 2);
+ nfo->min_size = std::max (min_psiz, min_bufz / nfo->max_nper);
+ nfo->max_size = std::min (max_psiz, max_bufz / nfo->min_nper);
nfo->valid = true;
return 0;