mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
Timer cleanups against the latest API
This commit is contained in:
parent
5f5243ef79
commit
fe75a8fa3f
2 changed files with 11 additions and 2 deletions
|
|
@ -34,7 +34,9 @@ const char *_snd_module_timer_hw = "";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SNDRV_FILE_TIMER "/dev/snd/timer"
|
#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)
|
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)
|
static int snd_timer_hw_status(snd_timer_t *handle, snd_timer_status_t * status)
|
||||||
{
|
{
|
||||||
snd_timer_t *tmr;
|
snd_timer_t *tmr;
|
||||||
|
int cmd;
|
||||||
|
|
||||||
tmr = handle;
|
tmr = handle;
|
||||||
if (!tmr || !status)
|
if (!tmr || !status)
|
||||||
return -EINVAL;
|
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 -errno;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -243,6 +250,7 @@ int snd_timer_hw_open(snd_timer_t **handle, const char *name, int dev_class, int
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
tmr->type = SND_TIMER_TYPE_HW;
|
tmr->type = SND_TIMER_TYPE_HW;
|
||||||
|
tmr->version = ver;
|
||||||
tmr->mode = tmode;
|
tmr->mode = tmode;
|
||||||
tmr->name = strdup(name);
|
tmr->name = strdup(name);
|
||||||
tmr->poll_fd = fd;
|
tmr->poll_fd = fd;
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ typedef struct {
|
||||||
} snd_timer_ops_t;
|
} snd_timer_ops_t;
|
||||||
|
|
||||||
struct _snd_timer {
|
struct _snd_timer {
|
||||||
|
unsigned int version;
|
||||||
char *name;
|
char *name;
|
||||||
snd_timer_type_t type;
|
snd_timer_type_t type;
|
||||||
int mode;
|
int mode;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue