mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-12-19 08:57:08 -05:00
Fixed poll() behaviour for direct plugins, also added snd_pcm_hwsync() call to start callback
This commit is contained in:
parent
bf978c3ff2
commit
c508b496b4
4 changed files with 15 additions and 5 deletions
|
|
@ -410,15 +410,23 @@ int snd_pcm_direct_poll_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned in
|
||||||
{
|
{
|
||||||
snd_pcm_direct_t *dmix = pcm->private_data;
|
snd_pcm_direct_t *dmix = pcm->private_data;
|
||||||
unsigned short events;
|
unsigned short events;
|
||||||
static snd_timer_read_t rbuf[5]; /* can be overwriten by multiple plugins, we don't need the value */
|
/* rbuf might be overwriten by multiple plugins */
|
||||||
|
/* we don't need the value */
|
||||||
|
static snd_timer_read_t rbuf[5];
|
||||||
|
|
||||||
assert(pfds && nfds == 1 && revents);
|
assert(pfds && nfds == 1 && revents);
|
||||||
events = pfds[0].revents;
|
events = pfds[0].revents;
|
||||||
if (events & POLLIN) {
|
if (events & POLLIN) {
|
||||||
events |= POLLOUT;
|
int empty = 0;
|
||||||
events &= ~POLLIN;
|
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
|
||||||
|
events |= POLLOUT;
|
||||||
|
events &= ~POLLIN;
|
||||||
|
empty = snd_pcm_mmap_playback_avail(pcm) < pcm->avail_min;
|
||||||
|
} else {
|
||||||
|
empty = snd_pcm_mmap_capture_avail(pcm) < pcm->avail_min;
|
||||||
|
}
|
||||||
/* empty the timer read queue */
|
/* empty the timer read queue */
|
||||||
while (snd_timer_read(dmix->timer, &rbuf, sizeof(rbuf)) == sizeof(rbuf)) ;
|
while (empty && snd_timer_read(dmix->timer, &rbuf, sizeof(rbuf)) == sizeof(rbuf)) ;
|
||||||
}
|
}
|
||||||
*revents = events;
|
*revents = events;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -407,7 +407,6 @@ static int snd_pcm_dmix_sync_ptr(snd_pcm_t *pcm)
|
||||||
}
|
}
|
||||||
dmix->hw_ptr += diff;
|
dmix->hw_ptr += diff;
|
||||||
dmix->hw_ptr %= pcm->boundary;
|
dmix->hw_ptr %= pcm->boundary;
|
||||||
// printf("sync ptr diff = %li\n", diff);
|
|
||||||
if (pcm->stop_threshold >= pcm->boundary) /* don't care */
|
if (pcm->stop_threshold >= pcm->boundary) /* don't care */
|
||||||
return 0;
|
return 0;
|
||||||
if ((avail = snd_pcm_mmap_playback_avail(pcm)) >= pcm->stop_threshold) {
|
if ((avail = snd_pcm_mmap_playback_avail(pcm)) >= pcm->stop_threshold) {
|
||||||
|
|
@ -545,6 +544,7 @@ static int snd_pcm_dmix_start(snd_pcm_t *pcm)
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
dmix->state = SND_PCM_STATE_RUNNING;
|
dmix->state = SND_PCM_STATE_RUNNING;
|
||||||
|
snd_pcm_hwsync(dmix->spcm);
|
||||||
dmix->slave_appl_ptr = dmix->slave_hw_ptr = *dmix->spcm->hw.ptr;
|
dmix->slave_appl_ptr = dmix->slave_hw_ptr = *dmix->spcm->hw.ptr;
|
||||||
avail = snd_pcm_mmap_playback_hw_avail(pcm);
|
avail = snd_pcm_mmap_playback_hw_avail(pcm);
|
||||||
if (avail < 0)
|
if (avail < 0)
|
||||||
|
|
|
||||||
|
|
@ -292,6 +292,7 @@ static int snd_pcm_dshare_start(snd_pcm_t *pcm)
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
dshare->state = SND_PCM_STATE_RUNNING;
|
dshare->state = SND_PCM_STATE_RUNNING;
|
||||||
|
snd_pcm_hwsync(dshare->spcm);
|
||||||
dshare->slave_appl_ptr = dshare->slave_hw_ptr = *dshare->spcm->hw.ptr;
|
dshare->slave_appl_ptr = dshare->slave_hw_ptr = *dshare->spcm->hw.ptr;
|
||||||
avail = snd_pcm_mmap_playback_hw_avail(pcm);
|
avail = snd_pcm_mmap_playback_hw_avail(pcm);
|
||||||
if (avail < 0)
|
if (avail < 0)
|
||||||
|
|
|
||||||
|
|
@ -274,6 +274,7 @@ static int snd_pcm_dsnoop_start(snd_pcm_t *pcm)
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
dsnoop->state = SND_PCM_STATE_RUNNING;
|
dsnoop->state = SND_PCM_STATE_RUNNING;
|
||||||
|
snd_pcm_hwsync(dsnoop->spcm);
|
||||||
dsnoop->slave_appl_ptr = dsnoop->slave_hw_ptr = *dsnoop->spcm->hw.ptr;
|
dsnoop->slave_appl_ptr = dsnoop->slave_hw_ptr = *dsnoop->spcm->hw.ptr;
|
||||||
gettimeofday(&tv, 0);
|
gettimeofday(&tv, 0);
|
||||||
dsnoop->trigger_tstamp.tv_sec = tv.tv_sec;
|
dsnoop->trigger_tstamp.tv_sec = tv.tv_sec;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue