mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-12-22 23:46:31 +01:00
- fixed the order of period and buffer size setting.
firstly period then buffer size. this will avoid the problem of rounding.
This commit is contained in:
parent
0cc48a4ef8
commit
9b621eeac4
1 changed files with 10 additions and 10 deletions
|
@ -848,16 +848,8 @@ static void set_params(void)
|
|||
}
|
||||
}
|
||||
rate = hwparams.rate;
|
||||
if (buffer_time == 0 && buffer_frames > 0) {
|
||||
err = snd_pcm_hw_params_set_buffer_size_near(handle, params,
|
||||
&buffer_frames);
|
||||
} else {
|
||||
if (buffer_time == 0)
|
||||
buffer_time = 500000;
|
||||
err = snd_pcm_hw_params_set_buffer_time_near(handle, params,
|
||||
&buffer_time, 0);
|
||||
}
|
||||
assert(err >= 0);
|
||||
if (buffer_time == 0 && buffer_frames == 0)
|
||||
buffer_time = 500000;
|
||||
if (period_time == 0 && period_frames == 0) {
|
||||
if (buffer_time > 0)
|
||||
period_time = buffer_time / 4;
|
||||
|
@ -871,6 +863,14 @@ static void set_params(void)
|
|||
err = snd_pcm_hw_params_set_period_size_near(handle, params,
|
||||
&period_frames, 0);
|
||||
assert(err >= 0);
|
||||
if (buffer_time > 0) {
|
||||
err = snd_pcm_hw_params_set_buffer_time_near(handle, params,
|
||||
&buffer_time, 0);
|
||||
} else {
|
||||
err = snd_pcm_hw_params_set_buffer_size_near(handle, params,
|
||||
&buffer_frames);
|
||||
}
|
||||
assert(err >= 0);
|
||||
err = snd_pcm_hw_params(handle, params);
|
||||
if (err < 0) {
|
||||
error("Unable to install hw params:");
|
||||
|
|
Loading…
Reference in a new issue