mirror of https://github.com/ericonr/sndio.git
fix premature onmove() call-backs
This commit is contained in:
parent
280f58c39a
commit
8e377687b9
|
@ -973,6 +973,12 @@ sio_alsa_onmove(struct sio_alsa_hdl *hdl)
|
|||
{
|
||||
int delta;
|
||||
|
||||
if (hdl->sio.mode & SIO_PLAY)
|
||||
DPRINTF("ostate = %d\n", snd_pcm_state(hdl->opcm));
|
||||
if (hdl->sio.mode & SIO_REC)
|
||||
DPRINTF("istate = %d\n", snd_pcm_state(hdl->ipcm));
|
||||
|
||||
if (hdl->running) {
|
||||
switch (hdl->sio.mode & (SIO_PLAY | SIO_REC)) {
|
||||
case SIO_PLAY:
|
||||
delta = hdl->odelta;
|
||||
|
@ -981,13 +987,16 @@ sio_alsa_onmove(struct sio_alsa_hdl *hdl)
|
|||
delta = hdl->idelta;
|
||||
break;
|
||||
case SIO_PLAY | SIO_REC:
|
||||
delta = hdl->odelta > hdl->idelta ? hdl->odelta : hdl->idelta;
|
||||
delta = hdl->odelta > hdl->idelta ?
|
||||
hdl->odelta : hdl->idelta;
|
||||
break;
|
||||
}
|
||||
if (delta < 0)
|
||||
return;
|
||||
if (delta == 0 && hdl->running)
|
||||
if (delta <= 0)
|
||||
return;
|
||||
} else {
|
||||
delta = 0;
|
||||
hdl->running = 1;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
hdl->cpos += delta;
|
||||
if (sndio_debug >= 1)
|
||||
|
@ -1022,10 +1031,8 @@ sio_alsa_pollfd(struct sio_hdl *sh, struct pollfd *pfd, int events)
|
|||
if ((events & POLLOUT) && (hdl->sio.mode & SIO_PLAY) &&
|
||||
hdl->sio.started) {
|
||||
if (!hdl->running &&
|
||||
snd_pcm_state(hdl->opcm) == SND_PCM_STATE_RUNNING) {
|
||||
snd_pcm_state(hdl->opcm) == SND_PCM_STATE_RUNNING)
|
||||
sio_alsa_onmove(hdl);
|
||||
hdl->running = 1;
|
||||
}
|
||||
hdl->onfds = snd_pcm_poll_descriptors(hdl->opcm,
|
||||
pfd, hdl->nfds);
|
||||
if (hdl->onfds < 0) {
|
||||
|
@ -1038,10 +1045,8 @@ sio_alsa_pollfd(struct sio_hdl *sh, struct pollfd *pfd, int events)
|
|||
if ((events & POLLIN) && (hdl->sio.mode & SIO_REC) &&
|
||||
hdl->sio.started) {
|
||||
if (!hdl->running &&
|
||||
snd_pcm_state(hdl->ipcm) == SND_PCM_STATE_RUNNING) {
|
||||
snd_pcm_state(hdl->ipcm) == SND_PCM_STATE_RUNNING)
|
||||
sio_alsa_onmove(hdl);
|
||||
hdl->running = 1;
|
||||
}
|
||||
hdl->infds = snd_pcm_poll_descriptors(hdl->ipcm,
|
||||
pfd + hdl->onfds, hdl->nfds - hdl->onfds);
|
||||
if (hdl->infds < 0) {
|
||||
|
@ -1150,6 +1155,11 @@ sio_alsa_revents(struct sio_hdl *sh, struct pollfd *pfd)
|
|||
hdl->idelta += iused - hdl->iused;
|
||||
hdl->iused = iused;
|
||||
}
|
||||
if (hdl->running ||
|
||||
((hdl->sio.mode & SIO_PLAY) &&
|
||||
ostate == SND_PCM_STATE_RUNNING) ||
|
||||
((hdl->sio.mode & SIO_REC) &&
|
||||
istate == SND_PCM_STATE_RUNNING))
|
||||
sio_alsa_onmove(hdl);
|
||||
}
|
||||
if ((hdl->sio.mode & SIO_PLAY) && !sio_alsa_wsil(hdl))
|
||||
|
|
Loading…
Reference in New Issue