summaryrefslogtreecommitdiff
path: root/src/timer
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@perex.cz>2003-03-04 20:01:06 +0000
committerJaroslav Kysela <perex@perex.cz>2003-03-04 20:01:06 +0000
commit9c084c4ba6a4cda677cfe1213b51cc1e4afeb3ed (patch)
treed4a3bede326b80fd80c9fc1335dd7f7ffe4b59c1 /src/timer
parent6a949ee804670d9d3de6f1f8aaaa4e247ad8e90c (diff)
Updated to new timer API
Diffstat (limited to 'src/timer')
-rw-r--r--src/timer/timer.c89
-rw-r--r--src/timer/timer_hw.c9
-rw-r--r--src/timer/timer_local.h3
-rw-r--r--src/timer/timer_query.c50
-rw-r--r--src/timer/timer_query_hw.c30
5 files changed, 171 insertions, 10 deletions
diff --git a/src/timer/timer.c b/src/timer/timer.c
index 10e5ec67..8b366e66 100644
--- a/src/timer/timer.c
+++ b/src/timer/timer.c
@@ -466,16 +466,6 @@ const char *snd_timer_info_get_name(snd_timer_info_t * info)
return info->name;
}
-/**
- * \brief get maximum timer ticks
- * \param info pointer to #snd_timer_info_t structure
- * \return maximum timer ticks
- */
-long snd_timer_info_get_ticks(snd_timer_info_t * info)
-{
- assert(info);
- return info->ticks;
-}
/**
* \brief get timer resolution in us
@@ -576,6 +566,40 @@ int snd_timer_params_get_auto_start(snd_timer_params_t * params)
}
/**
+ * \brief set timer exclusive use
+ * \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)
+#else
+void snd_timer_params_set_exclusive(snd_timer_params_t * params, int exclusive)
+#endif
+{
+ assert(params);
+ if (exclusive)
+ params->flags |= SNDRV_TIMER_PSFLG_EXCLUSIVE;
+ else
+ params->flags &= ~SNDRV_TIMER_PSFLG_EXCLUSIVE;
+}
+default_symbol_version(__snd_timer_params_set_exclusive, snd_timer_params_set_exclusive, ALSA_0.9.0);
+
+/**
+ * \brief determine if timer has exclusive flag
+ * \param params pointer to #snd_timer_params_t structure
+ * \return nonzero if timer has exclusive flag
+ */
+#ifndef DOXYGEN
+int INTERNAL(snd_timer_params_get_exclusive)(snd_timer_params_t * params)
+#else
+int snd_timer_params_get_exclusive(snd_timer_params_t * params)
+#endif
+{
+ assert(params);
+ return params->flags & SNDRV_TIMER_PSFLG_EXCLUSIVE ? 1 : 0;
+}
+default_symbol_version(__snd_timer_params_get_exclusive, snd_timer_params_get_exclusive, ALSA_0.9.0);
+
+/**
* \brief set timer ticks
* \param params pointer to #snd_timer_params_t structure
*/
@@ -618,6 +642,37 @@ long snd_timer_params_get_queue_size(snd_timer_params_t * params)
}
/**
+ * \brief set timer event filter
+ * \param params pointer to #snd_timer_params_t structure
+ */
+#ifndef DOXYGEN
+void INTERNAL(snd_timer_params_set_filter)(snd_timer_params_t * params, unsigned int filter)
+#else
+void snd_timer_params_set_filter(snd_timer_params_t * params, unsigned int filter)
+#endif
+{
+ assert(params);
+ params->filter = filter;
+}
+default_symbol_version(__snd_timer_params_set_filter, snd_timer_params_set_filter, ALSA_0.9.0);
+
+/**
+ * \brief get timer event filter
+ * \param params pointer to #snd_timer_params_t structure
+ * \return timer event filter
+ */
+#ifndef DOXYGEN
+unsigned int INTERNAL(snd_timer_params_get_filter)(snd_timer_params_t * params)
+#else
+unsigned int snd_timer_params_get_filter(snd_timer_params_t * params)
+#endif
+{
+ assert(params);
+ return params->filter;
+}
+default_symbol_version(__snd_timer_params_get_filter, snd_timer_params_get_filter, ALSA_0.9.0);
+
+/**
* \brief set parameters for timer handle
* \param timer timer handle
* \param params pointer to a #snd_timer_params_t structure
@@ -796,3 +851,17 @@ ssize_t snd_timer_read(snd_timer_t *timer, void *buffer, size_t size)
assert(buffer || size == 0);
return timer->ops->read(timer, buffer, size);
}
+
+/**
+ * \brief (DEPRECATED) get maximum timer ticks
+ * \param info pointer to #snd_timer_info_t structure
+ * \return maximum timer ticks
+ */
+long snd_timer_info_get_ticks(snd_timer_info_t * info)
+{
+ assert(info);
+ return 1;
+}
+#ifndef DOC_HIDDEN
+link_warning(snd_timer_info_get_ticks, "Warning: snd_timer_info_get_ticks is deprecated");
+#endif
diff --git a/src/timer/timer_hw.c b/src/timer/timer_hw.c
index b20c0aa2..2ea2aa98 100644
--- a/src/timer/timer_hw.c
+++ b/src/timer/timer_hw.c
@@ -233,6 +233,15 @@ int snd_timer_hw_open(snd_timer_t **handle, const char *name, int dev_class, int
close(fd);
return -SND_ERROR_INCOMPATIBLE_VERSION;
}
+ if (mode & SND_TIMER_OPEN_TREAD) {
+ int arg = 1;
+ if (ioctl(fd, SNDRV_TIMER_IOCTL_TREAD, &arg) < 0) {
+ ret = -errno;
+ close(fd);
+ SNDERR("extended read is not supported (SNDRV_TIMER_IOCTL_TREAD)");
+ return ret;
+ }
+ }
memset(&sel, 0, sizeof(sel));
sel.id.dev_class = dev_class;
sel.id.dev_sclass = dev_sclass;
diff --git a/src/timer/timer_local.h b/src/timer/timer_local.h
index bbe8f0c7..f11bce34 100644
--- a/src/timer/timer_local.h
+++ b/src/timer/timer_local.h
@@ -52,6 +52,9 @@ int snd_timer_hw_open(snd_timer_t **handle, const char *name, int dev_class, int
typedef struct {
int (*close)(snd_timer_query_t *timer);
int (*next_device)(snd_timer_query_t *timer, snd_timer_id_t *tid);
+ int (*info)(snd_timer_query_t *timer, snd_timer_ginfo_t *info);
+ int (*params)(snd_timer_query_t *timer, snd_timer_gparams_t *info);
+ int (*status)(snd_timer_query_t *timer, snd_timer_gstatus_t *info);
} snd_timer_query_ops_t;
struct _snd_timer_query {
diff --git a/src/timer/timer_query.c b/src/timer/timer_query.c
index 497460f7..d381d2ac 100644
--- a/src/timer/timer_query.c
+++ b/src/timer/timer_query.c
@@ -221,6 +221,56 @@ int snd_timer_query_next_device(snd_timer_query_t *timer, snd_timer_id_t *tid)
}
/**
+ * \brief obtain the timer global information
+ * \param timer timer handle
+ * \param info timer information
+ * \return 0 on success otherwise a negative error code
+ */
+#ifndef DOXYGEN
+int INTERNAL(snd_timer_query_info)(snd_timer_query_t *timer, snd_timer_ginfo_t *info)
+#else
+int snd_timer_query_info(snd_timer_query_t *timer, snd_timer_ginfo_t *info)
+#endif
+{
+ assert(timer);
+ assert(info);
+ return timer->ops->info(timer, info);
+}
+default_symbol_version(__snd_timer_query_info, snd_timer_query_info, ALSA_0.9.0);
+
+/**
+ * \brief set the timer global parameters
+ * \param timer timer handle
+ * \param params timer parameters
+ * \return 0 on success otherwise a negative error code
+ */
+#ifndef DOXYGEN
+int INTERNAL(snd_timer_query_params)(snd_timer_query_t *timer, snd_timer_gparams_t *params)
+#else
+int snd_timer_query_params(snd_timer_query_t *timer, snd_timer_gparams_t *params)
+#endif
+{
+ assert(timer);
+ assert(params);
+ return timer->ops->params(timer, params);
+}
+default_symbol_version(__snd_timer_query_params, snd_timer_query_params, ALSA_0.9.0);
+
+/**
+ * \brief get the timer global status
+ * \param timer timer handle
+ * \param status timer status
+ * \return 0 on success otherwise a negative error code
+ */
+int snd_timer_query_status(snd_timer_query_t *timer, snd_timer_gstatus_t *status)
+{
+ assert(timer);
+ assert(status);
+ return timer->ops->status(timer, status);
+}
+default_symbol_version(__snd_timer_query_status, snd_timer_query_status, ALSA_0.9.0);
+
+/**
* \brief get size of the snd_timer_id_t structure in bytes
* \return size of the snd_timer_id_t structure in bytes
*/
diff --git a/src/timer/timer_query_hw.c b/src/timer/timer_query_hw.c
index feded1f8..18178d6d 100644
--- a/src/timer/timer_query_hw.c
+++ b/src/timer/timer_query_hw.c
@@ -54,9 +54,39 @@ static int snd_timer_query_hw_next_device(snd_timer_query_t *handle, snd_timer_i
return 0;
}
+static int snd_timer_query_hw_info(snd_timer_query_t *handle, snd_timer_ginfo_t *info)
+{
+ if (!handle || !info)
+ return -EINVAL;
+ if (ioctl(handle->poll_fd, SNDRV_TIMER_IOCTL_GINFO, info) < 0)
+ return -errno;
+ return 0;
+}
+
+static int snd_timer_query_hw_params(snd_timer_query_t *handle, snd_timer_gparams_t *params)
+{
+ if (!handle || !params)
+ return -EINVAL;
+ if (ioctl(handle->poll_fd, SNDRV_TIMER_IOCTL_GPARAMS, params) < 0)
+ return -errno;
+ return 0;
+}
+
+static int snd_timer_query_hw_status(snd_timer_query_t *handle, snd_timer_gstatus_t *status)
+{
+ if (!handle || !status)
+ return -EINVAL;
+ if (ioctl(handle->poll_fd, SNDRV_TIMER_IOCTL_GSTATUS, status) < 0)
+ return -errno;
+ return 0;
+}
+
static snd_timer_query_ops_t snd_timer_query_hw_ops = {
close: snd_timer_query_hw_close,
next_device: snd_timer_query_hw_next_device,
+ info: snd_timer_query_hw_info,
+ params: snd_timer_query_hw_params,
+ status: snd_timer_query_hw_status
};
int snd_timer_query_hw_open(snd_timer_query_t **handle, const char *name, int mode)