mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-02 09:01:48 -05:00
pcm direct plugins: drain() call might be blocked when threads are used
Add SETUP state checks and do modifications according latest ALSA driver (passing wrong event identification). ALSA bug#4914 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
7fd0d9f423
commit
b9dbee694a
5 changed files with 20 additions and 14 deletions
|
|
@ -540,7 +540,6 @@ void snd_pcm_direct_clear_timer_queue(snd_pcm_direct_t *dmix)
|
|||
int snd_pcm_direct_timer_stop(snd_pcm_direct_t *dmix)
|
||||
{
|
||||
snd_timer_stop(dmix->timer);
|
||||
snd_pcm_direct_clear_timer_queue(dmix);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -567,6 +566,7 @@ int snd_pcm_direct_poll_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned in
|
|||
switch (snd_pcm_state(dmix->spcm)) {
|
||||
case SND_PCM_STATE_XRUN:
|
||||
case SND_PCM_STATE_SUSPENDED:
|
||||
case SND_PCM_STATE_SETUP:
|
||||
events |= POLLERR;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -577,6 +577,7 @@ int snd_pcm_direct_poll_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned in
|
|||
switch (snd_pcm_state(pcm)) {
|
||||
case SND_PCM_STATE_XRUN:
|
||||
case SND_PCM_STATE_SUSPENDED:
|
||||
case SND_PCM_STATE_SETUP:
|
||||
events |= POLLERR;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -1126,8 +1127,9 @@ int snd_pcm_direct_initialize_poll_fd(snd_pcm_direct_t *dmix)
|
|||
snd_timer_poll_descriptors(dmix->timer, &dmix->timer_fd, 1);
|
||||
dmix->poll_fd = dmix->timer_fd.fd;
|
||||
|
||||
dmix->timer_event_suspend = 1<<SND_TIMER_EVENT_MSUSPEND;
|
||||
dmix->timer_event_resume = 1<<SND_TIMER_EVENT_MRESUME;
|
||||
dmix->timer_events = (1<<SND_TIMER_EVENT_MSUSPEND) |
|
||||
(1<<SND_TIMER_EVENT_MRESUME) |
|
||||
(1<<SND_TIMER_EVENT_STOP);
|
||||
|
||||
/*
|
||||
* Some hacks for older kernel drivers
|
||||
|
|
@ -1146,9 +1148,15 @@ int snd_pcm_direct_initialize_poll_fd(snd_pcm_direct_t *dmix)
|
|||
* suspend/resume events.
|
||||
*/
|
||||
if (ver < SNDRV_PROTOCOL_VERSION(2, 0, 5)) {
|
||||
dmix->timer_event_suspend = 1<<SND_TIMER_EVENT_MPAUSE;
|
||||
dmix->timer_event_resume = 1<<SND_TIMER_EVENT_MCONTINUE;
|
||||
dmix->timer_events &= ~((1<<SND_TIMER_EVENT_MSUSPEND) |
|
||||
(1<<SND_TIMER_EVENT_MRESUME));
|
||||
dmix->timer_events |= (1<<SND_TIMER_EVENT_MPAUSE) |
|
||||
(1<<SND_TIMER_EVENT_MCONTINUE);
|
||||
}
|
||||
/* In older versions, use SND_TIMER_EVENT_START too.
|
||||
*/
|
||||
if (ver < SNDRV_PROTOCOL_VERSION(2, 0, 6))
|
||||
dmix->timer_events |= 1<<SND_TIMER_EVENT_START;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1275,8 +1283,7 @@ int snd_pcm_direct_set_timer_params(snd_pcm_direct_t *dmix)
|
|||
snd_timer_params_set_ticks(params, 1);
|
||||
if (dmix->tread) {
|
||||
filter = (1<<SND_TIMER_EVENT_TICK) |
|
||||
dmix->timer_event_suspend |
|
||||
dmix->timer_event_resume;
|
||||
dmix->timer_events;
|
||||
snd_timer_params_set_filter(params, filter);
|
||||
}
|
||||
ret = snd_timer_params(dmix->timer, params);
|
||||
|
|
|
|||
|
|
@ -142,10 +142,9 @@ struct snd_pcm_direct {
|
|||
int hw_fd; /* hardware file descriptor */
|
||||
struct pollfd timer_fd;
|
||||
int poll_fd;
|
||||
int tread;
|
||||
int timer_need_poll;
|
||||
unsigned int timer_event_suspend;
|
||||
unsigned int timer_event_resume;
|
||||
int tread: 1;
|
||||
int timer_need_poll: 1;
|
||||
unsigned int timer_events;
|
||||
int server_fd;
|
||||
pid_t server_pid;
|
||||
snd_timer_t *timer; /* timer used as poll_fd */
|
||||
|
|
|
|||
|
|
@ -605,8 +605,8 @@ static int snd_pcm_dmix_drop(snd_pcm_t *pcm)
|
|||
snd_pcm_direct_t *dmix = pcm->private_data;
|
||||
if (dmix->state == SND_PCM_STATE_OPEN)
|
||||
return -EBADFD;
|
||||
snd_pcm_direct_timer_stop(dmix);
|
||||
dmix->state = SND_PCM_STATE_SETUP;
|
||||
snd_pcm_direct_timer_stop(dmix);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -355,9 +355,9 @@ static int snd_pcm_dshare_drop(snd_pcm_t *pcm)
|
|||
snd_pcm_direct_t *dshare = pcm->private_data;
|
||||
if (dshare->state == SND_PCM_STATE_OPEN)
|
||||
return -EBADFD;
|
||||
dshare->state = SND_PCM_STATE_SETUP;
|
||||
snd_pcm_direct_timer_stop(dshare);
|
||||
do_silence(pcm);
|
||||
dshare->state = SND_PCM_STATE_SETUP;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -280,8 +280,8 @@ static int snd_pcm_dsnoop_drop(snd_pcm_t *pcm)
|
|||
snd_pcm_direct_t *dsnoop = pcm->private_data;
|
||||
if (dsnoop->state == SND_PCM_STATE_OPEN)
|
||||
return -EBADFD;
|
||||
snd_timer_stop(dsnoop->timer);
|
||||
dsnoop->state = SND_PCM_STATE_SETUP;
|
||||
snd_timer_stop(dsnoop->timer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue