mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-01 22:58:49 -04:00
Implement missing htimestamp callbacks
Implemented the missing htimestamp callbacks for ioplug, rate and null plugins.
This commit is contained in:
parent
77849672cd
commit
91fc64cefb
5 changed files with 50 additions and 20 deletions
|
|
@ -266,6 +266,28 @@ int snd_pcm_generic_htimestamp(snd_pcm_t *pcm, snd_pcm_uframes_t *avail,
|
||||||
return snd_pcm_htimestamp(generic->slave, avail, tstamp);
|
return snd_pcm_htimestamp(generic->slave, avail, tstamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* stand-alone version - similar like snd_pcm_hw_htimestamp but
|
||||||
|
* taking the tstamp via gettimestamp().
|
||||||
|
*/
|
||||||
|
int snd_pcm_generic_real_htimestamp(snd_pcm_t *pcm, snd_pcm_uframes_t *avail,
|
||||||
|
snd_htimestamp_t *tstamp)
|
||||||
|
{
|
||||||
|
snd_pcm_sframes_t avail1;
|
||||||
|
int ok = 0;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
avail1 = snd_pcm_avail_update(pcm);
|
||||||
|
if (avail1 < 0)
|
||||||
|
return avail1;
|
||||||
|
if (ok && (snd_pcm_uframes_t)avail1 == *avail)
|
||||||
|
break;
|
||||||
|
*avail = avail1;
|
||||||
|
gettimestamp(tstamp, pcm->monotonic);
|
||||||
|
ok = 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int snd_pcm_generic_mmap(snd_pcm_t *pcm)
|
int snd_pcm_generic_mmap(snd_pcm_t *pcm)
|
||||||
{
|
{
|
||||||
if (pcm->mmap_shadow) {
|
if (pcm->mmap_shadow) {
|
||||||
|
|
|
||||||
|
|
@ -139,5 +139,7 @@ snd_pcm_sframes_t snd_pcm_generic_mmap_commit(snd_pcm_t *pcm,
|
||||||
snd_pcm_sframes_t snd_pcm_generic_avail_update(snd_pcm_t *pcm);
|
snd_pcm_sframes_t snd_pcm_generic_avail_update(snd_pcm_t *pcm);
|
||||||
int snd_pcm_generic_htimestamp(snd_pcm_t *pcm, snd_pcm_uframes_t *avail,
|
int snd_pcm_generic_htimestamp(snd_pcm_t *pcm, snd_pcm_uframes_t *avail,
|
||||||
snd_htimestamp_t *timestamp);
|
snd_htimestamp_t *timestamp);
|
||||||
|
int snd_pcm_generic_real_htimestamp(snd_pcm_t *pcm, snd_pcm_uframes_t *avail,
|
||||||
|
snd_htimestamp_t *tstamp);
|
||||||
int snd_pcm_generic_mmap(snd_pcm_t *pcm);
|
int snd_pcm_generic_mmap(snd_pcm_t *pcm);
|
||||||
int snd_pcm_generic_munmap(snd_pcm_t *pcm);
|
int snd_pcm_generic_munmap(snd_pcm_t *pcm);
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
#include "pcm_local.h"
|
#include "pcm_local.h"
|
||||||
#include "pcm_ioplug.h"
|
#include "pcm_ioplug.h"
|
||||||
#include "pcm_ext_parm.h"
|
#include "pcm_ext_parm.h"
|
||||||
|
#include "pcm_generic.h"
|
||||||
|
|
||||||
#ifndef PIC
|
#ifndef PIC
|
||||||
/* entry for static linking */
|
/* entry for static linking */
|
||||||
|
|
@ -636,13 +637,6 @@ static snd_pcm_sframes_t snd_pcm_ioplug_avail_update(snd_pcm_t *pcm)
|
||||||
return (snd_pcm_sframes_t)avail;
|
return (snd_pcm_sframes_t)avail;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_pcm_ioplug_htimestamp(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
|
|
||||||
snd_pcm_uframes_t *avail ATTRIBUTE_UNUSED,
|
|
||||||
snd_htimestamp_t *tstamp ATTRIBUTE_UNUSED)
|
|
||||||
{
|
|
||||||
return -EIO; /* not implemented yet */
|
|
||||||
}
|
|
||||||
|
|
||||||
static int snd_pcm_ioplug_nonblock(snd_pcm_t *pcm, int nonblock)
|
static int snd_pcm_ioplug_nonblock(snd_pcm_t *pcm, int nonblock)
|
||||||
{
|
{
|
||||||
ioplug_priv_t *io = pcm->private_data;
|
ioplug_priv_t *io = pcm->private_data;
|
||||||
|
|
@ -781,7 +775,7 @@ static snd_pcm_fast_ops_t snd_pcm_ioplug_fast_ops = {
|
||||||
.readn = snd_pcm_ioplug_readn,
|
.readn = snd_pcm_ioplug_readn,
|
||||||
.avail_update = snd_pcm_ioplug_avail_update,
|
.avail_update = snd_pcm_ioplug_avail_update,
|
||||||
.mmap_commit = snd_pcm_ioplug_mmap_commit,
|
.mmap_commit = snd_pcm_ioplug_mmap_commit,
|
||||||
.htimestamp = snd_pcm_ioplug_htimestamp,
|
.htimestamp = snd_pcm_generic_real_htimestamp,
|
||||||
.poll_descriptors_count = snd_pcm_ioplug_poll_descriptors_count,
|
.poll_descriptors_count = snd_pcm_ioplug_poll_descriptors_count,
|
||||||
.poll_descriptors = snd_pcm_ioplug_poll_descriptors,
|
.poll_descriptors = snd_pcm_ioplug_poll_descriptors,
|
||||||
.poll_revents = snd_pcm_ioplug_poll_revents,
|
.poll_revents = snd_pcm_ioplug_poll_revents,
|
||||||
|
|
|
||||||
|
|
@ -244,13 +244,6 @@ static snd_pcm_sframes_t snd_pcm_null_avail_update(snd_pcm_t *pcm)
|
||||||
return pcm->buffer_size;
|
return pcm->buffer_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_pcm_null_htimestamp(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
|
|
||||||
snd_pcm_uframes_t *avail ATTRIBUTE_UNUSED,
|
|
||||||
snd_htimestamp_t *tstamp ATTRIBUTE_UNUSED)
|
|
||||||
{
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int snd_pcm_null_hw_refine(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params)
|
static int snd_pcm_null_hw_refine(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params)
|
||||||
{
|
{
|
||||||
int err = snd_pcm_hw_refine_soft(pcm, params);
|
int err = snd_pcm_hw_refine_soft(pcm, params);
|
||||||
|
|
@ -319,7 +312,7 @@ static snd_pcm_fast_ops_t snd_pcm_null_fast_ops = {
|
||||||
.readn = snd_pcm_null_readn,
|
.readn = snd_pcm_null_readn,
|
||||||
.avail_update = snd_pcm_null_avail_update,
|
.avail_update = snd_pcm_null_avail_update,
|
||||||
.mmap_commit = snd_pcm_null_mmap_commit,
|
.mmap_commit = snd_pcm_null_mmap_commit,
|
||||||
.htimestamp = snd_pcm_null_htimestamp,
|
.htimestamp = snd_pcm_generic_real_htimestamp,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1020,11 +1020,30 @@ static snd_pcm_sframes_t snd_pcm_rate_avail_update(snd_pcm_t *pcm)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_pcm_rate_htimestamp(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
|
static int snd_pcm_rate_htimestamp(snd_pcm_t *pcm,
|
||||||
snd_pcm_uframes_t *avail ATTRIBUTE_UNUSED,
|
snd_pcm_uframes_t *avail,
|
||||||
snd_htimestamp_t *tstamp ATTRIBUTE_UNUSED)
|
snd_htimestamp_t *tstamp)
|
||||||
{
|
{
|
||||||
return -EIO; /* not implemented yet */
|
snd_pcm_rate_t *rate = pcm->private_data;
|
||||||
|
snd_pcm_sframes_t avail1;
|
||||||
|
snd_pcm_uframes_t tmp;
|
||||||
|
int ok = 0, err;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
/* the position is from this plugin itself */
|
||||||
|
avail1 = snd_pcm_avail_update(pcm);
|
||||||
|
if (avail1 < 0)
|
||||||
|
return avail1;
|
||||||
|
if (ok && (snd_pcm_uframes_t)avail1 == *avail)
|
||||||
|
break;
|
||||||
|
*avail = avail1;
|
||||||
|
/* timestamp is taken from the slave PCM */
|
||||||
|
err = snd_pcm_htimestamp(rate->gen.slave, &tmp, tstamp);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
ok = 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_pcm_rate_poll_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int nfds, unsigned short *revents)
|
static int snd_pcm_rate_poll_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int nfds, unsigned short *revents)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue