mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-11 13:30:05 -05:00
pcm: introduce pcm_frame_diff and pcm_frame_diff2 helpers
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
a6c8ac0c85
commit
6d06fcc285
4 changed files with 30 additions and 40 deletions
|
|
@ -1170,6 +1170,26 @@ static inline void sw_set_period_event(snd_pcm_sw_params_t *params, int val)
|
|||
|
||||
#define PCMINABORT(pcm) (((pcm)->mode & SND_PCM_ABORT) != 0)
|
||||
|
||||
static inline snd_pcm_sframes_t pcm_frame_diff(snd_pcm_uframes_t ptr1,
|
||||
snd_pcm_uframes_t ptr2,
|
||||
snd_pcm_uframes_t boundary)
|
||||
{
|
||||
if (ptr1 < ptr2)
|
||||
return ptr1 + (boundary - ptr2);
|
||||
else
|
||||
return ptr1 - ptr2;
|
||||
}
|
||||
|
||||
static inline snd_pcm_sframes_t pcm_frame_diff2(snd_pcm_uframes_t ptr1,
|
||||
snd_pcm_uframes_t ptr2,
|
||||
snd_pcm_uframes_t boundary)
|
||||
{
|
||||
snd_pcm_sframes_t r = ptr1 - ptr2;
|
||||
if (r >= (snd_pcm_sframes_t)boundary / 2)
|
||||
return boundary - r;
|
||||
return r;
|
||||
}
|
||||
|
||||
#ifdef THREAD_SAFE_API
|
||||
/*
|
||||
* __snd_pcm_lock() and __snd_pcm_unlock() are used to lock/unlock the plugin
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue