summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-04-28 02:46:44 +0200
committerRobin Gareus <robin@gareus.org>2020-04-28 02:51:20 +0200
commit13ed8da2bca65f41dc2dca008502596ac2c538be (patch)
tree5ab47e11827509e118f849be3e801e33564332e9 /libs
parent30a60f45df8bdd2444e3578039f3a9887166ea8a (diff)
Add flag to allow ALSA backend to fall back to nearest avail. nperiods
Diffstat (limited to 'libs')
-rw-r--r--libs/backends/alsa/zita-alsa-pcmi.cc29
-rw-r--r--libs/backends/alsa/zita-alsa-pcmi.h3
2 files changed, 24 insertions, 8 deletions
diff --git a/libs/backends/alsa/zita-alsa-pcmi.cc b/libs/backends/alsa/zita-alsa-pcmi.cc
index a35b2b3f03..fe3e0f1a8b 100644
--- a/libs/backends/alsa/zita-alsa-pcmi.cc
+++ b/libs/backends/alsa/zita-alsa-pcmi.cc
@@ -487,8 +487,10 @@ void Alsa_pcmi::initialise (const char *play_name, const char *capt_name, const
if (snd_pcm_hw_params_get_periods (_play_hwpar, &nfrag, &dir) || (nfrag != _play_nfrag) || dir)
{
if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't get requested number of periods for playback.\n");
- _state = -5;
- return;
+ if ((_debug & FRAG_NEAR) == 0) {
+ _state = -5;
+ return;
+ }
}
snd_pcm_hw_params_get_format (_play_hwpar, &_play_format);
@@ -774,11 +776,24 @@ int Alsa_pcmi::set_hwpar (snd_pcm_t *handle, snd_pcm_hw_params_t *hwpar, const
sname, _fsize);
return -4;
}
- if (snd_pcm_hw_params_set_periods (handle, hwpar, nfrag, 0) < 0)
- {
- if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't set %s periods to %u.\n",
- sname, nfrag);
- return -5;
+ if ((_debug & FRAG_NEAR)) {
+ unsigned int nf = nfrag;
+ snd_pcm_hw_params_set_periods_min (handle, hwpar, &nf, NULL);
+ if (nf > nfrag) {
+ nfrag = nf;
+ }
+ if (snd_pcm_hw_params_set_periods_near (handle, hwpar, &nfrag, NULL) < 0) {
+ if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't set %s periods to %u.\n",
+ sname, nfrag);
+ return -5;
+ }
+ } else {
+ if (snd_pcm_hw_params_set_periods (handle, hwpar, nfrag, 0) < 0)
+ {
+ if (_debug & DEBUG_INIT) fprintf (stderr, "Alsa_pcmi: can't set %s periods to %u.\n",
+ sname, nfrag);
+ return -5;
+ }
}
if (snd_pcm_hw_params_set_buffer_size (handle, hwpar, _fsize * nfrag) < 0)
{
diff --git a/libs/backends/alsa/zita-alsa-pcmi.h b/libs/backends/alsa/zita-alsa-pcmi.h
index 48c2396c19..65a1d82d2d 100644
--- a/libs/backends/alsa/zita-alsa-pcmi.h
+++ b/libs/backends/alsa/zita-alsa-pcmi.h
@@ -60,7 +60,8 @@ public:
DEBUG_DATA = 8,
DEBUG_ALL = 15,
FORCE_16B = 256,
- FORCE_2CH = 512
+ FORCE_2CH = 512,
+ FRAG_NEAR = 1024
};
void printinfo (void);