Add flag to allow ALSA backend to fall back to nearest avail. nperiods
This commit is contained in:
parent
30a60f45df
commit
13ed8da2bc
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user