Fixed poll() behaviour for direct plugins, also added snd_pcm_hwsync() call to start callback

This commit is contained in:
Jaroslav Kysela 2004-01-21 19:21:11 +00:00
parent bf978c3ff2
commit c508b496b4
4 changed files with 15 additions and 5 deletions

View file

@ -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;
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);
events = pfds[0].revents;
if (events & POLLIN) {
events |= POLLOUT;
events &= ~POLLIN;
int empty = 0;
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 */
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;
return 0;

View file

@ -407,7 +407,6 @@ static int snd_pcm_dmix_sync_ptr(snd_pcm_t *pcm)
}
dmix->hw_ptr += diff;
dmix->hw_ptr %= pcm->boundary;
// printf("sync ptr diff = %li\n", diff);
if (pcm->stop_threshold >= pcm->boundary) /* don't care */
return 0;
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)
return err;
dmix->state = SND_PCM_STATE_RUNNING;
snd_pcm_hwsync(dmix->spcm);
dmix->slave_appl_ptr = dmix->slave_hw_ptr = *dmix->spcm->hw.ptr;
avail = snd_pcm_mmap_playback_hw_avail(pcm);
if (avail < 0)

View file

@ -292,6 +292,7 @@ static int snd_pcm_dshare_start(snd_pcm_t *pcm)
if (err < 0)
return err;
dshare->state = SND_PCM_STATE_RUNNING;
snd_pcm_hwsync(dshare->spcm);
dshare->slave_appl_ptr = dshare->slave_hw_ptr = *dshare->spcm->hw.ptr;
avail = snd_pcm_mmap_playback_hw_avail(pcm);
if (avail < 0)

View file

@ -274,6 +274,7 @@ static int snd_pcm_dsnoop_start(snd_pcm_t *pcm)
if (err < 0)
return err;
dsnoop->state = SND_PCM_STATE_RUNNING;
snd_pcm_hwsync(dsnoop->spcm);
dsnoop->slave_appl_ptr = dsnoop->slave_hw_ptr = *dsnoop->spcm->hw.ptr;
gettimeofday(&tv, 0);
dsnoop->trigger_tstamp.tv_sec = tv.tv_sec;