mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-31 22:25:35 -04:00
Remove pause and fix timer initialization in prepare
- Removed broken pause implementations. - Fixed the timer initialization in prepare callback so that poll works again after prepare.
This commit is contained in:
parent
e76bbd74d7
commit
51313cb2dd
5 changed files with 28 additions and 60 deletions
|
|
@ -598,6 +598,7 @@ int snd_pcm_direct_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
|||
err = hw_param_interval_refine_one(params, SND_PCM_HW_PARAM_PERIODS, hw_params);
|
||||
if (err < 0)
|
||||
return err;
|
||||
params->info = dshare->shmptr->s.info;
|
||||
#ifdef REFINE_DEBUG
|
||||
snd_output_puts(log, "DMIX REFINE (end):\n");
|
||||
snd_pcm_hw_params_dump(params, log);
|
||||
|
|
@ -849,7 +850,7 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str
|
|||
dmix->shmptr->s.rate = spcm->rate;
|
||||
dmix->shmptr->s.format = spcm->format;
|
||||
dmix->shmptr->s.boundary = spcm->boundary;
|
||||
dmix->shmptr->s.info = spcm->info & ~(SND_PCM_INFO_PAUSE|SND_PCM_INFO_RESUME);
|
||||
dmix->shmptr->s.info = spcm->info & ~SND_PCM_INFO_PAUSE;
|
||||
dmix->shmptr->s.msbits = spcm->msbits;
|
||||
|
||||
spcm->donot_close = 1;
|
||||
|
|
@ -865,14 +866,12 @@ int snd_pcm_direct_initialize_poll_fd(snd_pcm_direct_t *dmix)
|
|||
{
|
||||
int ret;
|
||||
snd_pcm_info_t *info;
|
||||
snd_timer_params_t *params;
|
||||
char name[128];
|
||||
int capture = dmix->type == SND_PCM_TYPE_DSNOOP ? 1 : 0;
|
||||
|
||||
dmix->tread = 0;
|
||||
dmix->timer_need_poll = 0;
|
||||
snd_pcm_info_alloca(&info);
|
||||
snd_timer_params_alloca(¶ms);
|
||||
ret = snd_pcm_info(dmix->spcm, info);
|
||||
if (ret < 0) {
|
||||
SNDERR("unable to info for slave pcm");
|
||||
|
|
@ -918,14 +917,24 @@ int snd_pcm_direct_initialize_poll_fd(snd_pcm_direct_t *dmix)
|
|||
dmix->timer_need_poll = 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_pcm_direct_set_timer_params(snd_pcm_direct_t *dmix)
|
||||
{
|
||||
snd_timer_params_t *params;
|
||||
int ret;
|
||||
|
||||
snd_timer_params_alloca(¶ms);
|
||||
snd_timer_params_set_auto_start(params, 1);
|
||||
snd_timer_params_set_early_event(params, 1);
|
||||
if (dmix->type != SND_PCM_TYPE_DSNOOP)
|
||||
snd_timer_params_set_early_event(params, 1);
|
||||
snd_timer_params_set_ticks(params, 1);
|
||||
if (dmix->tread)
|
||||
snd_timer_params_set_filter(params, (1<<SND_TIMER_EVENT_TICK)|(1<<SND_TIMER_EVENT_MPAUSE));
|
||||
ret = snd_timer_params(dmix->timer, params);
|
||||
if (ret < 0) {
|
||||
SNDERR("unable to set timer parameters", name);
|
||||
SNDERR("unable to set timer parameters");
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ int snd_pcm_direct_mmap(snd_pcm_t *pcm);
|
|||
int snd_pcm_direct_munmap(snd_pcm_t *pcm);
|
||||
int snd_pcm_direct_timer_stop(snd_pcm_direct_t *dmix);
|
||||
void snd_pcm_direct_clear_timer_queue(snd_pcm_direct_t *dmix);
|
||||
int snd_pcm_direct_set_timer_params(snd_pcm_direct_t *dmix);
|
||||
|
||||
int snd_timer_async(snd_timer_t *timer, int sig, pid_t pid);
|
||||
struct timespec snd_pcm_hw_fast_tstamp(snd_pcm_t *pcm);
|
||||
|
|
|
|||
|
|
@ -415,7 +415,7 @@ static int snd_pcm_dmix_prepare(snd_pcm_t *pcm)
|
|||
dmix->state = SND_PCM_STATE_PREPARED;
|
||||
dmix->appl_ptr = 0;
|
||||
dmix->hw_ptr = 0;
|
||||
return 0;
|
||||
return snd_pcm_direct_set_timer_params(dmix);
|
||||
}
|
||||
|
||||
static int snd_pcm_dmix_reset(snd_pcm_t *pcm)
|
||||
|
|
@ -509,26 +509,9 @@ static int snd_pcm_dmix_drain(snd_pcm_t *pcm)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int snd_pcm_dmix_pause(snd_pcm_t *pcm, int enable)
|
||||
static int snd_pcm_dmix_pause(snd_pcm_t *pcm ATTRIBUTE_UNUSED, int enable ATTRIBUTE_UNUSED)
|
||||
{
|
||||
snd_pcm_direct_t *dmix = pcm->private_data;
|
||||
if (enable) {
|
||||
if (dmix->state == SND_PCM_STATE_RUNNING)
|
||||
snd_pcm_direct_timer_stop(dmix);
|
||||
else if (dmix->state != STATE_RUN_PENDING)
|
||||
return -EBADFD;
|
||||
dmix->state = SND_PCM_STATE_PAUSED;
|
||||
} else {
|
||||
if (dmix->state != SND_PCM_STATE_PAUSED)
|
||||
return -EBADFD;
|
||||
if (snd_pcm_mmap_playback_hw_avail(pcm) > 0) {
|
||||
dmix->state = SND_PCM_STATE_RUNNING;
|
||||
/* FIXME: sync the hwptr */
|
||||
snd_timer_start(dmix->timer);
|
||||
} else
|
||||
dmix->state = STATE_RUN_PENDING;
|
||||
}
|
||||
return 0;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static snd_pcm_sframes_t snd_pcm_dmix_rewind(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_uframes_t frames ATTRIBUTE_UNUSED)
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ static int snd_pcm_dshare_prepare(snd_pcm_t *pcm)
|
|||
dshare->state = SND_PCM_STATE_PREPARED;
|
||||
dshare->appl_ptr = 0;
|
||||
dshare->hw_ptr = 0;
|
||||
return 0;
|
||||
return snd_pcm_direct_set_timer_params(dshare);
|
||||
}
|
||||
|
||||
static int snd_pcm_dshare_reset(snd_pcm_t *pcm)
|
||||
|
|
@ -286,12 +286,12 @@ static int snd_pcm_dshare_start(snd_pcm_t *pcm)
|
|||
|
||||
if (dshare->state != SND_PCM_STATE_PREPARED)
|
||||
return -EBADFD;
|
||||
snd_pcm_hwsync(dshare->spcm);
|
||||
dshare->slave_appl_ptr = dshare->slave_hw_ptr = *dshare->spcm->hw.ptr;
|
||||
err = snd_timer_start(dshare->timer);
|
||||
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)
|
||||
return 0;
|
||||
|
|
@ -341,22 +341,9 @@ static int snd_pcm_dshare_drain(snd_pcm_t *pcm)
|
|||
return snd_pcm_dshare_drop(pcm);
|
||||
}
|
||||
|
||||
static int snd_pcm_dshare_pause(snd_pcm_t *pcm, int enable)
|
||||
static int snd_pcm_dshare_pause(snd_pcm_t *pcm ATTRIBUTE_UNUSED, int enable ATTRIBUTE_UNUSED)
|
||||
{
|
||||
snd_pcm_direct_t *dshare = pcm->private_data;
|
||||
if (enable) {
|
||||
if (dshare->state != SND_PCM_STATE_RUNNING)
|
||||
return -EBADFD;
|
||||
dshare->state = SND_PCM_STATE_PAUSED;
|
||||
snd_timer_stop(dshare->timer);
|
||||
do_silence(pcm);
|
||||
} else {
|
||||
if (dshare->state != SND_PCM_STATE_PAUSED)
|
||||
return -EBADFD;
|
||||
dshare->state = SND_PCM_STATE_RUNNING;
|
||||
snd_timer_start(dshare->timer);
|
||||
}
|
||||
return 0;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static snd_pcm_sframes_t snd_pcm_dshare_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ static int snd_pcm_dsnoop_prepare(snd_pcm_t *pcm)
|
|||
dsnoop->state = SND_PCM_STATE_PREPARED;
|
||||
dsnoop->appl_ptr = 0;
|
||||
dsnoop->hw_ptr = 0;
|
||||
return 0;
|
||||
return snd_pcm_direct_set_timer_params(dsnoop);
|
||||
}
|
||||
|
||||
static int snd_pcm_dsnoop_reset(snd_pcm_t *pcm)
|
||||
|
|
@ -268,12 +268,12 @@ static int snd_pcm_dsnoop_start(snd_pcm_t *pcm)
|
|||
|
||||
if (dsnoop->state != SND_PCM_STATE_PREPARED)
|
||||
return -EBADFD;
|
||||
snd_pcm_hwsync(dsnoop->spcm);
|
||||
dsnoop->slave_appl_ptr = dsnoop->slave_hw_ptr = *dsnoop->spcm->hw.ptr;
|
||||
err = snd_timer_start(dsnoop->timer);
|
||||
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;
|
||||
dsnoop->trigger_tstamp.tv_nsec = tv.tv_usec * 1000L;
|
||||
|
|
@ -313,21 +313,9 @@ static int snd_pcm_dsnoop_drain(snd_pcm_t *pcm)
|
|||
return snd_pcm_dsnoop_drop(pcm);
|
||||
}
|
||||
|
||||
static int snd_pcm_dsnoop_pause(snd_pcm_t *pcm, int enable)
|
||||
static int snd_pcm_dsnoop_pause(snd_pcm_t *pcm ATTRIBUTE_UNUSED, int enable ATTRIBUTE_UNUSED)
|
||||
{
|
||||
snd_pcm_direct_t *dsnoop = pcm->private_data;
|
||||
if (enable) {
|
||||
if (dsnoop->state != SND_PCM_STATE_RUNNING)
|
||||
return -EBADFD;
|
||||
dsnoop->state = SND_PCM_STATE_PAUSED;
|
||||
snd_timer_stop(dsnoop->timer);
|
||||
} else {
|
||||
if (dsnoop->state != SND_PCM_STATE_PAUSED)
|
||||
return -EBADFD;
|
||||
dsnoop->state = SND_PCM_STATE_RUNNING;
|
||||
snd_timer_start(dsnoop->timer);
|
||||
}
|
||||
return 0;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static snd_pcm_sframes_t snd_pcm_dsnoop_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue