From: Jaroslav Kysela Date: Sun, 2 Mar 2003 19:30:52 +0000 (+0000) Subject: Timer cleanups against the latest API X-Git-Tag: v1.0.3~225 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=fe75a8fa3f643e4c4d799e26ac66e4649dc19d1f;p=alsa-lib.git Timer cleanups against the latest API --- diff --git a/src/timer/timer_hw.c b/src/timer/timer_hw.c index 76651d89..b20c0aa2 100644 --- a/src/timer/timer_hw.c +++ b/src/timer/timer_hw.c @@ -34,7 +34,9 @@ const char *_snd_module_timer_hw = ""; #endif #define SNDRV_FILE_TIMER "/dev/snd/timer" -#define SNDRV_TIMER_VERSION_MAX SNDRV_PROTOCOL_VERSION(2, 0, 0) +#define SNDRV_TIMER_VERSION_MAX SNDRV_PROTOCOL_VERSION(2, 0, 1) + +#define SNDRV_TIMER_IOCTL_STATUS_OLD _IOW('T', 0x14, struct sndrv_timer_status) static int snd_timer_hw_close(snd_timer_t *handle) { @@ -121,11 +123,16 @@ static int snd_timer_hw_params(snd_timer_t *handle, snd_timer_params_t * params) static int snd_timer_hw_status(snd_timer_t *handle, snd_timer_status_t * status) { snd_timer_t *tmr; + int cmd; tmr = handle; if (!tmr || !status) return -EINVAL; - if (ioctl(tmr->poll_fd, SNDRV_TIMER_IOCTL_STATUS, status) < 0) + if (tmr->version < SNDRV_PROTOCOL_VERSION(2, 0, 1)) + cmd = SNDRV_TIMER_IOCTL_STATUS_OLD; + else + cmd = SNDRV_TIMER_IOCTL_STATUS; + if (ioctl(tmr->poll_fd, cmd, status) < 0) return -errno; return 0; } @@ -243,6 +250,7 @@ int snd_timer_hw_open(snd_timer_t **handle, const char *name, int dev_class, int return -ENOMEM; } tmr->type = SND_TIMER_TYPE_HW; + tmr->version = ver; tmr->mode = tmode; tmr->name = strdup(name); tmr->poll_fd = fd; diff --git a/src/timer/timer_local.h b/src/timer/timer_local.h index 8c3ad3d7..bbe8f0c7 100644 --- a/src/timer/timer_local.h +++ b/src/timer/timer_local.h @@ -38,6 +38,7 @@ typedef struct { } snd_timer_ops_t; struct _snd_timer { + unsigned int version; char *name; snd_timer_type_t type; int mode;