Added early event extension to the timer API - and a fix for the direct plugins

This commit is contained in:
Jaroslav Kysela 2004-04-06 17:29:25 +00:00
parent dff4d5c466
commit 64a39728a2
5 changed files with 46 additions and 6 deletions

View File

@ -538,7 +538,7 @@ enum {
* Timer section - /dev/snd/timer
*/
#define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 1)
#define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 2)
enum sndrv_timer_class {
SNDRV_TIMER_CLASS_NONE = -1,
@ -619,6 +619,7 @@ struct sndrv_timer_info {
#define SNDRV_TIMER_PSFLG_AUTO (1<<0) /* auto start, otherwise one-shot */
#define SNDRV_TIMER_PSFLG_EXCLUSIVE (1<<1) /* exclusive use, precise start/stop/pause/continue */
#define SNDRV_TIMER_PSFLG_EARLY_EVENT (1<<2) /* write early event to the poll queue */
struct sndrv_timer_params {
unsigned int flags; /* flags - SNDRV_MIXER_PSFLG_* */
@ -667,6 +668,7 @@ enum sndrv_timer_event {
SNDRV_TIMER_EVENT_STOP, /* val = 0 */
SNDRV_TIMER_EVENT_CONTINUE, /* val = resolution in ns */
SNDRV_TIMER_EVENT_PAUSE, /* val = 0 */
SNDRV_TIMER_EVENT_EARLY, /* val = 0, early event */
/* master timer events for slave timer instances */
SNDRV_TIMER_EVENT_MSTART = SNDRV_TIMER_EVENT_START + 10,
SNDRV_TIMER_EVENT_MSTOP = SNDRV_TIMER_EVENT_STOP + 10,

View File

@ -84,6 +84,7 @@ typedef enum _snd_timer_event {
SND_TIMER_EVENT_STOP, /* val = 0 */
SND_TIMER_EVENT_CONTINUE, /* val = resolution in ns */
SND_TIMER_EVENT_PAUSE, /* val = 0 */
SND_TIMER_EVENT_EARLY, /* val = 0 */
/* master timer events for slave timer instances */
SND_TIMER_EVENT_MSTART = SND_TIMER_EVENT_START + 10,
SND_TIMER_EVENT_MSTOP = SND_TIMER_EVENT_STOP + 10,
@ -190,10 +191,12 @@ int snd_timer_params_malloc(snd_timer_params_t **ptr);
void snd_timer_params_free(snd_timer_params_t *obj);
void snd_timer_params_copy(snd_timer_params_t *dst, const snd_timer_params_t *src);
void snd_timer_params_set_auto_start(snd_timer_params_t * params, int auto_start);
int snd_timer_params_set_auto_start(snd_timer_params_t * params, int auto_start);
int snd_timer_params_get_auto_start(snd_timer_params_t * params);
void snd_timer_params_set_exclusive(snd_timer_params_t * params, int exclusive);
int snd_timer_params_set_exclusive(snd_timer_params_t * params, int exclusive);
int snd_timer_params_get_exclusive(snd_timer_params_t * params);
int snd_timer_params_set_early_event(snd_timer_params_t * params, int early_event);
int snd_timer_params_get_early_event(snd_timer_params_t * params);
void snd_timer_params_set_ticks(snd_timer_params_t * params, long ticks);
long snd_timer_params_get_ticks(snd_timer_params_t * params);
void snd_timer_params_set_queue_size(snd_timer_params_t * params, long queue_size);

View File

@ -152,3 +152,10 @@ ALSA_1.0.4 {
snd_spcm_init_duplex;
snd_spcm_init_get_params;
} ALSA_0.9.8;
ALSA_1.0.5 {
global:
snd_timer_params_set_early_event;
snd_timer_params_get_early_event;
} ALSA_1.0.4;

View File

@ -846,6 +846,7 @@ int snd_pcm_direct_initialize_poll_fd(snd_pcm_direct_t *dmix)
return ret;
}
snd_timer_params_set_auto_start(params, 1);
snd_timer_params_set_early_event(params, 1);
snd_timer_params_set_ticks(params, 1);
ret = snd_timer_params(dmix->timer, params);
if (ret < 0) {

View File

@ -545,13 +545,14 @@ void snd_timer_params_copy(snd_timer_params_t *dst, const snd_timer_params_t *sr
* \brief set timer auto start
* \param params pointer to #snd_timer_params_t structure
*/
void snd_timer_params_set_auto_start(snd_timer_params_t * params, int auto_start)
int snd_timer_params_set_auto_start(snd_timer_params_t * params, int auto_start)
{
assert(params);
if (auto_start)
params->flags |= SNDRV_TIMER_PSFLG_AUTO;
else
params->flags &= ~SNDRV_TIMER_PSFLG_AUTO;
return 0;
}
/**
@ -570,9 +571,9 @@ int snd_timer_params_get_auto_start(snd_timer_params_t * params)
* \param params pointer to #snd_timer_params_t structure
*/
#ifndef DOXYGEN
void INTERNAL(snd_timer_params_set_exclusive)(snd_timer_params_t * params, int exclusive)
int INTERNAL(snd_timer_params_set_exclusive)(snd_timer_params_t * params, int exclusive)
#else
void snd_timer_params_set_exclusive(snd_timer_params_t * params, int exclusive)
int snd_timer_params_set_exclusive(snd_timer_params_t * params, int exclusive)
#endif
{
assert(params);
@ -580,6 +581,7 @@ void snd_timer_params_set_exclusive(snd_timer_params_t * params, int exclusive)
params->flags |= SNDRV_TIMER_PSFLG_EXCLUSIVE;
else
params->flags &= ~SNDRV_TIMER_PSFLG_EXCLUSIVE;
return 0;
}
use_default_symbol_version(__snd_timer_params_set_exclusive, snd_timer_params_set_exclusive, ALSA_0.9.0);
@ -599,6 +601,31 @@ int snd_timer_params_get_exclusive(snd_timer_params_t * params)
}
use_default_symbol_version(__snd_timer_params_get_exclusive, snd_timer_params_get_exclusive, ALSA_0.9.0);
/**
* \brief set timer early event
* \param params pointer to #snd_timer_params_t structure
*/
int snd_timer_params_set_early_event(snd_timer_params_t * params, int early_event)
{
assert(params);
if (early_event)
params->flags |= SNDRV_TIMER_PSFLG_EARLY_EVENT;
else
params->flags &= ~SNDRV_TIMER_PSFLG_EARLY_EVENT;
return 0;
}
/**
* \brief determine if timer has early event flag
* \param params pointer to #snd_timer_params_t structure
* \return nonzero if timer has early event flag set
*/
int snd_timer_params_get_early_event(snd_timer_params_t * params)
{
assert(params);
return params->flags & SNDRV_TIMER_PSFLG_EARLY_EVENT ? 1 : 0;
}
/**
* \brief set timer ticks
* \param params pointer to #snd_timer_params_t structure