prepare ALSA backend for half-duplex

This commit is contained in:
Robin Gareus 2015-06-14 20:43:29 +02:00
parent 573ec69a9a
commit 94c146c780
2 changed files with 12 additions and 3 deletions

View File

@ -953,8 +953,8 @@ AlsaAudioBackend::register_system_audio_ports()
{
LatencyRange lr;
const int a_ins = _n_inputs > 0 ? _n_inputs : 2;
const int a_out = _n_outputs > 0 ? _n_outputs : 2;
const int a_ins = _n_inputs;
const int a_out = _n_outputs;
/* audio ports */
lr.min = lr.max = (_measure_latency ? 0 : _systemic_audio_input_latency);

View File

@ -270,6 +270,9 @@ int Alsa_pcmi::play_init (snd_pcm_uframes_t len)
const snd_pcm_channel_area_t *a;
int err;
if (!_play_handle) {
return 0;
}
if ((err = snd_pcm_mmap_begin (_play_handle, &a, &_play_offs, &len)) < 0)
{
if (_debug & DEBUG_DATA) fprintf (stderr, "Alsa_pcmi: snd_pcm_mmap_begin(play): %s.\n", snd_strerror (err));
@ -291,6 +294,10 @@ int Alsa_pcmi::capt_init (snd_pcm_uframes_t len)
const snd_pcm_channel_area_t *a;
int err;
if (!_capt_handle) {
return 0;
}
if ((err = snd_pcm_mmap_begin (_capt_handle, &a, &_capt_offs, &len)) < 0)
{
if (_debug & DEBUG_DATA) fprintf (stderr, "Alsa_pcmi: snd_pcm_mmap_begin(capt): %s.\n", snd_strerror (err));
@ -326,12 +333,14 @@ void Alsa_pcmi::capt_chan (int chan, float *dst, int len, int step)
int Alsa_pcmi::play_done (int len)
{
if (!_play_handle) return 0;
return snd_pcm_mmap_commit (_play_handle, _play_offs, len);
}
int Alsa_pcmi::capt_done (int len)
{
if (!_capt_handle) return 0;
return snd_pcm_mmap_commit (_capt_handle, _capt_offs, len);
}
@ -394,7 +403,7 @@ void Alsa_pcmi::initialise (const char *play_name, const char *capt_name, const
}
}
if (! _play_handle || ! _capt_handle) return;
if (! _play_handle && ! _capt_handle) return;
if (ctrl_name)
{