Update of /cvsroot/alsa/alsa-lib/src/timer In directory sc8-pr-cvs1:/tmp/cvs-serv15643/src/timer
Modified Files: timer.c timer_hw.c timer_local.h timer_query.c timer_query_hw.c Log Message: Updated to new timer API Index: timer.c =================================================================== RCS file: /cvsroot/alsa/alsa-lib/src/timer/timer.c,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- timer.c 28 Feb 2003 17:23:36 -0000 1.39 +++ timer.c 4 Mar 2003 20:01:08 -0000 1.40 @@ -466,16 +466,6 @@ 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 @@ } /** + * \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 @@ } /** + * \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 @@ 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 Index: timer_hw.c =================================================================== RCS file: /cvsroot/alsa/alsa-lib/src/timer/timer_hw.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- timer_hw.c 2 Mar 2003 19:30:52 -0000 1.10 +++ timer_hw.c 4 Mar 2003 20:01:09 -0000 1.11 @@ -233,6 +233,15 @@ 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; Index: timer_local.h =================================================================== RCS file: /cvsroot/alsa/alsa-lib/src/timer/timer_local.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- timer_local.h 2 Mar 2003 19:30:52 -0000 1.4 +++ timer_local.h 4 Mar 2003 20:01:09 -0000 1.5 @@ -52,6 +52,9 @@ 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 { Index: timer_query.c =================================================================== RCS file: /cvsroot/alsa/alsa-lib/src/timer/timer_query.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- timer_query.c 30 Dec 2001 09:22:56 -0000 1.9 +++ timer_query.c 4 Mar 2003 20:01:10 -0000 1.10 @@ -221,6 +221,56 @@ } /** + * \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 */ Index: timer_query_hw.c =================================================================== RCS file: /cvsroot/alsa/alsa-lib/src/timer/timer_query_hw.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- timer_query_hw.c 30 Dec 2001 09:22:56 -0000 1.5 +++ timer_query_hw.c 4 Mar 2003 20:01:10 -0000 1.6 @@ -54,9 +54,39 @@ 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) ------------------------------------------------------- This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. www.etnus.com _______________________________________________ Alsa-cvslog mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-cvslog