mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -05:00
alsa: get avail, delay, timestamps in a single kernel call
Refactor code to fetch avail, delay and timestamp values in a single call to snd_pcm_status(). The information reported is exactly the same as before, however it is extracted in a more atomic manner to improve timer-based scheduling. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
This commit is contained in:
parent
700cd890a9
commit
635eef9981
4 changed files with 21 additions and 22 deletions
|
|
@ -767,6 +767,7 @@ static void update_smoother(struct userdata *u) {
|
|||
int err;
|
||||
pa_usec_t now1 = 0, now2;
|
||||
snd_pcm_status_t *status;
|
||||
snd_htimestamp_t htstamp = { 0, 0 };
|
||||
|
||||
snd_pcm_status_alloca(&status);
|
||||
|
||||
|
|
@ -775,18 +776,13 @@ static void update_smoother(struct userdata *u) {
|
|||
|
||||
/* Let's update the time smoother */
|
||||
|
||||
if (PA_UNLIKELY((err = pa_alsa_safe_delay(u->pcm_handle, &delay, u->hwbuf_size, &u->source->sample_spec, TRUE)) < 0)) {
|
||||
if (PA_UNLIKELY((err = pa_alsa_safe_delay(u->pcm_handle, status, &delay, u->hwbuf_size, &u->source->sample_spec, TRUE)) < 0)) {
|
||||
pa_log_warn("Failed to get delay: %s", pa_alsa_strerror(err));
|
||||
return;
|
||||
}
|
||||
|
||||
if (PA_UNLIKELY((err = snd_pcm_status(u->pcm_handle, status)) < 0))
|
||||
pa_log_warn("Failed to get timestamp: %s", pa_alsa_strerror(err));
|
||||
else {
|
||||
snd_htimestamp_t htstamp = { 0, 0 };
|
||||
snd_pcm_status_get_htstamp(status, &htstamp);
|
||||
now1 = pa_timespec_load(&htstamp);
|
||||
}
|
||||
snd_pcm_status_get_htstamp(status, &htstamp);
|
||||
now1 = pa_timespec_load(&htstamp);
|
||||
|
||||
/* Hmm, if the timestamp is 0, then it wasn't set and we take the current time */
|
||||
if (now1 <= 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue