mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-28 05:40:23 -04:00
Added sync_ptr callback
This commit is contained in:
parent
c508b496b4
commit
819a85fb2c
5 changed files with 7 additions and 8 deletions
|
|
@ -418,6 +418,7 @@ int snd_pcm_direct_poll_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned in
|
|||
events = pfds[0].revents;
|
||||
if (events & POLLIN) {
|
||||
int empty = 0;
|
||||
dmix->sync_ptr(pcm);
|
||||
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
|
||||
events |= POLLOUT;
|
||||
events &= ~POLLIN;
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ struct snd_pcm_direct {
|
|||
snd_pcm_uframes_t avail_max;
|
||||
snd_pcm_uframes_t slave_appl_ptr;
|
||||
snd_pcm_uframes_t slave_hw_ptr;
|
||||
int (*sync_ptr)(snd_pcm_t *pcm);
|
||||
snd_pcm_state_t state;
|
||||
snd_htimestamp_t trigger_tstamp;
|
||||
int server, client;
|
||||
|
|
|
|||
|
|
@ -386,8 +386,6 @@ static int snd_pcm_dmix_sync_ptr(snd_pcm_t *pcm)
|
|||
snd_pcm_sframes_t diff;
|
||||
|
||||
switch (snd_pcm_state(dmix->spcm)) {
|
||||
case SND_PCM_STATE_SUSPENDED:
|
||||
return -ESTRPIPE;
|
||||
case SND_PCM_STATE_DISCONNECTED:
|
||||
dmix->state = -ENOTTY;
|
||||
return -ENOTTY;
|
||||
|
|
@ -839,6 +837,7 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
|
|||
pcm->private_data = dmix;
|
||||
dmix->state = SND_PCM_STATE_OPEN;
|
||||
dmix->slowptr = slowptr;
|
||||
dmix->sync_ptr = snd_pcm_dmix_sync_ptr;
|
||||
|
||||
if (first_instance) {
|
||||
ret = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
|
||||
|
|
|
|||
|
|
@ -133,8 +133,6 @@ static int snd_pcm_dshare_sync_ptr(snd_pcm_t *pcm)
|
|||
snd_pcm_sframes_t diff;
|
||||
|
||||
switch (snd_pcm_state(dshare->spcm)) {
|
||||
case SND_PCM_STATE_SUSPENDED:
|
||||
return -ESTRPIPE;
|
||||
case SND_PCM_STATE_DISCONNECTED:
|
||||
dshare->state = SNDRV_PCM_STATE_DISCONNECTED;
|
||||
return -ENOTTY;
|
||||
|
|
@ -597,6 +595,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
|
|||
pcm->private_data = dshare;
|
||||
dshare->state = SND_PCM_STATE_OPEN;
|
||||
dshare->slowptr = slowptr;
|
||||
dshare->sync_ptr = snd_pcm_dshare_sync_ptr;
|
||||
|
||||
if (first_instance) {
|
||||
ret = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
|
||||
|
|
|
|||
|
|
@ -108,15 +108,13 @@ static void snd_pcm_dsnoop_sync_area(snd_pcm_t *pcm, snd_pcm_uframes_t slave_hw_
|
|||
/*
|
||||
* synchronize hardware pointer (hw_ptr) with ours
|
||||
*/
|
||||
static snd_pcm_sframes_t snd_pcm_dsnoop_sync_ptr(snd_pcm_t *pcm)
|
||||
static int snd_pcm_dsnoop_sync_ptr(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_direct_t *dsnoop = pcm->private_data;
|
||||
snd_pcm_uframes_t slave_hw_ptr, old_slave_hw_ptr, avail;
|
||||
snd_pcm_sframes_t diff;
|
||||
|
||||
switch (snd_pcm_state(dsnoop->spcm)) {
|
||||
case SND_PCM_STATE_SUSPENDED:
|
||||
return -ESTRPIPE;
|
||||
case SND_PCM_STATE_DISCONNECTED:
|
||||
dsnoop->state = SNDRV_PCM_STATE_DISCONNECTED;
|
||||
return -ENOTTY;
|
||||
|
|
@ -151,7 +149,7 @@ static snd_pcm_sframes_t snd_pcm_dsnoop_sync_ptr(snd_pcm_t *pcm)
|
|||
}
|
||||
if (avail > dsnoop->avail_max)
|
||||
dsnoop->avail_max = avail;
|
||||
return diff;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -557,6 +555,7 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name,
|
|||
pcm->private_data = dsnoop;
|
||||
dsnoop->state = SND_PCM_STATE_OPEN;
|
||||
dsnoop->slowptr = slowptr;
|
||||
dsnoop->sync_ptr = snd_pcm_dsnoop_sync_ptr;
|
||||
|
||||
if (first_instance) {
|
||||
ret = snd_pcm_open_slave(&spcm, root, sconf, stream, mode);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue