Skip to content

Commit

Permalink
Fix PCM plug-in ALSA HW params constraints
Browse files Browse the repository at this point in the history
Current PCM plug-in code results in very strange buffer and period size
selections if the application sets period size before buffer size. This
simple fix corrects that issue. There does not appear to be any clue in
the ALSA docs as to why the period size max needs to be so high, but
looking at other IO plug-in examples they all appear to set the max
period to at least 1MB and in testing this change always gives sensible
values for both period and buffer sizes.

Closes #458
  • Loading branch information
borine authored and arkq committed Jun 11, 2021
1 parent be1d3bb commit 95eb25d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/asound/bluealsa-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,11 @@ static int bluealsa_set_hw_constraint(struct bluealsa_pcm *pcm) {
snd_pcm_format_physical_width(get_snd_pcm_format(pcm->ba_pcm.format)) / 8;

if ((err = snd_pcm_ioplug_set_param_minmax(io, SND_PCM_IOPLUG_HW_PERIOD_BYTES,
min_p, 1024 * 16)) < 0)
min_p, 1024 * 1024)) < 0)
return err;

if ((err = snd_pcm_ioplug_set_param_minmax(io, SND_PCM_IOPLUG_HW_BUFFER_BYTES,
2 * min_p, 2 * 1024 * 1024)) < 0)
return err;

if ((err = snd_pcm_ioplug_set_param_minmax(io, SND_PCM_IOPLUG_HW_CHANNELS,
Expand Down

0 comments on commit 95eb25d

Please sign in to comment.