]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Timer cleanups against the latest API
authorJaroslav Kysela <perex@perex.cz>
Sun, 2 Mar 2003 19:30:52 +0000 (19:30 +0000)
committerJaroslav Kysela <perex@perex.cz>
Sun, 2 Mar 2003 19:30:52 +0000 (19:30 +0000)
src/timer/timer_hw.c
src/timer/timer_local.h

index 76651d898e809037d82cf318851404d36983053a..b20c0aa2e3bf5fd056d2a55af5f45ab19516c89a 100644 (file)
@@ -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;
index 8c3ad3d737ca36516118b07f20a1436efe753d12..bbe8f0c7060e5d670a6406f5802cbaf61aca9521 100644 (file)
@@ -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;