Blame src/timer/timer_query.c

Packit 4a16fb
/**
Packit 4a16fb
 * \file timer/timer_query.c
Packit 4a16fb
 * \author Jaroslav Kysela <perex@perex.cz>
Packit 4a16fb
 * \date 2001
Packit 4a16fb
 *
Packit 4a16fb
 * Timer Query Interface is designed to obtain identification of timers.
Packit 4a16fb
 */
Packit 4a16fb
/*
Packit 4a16fb
 *  Timer Query Interface - main file
Packit 4a16fb
 *  Copyright (c) 2001 by Jaroslav Kysela <perex@perex.cz>
Packit 4a16fb
 *
Packit 4a16fb
 *
Packit 4a16fb
 *   This library is free software; you can redistribute it and/or modify
Packit 4a16fb
 *   it under the terms of the GNU Lesser General Public License as
Packit 4a16fb
 *   published by the Free Software Foundation; either version 2.1 of
Packit 4a16fb
 *   the License, or (at your option) any later version.
Packit 4a16fb
 *
Packit 4a16fb
 *   This program is distributed in the hope that it will be useful,
Packit 4a16fb
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 4a16fb
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 4a16fb
 *   GNU Lesser General Public License for more details.
Packit 4a16fb
 *
Packit 4a16fb
 *   You should have received a copy of the GNU Lesser General Public
Packit 4a16fb
 *   License along with this library; if not, write to the Free Software
Packit 4a16fb
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
Packit 4a16fb
 *
Packit 4a16fb
 */
Packit 4a16fb
Packit 4a16fb
#include "timer_local.h"
Packit 4a16fb
Packit 4a16fb
static int snd_timer_query_open_conf(snd_timer_query_t **timer,
Packit 4a16fb
				     const char *name, snd_config_t *timer_root,
Packit 4a16fb
				     snd_config_t *timer_conf, int mode)
Packit 4a16fb
{
Packit 4a16fb
	const char *str;
Packit 4a16fb
	char buf[256], errbuf[256];
Packit 4a16fb
	int err;
Packit 4a16fb
	snd_config_t *conf, *type_conf = NULL;
Packit 4a16fb
	snd_config_iterator_t i, next;
Packit 4a16fb
	const char *id;
Packit 4a16fb
	const char *lib = NULL, *open_name = NULL;
Packit 4a16fb
	int (*open_func)(snd_timer_query_t **, const char *, snd_config_t *, snd_config_t *, int) = NULL;
Packit 4a16fb
#ifndef PIC
Packit 4a16fb
	extern void *snd_timer_query_open_symbols(void);
Packit 4a16fb
#endif
Packit 4a16fb
	void *h = NULL;
Packit 4a16fb
	if (snd_config_get_type(timer_conf) != SND_CONFIG_TYPE_COMPOUND) {
Packit 4a16fb
		if (name)
Packit 4a16fb
			SNDERR("Invalid type for TIMER %s definition", name);
Packit 4a16fb
		else
Packit 4a16fb
			SNDERR("Invalid type for TIMER definition");
Packit 4a16fb
		return -EINVAL;
Packit 4a16fb
	}
Packit 4a16fb
	err = snd_config_search(timer_conf, "type", &conf;;
Packit 4a16fb
	if (err < 0) {
Packit 4a16fb
		SNDERR("type is not defined");
Packit 4a16fb
		return err;
Packit 4a16fb
	}
Packit 4a16fb
	err = snd_config_get_id(conf, &id;;
Packit 4a16fb
	if (err < 0) {
Packit 4a16fb
		SNDERR("unable to get id");
Packit 4a16fb
		return err;
Packit 4a16fb
	}
Packit 4a16fb
	err = snd_config_get_string(conf, &str);
Packit 4a16fb
	if (err < 0) {
Packit 4a16fb
		SNDERR("Invalid type for %s", id);
Packit 4a16fb
		return err;
Packit 4a16fb
	}
Packit 4a16fb
	err = snd_config_search_definition(timer_root, "timer_query_type", str, &type_conf);
Packit 4a16fb
	if (err >= 0) {
Packit 4a16fb
		if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) {
Packit 4a16fb
			SNDERR("Invalid type for TIMER type %s definition", str);
Packit 4a16fb
			err = -EINVAL;
Packit 4a16fb
			goto _err;
Packit 4a16fb
		}
Packit 4a16fb
		snd_config_for_each(i, next, type_conf) {
Packit 4a16fb
			snd_config_t *n = snd_config_iterator_entry(i);
Packit 4a16fb
			const char *id;
Packit 4a16fb
			if (snd_config_get_id(n, &id) < 0)
Packit 4a16fb
				continue;
Packit 4a16fb
			if (strcmp(id, "comment") == 0)
Packit 4a16fb
				continue;
Packit 4a16fb
			if (strcmp(id, "lib") == 0) {
Packit 4a16fb
				err = snd_config_get_string(n, &lib);
Packit 4a16fb
				if (err < 0) {
Packit 4a16fb
					SNDERR("Invalid type for %s", id);
Packit 4a16fb
					goto _err;
Packit 4a16fb
				}
Packit 4a16fb
				continue;
Packit 4a16fb
			}
Packit 4a16fb
			if (strcmp(id, "open") == 0) {
Packit 4a16fb
				err = snd_config_get_string(n, &open_name);
Packit 4a16fb
				if (err < 0) {
Packit 4a16fb
					SNDERR("Invalid type for %s", id);
Packit 4a16fb
					goto _err;
Packit 4a16fb
				}
Packit 4a16fb
				continue;
Packit 4a16fb
			}
Packit 4a16fb
			SNDERR("Unknown field %s", id);
Packit 4a16fb
			err = -EINVAL;
Packit 4a16fb
			goto _err;
Packit 4a16fb
		}
Packit 4a16fb
	}
Packit 4a16fb
	if (!open_name) {
Packit 4a16fb
		open_name = buf;
Packit 4a16fb
		snprintf(buf, sizeof(buf), "_snd_timer_query_%s_open", str);
Packit 4a16fb
	}
Packit 4a16fb
#ifndef PIC
Packit 4a16fb
	snd_timer_query_open_symbols();
Packit 4a16fb
#endif
Packit 4a16fb
	h = INTERNAL(snd_dlopen)(lib, RTLD_NOW, errbuf, sizeof(errbuf));
Packit 4a16fb
	if (h)
Packit 4a16fb
		open_func = snd_dlsym(h, open_name, SND_DLSYM_VERSION(SND_TIMER_QUERY_DLSYM_VERSION));
Packit 4a16fb
	err = 0;
Packit 4a16fb
	if (!h) {
Packit 4a16fb
		SNDERR("Cannot open shared library %s (%s)", lib, errbuf);
Packit 4a16fb
		err = -ENOENT;
Packit 4a16fb
	} else if (!open_func) {
Packit 4a16fb
		SNDERR("symbol %s is not defined inside %s", open_name, lib);
Packit 4a16fb
		snd_dlclose(h);
Packit 4a16fb
		err = -ENXIO;
Packit 4a16fb
	}
Packit 4a16fb
       _err:
Packit 4a16fb
	if (type_conf)
Packit 4a16fb
		snd_config_delete(type_conf);
Packit 4a16fb
	if (! err) {
Packit 4a16fb
		err = open_func(timer, name, timer_root, timer_conf, mode);
Packit 4a16fb
		if (err < 0)
Packit 4a16fb
			snd_dlclose(h);
Packit 4a16fb
		else
Packit 4a16fb
			(*timer)->dl_handle = h;
Packit 4a16fb
	}
Packit 4a16fb
	return err;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static int snd_timer_query_open_noupdate(snd_timer_query_t **timer, snd_config_t *root, const char *name, int mode)
Packit 4a16fb
{
Packit 4a16fb
	int err;
Packit 4a16fb
	snd_config_t *timer_conf;
Packit 4a16fb
	err = snd_config_search_definition(root, "timer_query", name, &timer_conf);
Packit 4a16fb
	if (err < 0) {
Packit 4a16fb
		SNDERR("Unknown timer %s", name);
Packit 4a16fb
		return err;
Packit 4a16fb
	}
Packit 4a16fb
	err = snd_timer_query_open_conf(timer, name, root, timer_conf, mode);
Packit 4a16fb
	snd_config_delete(timer_conf);
Packit 4a16fb
	return err;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief Opens a new connection to the timer query interface.
Packit 4a16fb
 * \param timer Returned handle (NULL if not wanted)
Packit 4a16fb
 * \param name ASCII identifier of the RawMidi handle
Packit 4a16fb
 * \param mode Open mode
Packit 4a16fb
 * \return 0 on success otherwise a negative error code
Packit 4a16fb
 *
Packit 4a16fb
 * Opens a new connection to the RawMidi interface specified with
Packit 4a16fb
 * an ASCII identifier and mode.
Packit 4a16fb
 */
Packit 4a16fb
int snd_timer_query_open(snd_timer_query_t **timer, const char *name, int mode)
Packit 4a16fb
{
Packit 4a16fb
	snd_config_t *top;
Packit 4a16fb
	int err;
Packit 4a16fb
Packit 4a16fb
	assert(timer && name);
Packit 4a16fb
	err = snd_config_update_ref(&top);
Packit 4a16fb
	if (err < 0)
Packit 4a16fb
		return err;
Packit 4a16fb
	err = snd_timer_query_open_noupdate(timer, top, name, mode);
Packit 4a16fb
	snd_config_unref(top);
Packit 4a16fb
	return err;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief Opens a new connection to the timer query interface using local configuration
Packit 4a16fb
 * \param timer Returned handle (NULL if not wanted)
Packit 4a16fb
 * \param name ASCII identifier of the RawMidi handle
Packit 4a16fb
 * \param mode Open mode
Packit 4a16fb
 * \param lconf Local configuration
Packit 4a16fb
 * \return 0 on success otherwise a negative error code
Packit 4a16fb
 *
Packit 4a16fb
 * Opens a new connection to the RawMidi interface specified with
Packit 4a16fb
 * an ASCII identifier and mode.
Packit 4a16fb
 */
Packit 4a16fb
int snd_timer_query_open_lconf(snd_timer_query_t **timer, const char *name,
Packit 4a16fb
			       int mode, snd_config_t *lconf)
Packit 4a16fb
{
Packit 4a16fb
	assert(timer && name && lconf);
Packit 4a16fb
	return snd_timer_query_open_noupdate(timer, lconf, name, mode);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief close timer query handle
Packit 4a16fb
 * \param timer timer handle
Packit 4a16fb
 * \return 0 on success otherwise a negative error code
Packit 4a16fb
 *
Packit 4a16fb
 * Closes the specified timer handle and frees all associated
Packit 4a16fb
 * resources.
Packit 4a16fb
 */
Packit 4a16fb
int snd_timer_query_close(snd_timer_query_t *timer)
Packit 4a16fb
{
Packit 4a16fb
	int err;
Packit 4a16fb
  	assert(timer);
Packit 4a16fb
	err = timer->ops->close(timer);
Packit 4a16fb
	if (timer->dl_handle)
Packit 4a16fb
		snd_dlclose(timer->dl_handle);
Packit 4a16fb
	free(timer->name);
Packit 4a16fb
	free(timer);
Packit 4a16fb
	return err;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief obtain the next timer identification
Packit 4a16fb
 * \param timer timer handle
Packit 4a16fb
 * \param tid timer identification
Packit 4a16fb
 * \return 0 on success otherwise a negative error code
Packit 4a16fb
 *
Packit 4a16fb
 * if tid->dev_class is -1, then the first device is returned
Packit 4a16fb
 * if result tid->dev_class is -1, no more devices are left
Packit 4a16fb
 */
Packit 4a16fb
int snd_timer_query_next_device(snd_timer_query_t *timer, snd_timer_id_t *tid)
Packit 4a16fb
{
Packit 4a16fb
  	assert(timer);
Packit 4a16fb
  	assert(tid);
Packit 4a16fb
	return timer->ops->next_device(timer, tid);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief get size of the snd_timer_ginfo_t structure in bytes
Packit 4a16fb
 * \return size of the snd_timer_ginfo_t structure in bytes
Packit 4a16fb
 */
Packit 4a16fb
size_t snd_timer_ginfo_sizeof(void)
Packit 4a16fb
{
Packit 4a16fb
	return sizeof(snd_timer_ginfo_t);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief allocate a new snd_timer_ginfo_t structure
Packit 4a16fb
 * \param info returned pointer
Packit 4a16fb
 * \return 0 on success otherwise a negative error code if fails
Packit 4a16fb
 *
Packit 4a16fb
 * Allocates a new snd_timer_info_t structure using the standard
Packit 4a16fb
 * malloc C library function.
Packit 4a16fb
 */
Packit 4a16fb
int snd_timer_ginfo_malloc(snd_timer_ginfo_t **info)
Packit 4a16fb
{
Packit 4a16fb
	assert(info);
Packit 4a16fb
	*info = calloc(1, sizeof(snd_timer_ginfo_t));
Packit 4a16fb
	if (!*info)
Packit 4a16fb
		return -ENOMEM;
Packit 4a16fb
	return 0;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief frees the snd_timer_ginfo_t structure
Packit 4a16fb
 * \param info pointer to the snd_timer_ginfo_t structure to free
Packit 4a16fb
 *
Packit 4a16fb
 * Frees the given snd_timer_info_t structure using the standard
Packit 4a16fb
 * free C library function.
Packit 4a16fb
 */
Packit 4a16fb
void snd_timer_ginfo_free(snd_timer_ginfo_t *info)
Packit 4a16fb
{
Packit 4a16fb
	assert(info);
Packit 4a16fb
	free(info);  
Packit 4a16fb
}
Packit 4a16fb
  
Packit 4a16fb
/**
Packit 4a16fb
 * \brief copy one snd_timer_info_t structure to another
Packit 4a16fb
 * \param dst destination snd_timer_info_t structure
Packit 4a16fb
 * \param src source snd_timer_info_t structure
Packit 4a16fb
 */
Packit 4a16fb
void snd_timer_ginfo_copy(snd_timer_ginfo_t *dst, const snd_timer_ginfo_t *src)
Packit 4a16fb
{
Packit 4a16fb
	assert(dst && src);
Packit 4a16fb
	*dst = *src;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief set timer identification
Packit 4a16fb
 * \param obj pointer to #snd_timer_ginfo_t structure
Packit 4a16fb
 * \param tid pointer to #snd_timer_id_t structure
Packit 4a16fb
 * \return zero on success otherwise a negative error number
Packit 4a16fb
 */
Packit 4a16fb
int snd_timer_ginfo_set_tid(snd_timer_ginfo_t *obj, snd_timer_id_t *tid)
Packit 4a16fb
{
Packit 4a16fb
	obj->tid = *((snd_timer_id_t *)tid);
Packit 4a16fb
	return 0;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief get timer identification
Packit 4a16fb
 * \param obj pointer to #snd_timer_ginfo_t structure
Packit 4a16fb
 * \return pointer to snd_timer_id_t
Packit 4a16fb
 */
Packit 4a16fb
snd_timer_id_t *snd_timer_ginfo_get_tid(snd_timer_ginfo_t *obj)
Packit 4a16fb
{
Packit 4a16fb
	return (snd_timer_id_t *)&obj->tid;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief get timer flags
Packit 4a16fb
 * \param obj pointer to #snd_timer_ginfo_t structure
Packit 4a16fb
 * \return timer flags
Packit 4a16fb
 */
Packit 4a16fb
unsigned int snd_timer_ginfo_get_flags(snd_timer_ginfo_t *obj)
Packit 4a16fb
{
Packit 4a16fb
	return obj->flags;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief get associated card with timer
Packit 4a16fb
 * \param obj pointer to #snd_timer_ginfo_t structure
Packit 4a16fb
 * \return associated card
Packit 4a16fb
 */
Packit 4a16fb
int snd_timer_ginfo_get_card(snd_timer_ginfo_t *obj)
Packit 4a16fb
{
Packit 4a16fb
	return obj->card;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief get timer identification
Packit 4a16fb
 * \param obj pointer to #snd_timer_ginfo_t structure
Packit 4a16fb
 * \return timer identification
Packit 4a16fb
 */
Packit 4a16fb
char *snd_timer_ginfo_get_id(snd_timer_ginfo_t *obj)
Packit 4a16fb
{
Packit 4a16fb
	return (char *)obj->id;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief get timer name
Packit 4a16fb
 * \param obj pointer to #snd_timer_ginfo_t structure
Packit 4a16fb
 * \return timer name
Packit 4a16fb
 */
Packit 4a16fb
char *snd_timer_ginfo_get_name(snd_timer_ginfo_t *obj)
Packit 4a16fb
{
Packit 4a16fb
	return (char *)obj->name;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief get timer resolution in ns
Packit 4a16fb
 * \param obj pointer to #snd_timer_ginfo_t structure
Packit 4a16fb
 * \return timer resolution in ns
Packit 4a16fb
 */
Packit 4a16fb
unsigned long snd_timer_ginfo_get_resolution(snd_timer_ginfo_t *obj)
Packit 4a16fb
{
Packit 4a16fb
	return obj->resolution;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief get timer minimal resolution in ns
Packit 4a16fb
 * \param obj pointer to #snd_timer_ginfo_t structure
Packit 4a16fb
 * \return timer minimal resolution in ns
Packit 4a16fb
 */
Packit 4a16fb
unsigned long snd_timer_ginfo_get_resolution_min(snd_timer_ginfo_t *obj)
Packit 4a16fb
{
Packit 4a16fb
	return obj->resolution_min;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief get timer maximal resolution in ns
Packit 4a16fb
 * \param obj pointer to #snd_timer_ginfo_t structure
Packit 4a16fb
 * \return timer maximal resolution in ns
Packit 4a16fb
 */
Packit 4a16fb
unsigned long snd_timer_ginfo_get_resolution_max(snd_timer_ginfo_t *obj)
Packit 4a16fb
{
Packit 4a16fb
	return obj->resolution_max;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief get current timer clients
Packit 4a16fb
 * \param obj pointer to #snd_timer_ginfo_t structure
Packit 4a16fb
 * \return current timer clients
Packit 4a16fb
 */
Packit 4a16fb
unsigned int snd_timer_ginfo_get_clients(snd_timer_ginfo_t *obj)
Packit 4a16fb
{
Packit 4a16fb
	return obj->clients;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief obtain the timer global information
Packit 4a16fb
 * \param timer timer handle
Packit 4a16fb
 * \param info timer information
Packit 4a16fb
 * \return 0 on success otherwise a negative error code
Packit 4a16fb
 */
Packit 4a16fb
#ifndef DOXYGEN
Packit 4a16fb
EXPORT_SYMBOL int INTERNAL(snd_timer_query_info)(snd_timer_query_t *timer, snd_timer_ginfo_t *info)
Packit 4a16fb
#else
Packit 4a16fb
int snd_timer_query_info(snd_timer_query_t *timer, snd_timer_ginfo_t *info)
Packit 4a16fb
#endif
Packit 4a16fb
{
Packit 4a16fb
  	assert(timer);
Packit 4a16fb
  	assert(info);
Packit 4a16fb
	return timer->ops->info(timer, info);
Packit 4a16fb
}
Packit 4a16fb
use_default_symbol_version(__snd_timer_query_info, snd_timer_query_info, ALSA_0.9.0);
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief set the timer global parameters
Packit 4a16fb
 * \param timer timer handle
Packit 4a16fb
 * \param params timer parameters
Packit 4a16fb
 * \return 0 on success otherwise a negative error code
Packit 4a16fb
 */
Packit 4a16fb
#ifndef DOXYGEN
Packit 4a16fb
EXPORT_SYMBOL int INTERNAL(snd_timer_query_params)(snd_timer_query_t *timer, snd_timer_gparams_t *params)
Packit 4a16fb
#else
Packit 4a16fb
int snd_timer_query_params(snd_timer_query_t *timer, snd_timer_gparams_t *params)
Packit 4a16fb
#endif
Packit 4a16fb
{
Packit 4a16fb
  	assert(timer);
Packit 4a16fb
  	assert(params);
Packit 4a16fb
	return timer->ops->params(timer, params);
Packit 4a16fb
}
Packit 4a16fb
use_default_symbol_version(__snd_timer_query_params, snd_timer_query_params, ALSA_0.9.0);
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief get the timer global status
Packit 4a16fb
 * \param timer timer handle
Packit 4a16fb
 * \param status timer status
Packit 4a16fb
 * \return 0 on success otherwise a negative error code
Packit 4a16fb
 */
Packit 4a16fb
#ifndef DOXYGEN
Packit 4a16fb
EXPORT_SYMBOL int INTERNAL(snd_timer_query_status)(snd_timer_query_t *timer, snd_timer_gstatus_t *status)
Packit 4a16fb
#else
Packit 4a16fb
int snd_timer_query_status(snd_timer_query_t *timer, snd_timer_gstatus_t *status)
Packit 4a16fb
#endif
Packit 4a16fb
{
Packit 4a16fb
  	assert(timer);
Packit 4a16fb
  	assert(status);
Packit 4a16fb
	return timer->ops->status(timer, status);
Packit 4a16fb
}
Packit 4a16fb
use_default_symbol_version(__snd_timer_query_status, snd_timer_query_status, ALSA_0.9.0);
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief get size of the snd_timer_id_t structure in bytes
Packit 4a16fb
 * \return size of the snd_timer_id_t structure in bytes
Packit 4a16fb
 */
Packit 4a16fb
size_t snd_timer_id_sizeof()
Packit 4a16fb
{
Packit 4a16fb
	return sizeof(snd_timer_id_t);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief allocate a new snd_timer_id_t structure
Packit 4a16fb
 * \param info returned pointer
Packit 4a16fb
 * \return 0 on success otherwise a negative error code if fails
Packit 4a16fb
 *
Packit 4a16fb
 * Allocates a new snd_timer_id_t structure using the standard
Packit 4a16fb
 * malloc C library function.
Packit 4a16fb
 */
Packit 4a16fb
int snd_timer_id_malloc(snd_timer_id_t **info)
Packit 4a16fb
{
Packit 4a16fb
	assert(info);
Packit 4a16fb
	*info = calloc(1, sizeof(snd_timer_id_t));
Packit 4a16fb
	if (!*info)
Packit 4a16fb
		return -ENOMEM;
Packit 4a16fb
	return 0;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief frees the snd_timer_id_t structure
Packit 4a16fb
 * \param info pointer to the snd_timer_id_t structure to free
Packit 4a16fb
 *
Packit 4a16fb
 * Frees the given snd_timer_id_t structure using the standard
Packit 4a16fb
 * free C library function.
Packit 4a16fb
 */
Packit 4a16fb
void snd_timer_id_free(snd_timer_id_t *info)
Packit 4a16fb
{
Packit 4a16fb
	assert(info);
Packit 4a16fb
	free(info);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief copy one snd_timer_id_t structure to another
Packit 4a16fb
 * \param dst destination snd_timer_id_t structure
Packit 4a16fb
 * \param src source snd_timer_id_t structure
Packit 4a16fb
 */
Packit 4a16fb
void snd_timer_id_copy(snd_timer_id_t *dst, const snd_timer_id_t *src)
Packit 4a16fb
{
Packit 4a16fb
	assert(dst && src);
Packit 4a16fb
	*dst = *src;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief set timer class
Packit 4a16fb
 * \param tid pointer to #snd_timer_id_t structure
Packit 4a16fb
 * \param dev_class class of timer device
Packit 4a16fb
 */
Packit 4a16fb
void snd_timer_id_set_class(snd_timer_id_t * tid, int dev_class)
Packit 4a16fb
{
Packit 4a16fb
	assert(tid);
Packit 4a16fb
	tid->dev_class = dev_class;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief get timer class
Packit 4a16fb
 * \param tid pointer to #snd_timer_id_t structure
Packit 4a16fb
 * \return timer class
Packit 4a16fb
 */
Packit 4a16fb
int snd_timer_id_get_class(snd_timer_id_t * tid)
Packit 4a16fb
{
Packit 4a16fb
	assert(tid);
Packit 4a16fb
	return tid->dev_class;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief set timer sub-class
Packit 4a16fb
 * \param tid pointer to #snd_timer_id_t structure
Packit 4a16fb
 * \param dev_sclass sub-class of timer device
Packit 4a16fb
 */
Packit 4a16fb
void snd_timer_id_set_sclass(snd_timer_id_t * tid, int dev_sclass)
Packit 4a16fb
{
Packit 4a16fb
	assert(tid);
Packit 4a16fb
	tid->dev_sclass = dev_sclass;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief get timer sub-class
Packit 4a16fb
 * \param tid pointer to #snd_timer_id_t structure
Packit 4a16fb
 * \return timer sub-class
Packit 4a16fb
 */
Packit 4a16fb
int snd_timer_id_get_sclass(snd_timer_id_t * tid)
Packit 4a16fb
{
Packit 4a16fb
	assert(tid);
Packit 4a16fb
	return tid->dev_sclass;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief set timer card
Packit 4a16fb
 * \param tid pointer to #snd_timer_id_t structure
Packit 4a16fb
 * \param card card number
Packit 4a16fb
 */
Packit 4a16fb
void snd_timer_id_set_card(snd_timer_id_t * tid, int card)
Packit 4a16fb
{
Packit 4a16fb
	assert(tid);
Packit 4a16fb
	tid->card = card;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief get timer card
Packit 4a16fb
 * \param tid pointer to #snd_timer_id_t structure
Packit 4a16fb
 * \return timer card number
Packit 4a16fb
 */
Packit 4a16fb
int snd_timer_id_get_card(snd_timer_id_t * tid)
Packit 4a16fb
{
Packit 4a16fb
	assert(tid);
Packit 4a16fb
	return tid->card;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief set timer device
Packit 4a16fb
 * \param tid pointer to #snd_timer_id_t structure
Packit 4a16fb
 * \param device device number
Packit 4a16fb
 */
Packit 4a16fb
void snd_timer_id_set_device(snd_timer_id_t * tid, int device)
Packit 4a16fb
{
Packit 4a16fb
	assert(tid);
Packit 4a16fb
	tid->device = device;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief get timer device
Packit 4a16fb
 * \param tid pointer to #snd_timer_id_t structure
Packit 4a16fb
 * \return timer device number
Packit 4a16fb
 */
Packit 4a16fb
int snd_timer_id_get_device(snd_timer_id_t * tid)
Packit 4a16fb
{
Packit 4a16fb
	assert(tid);
Packit 4a16fb
	return tid->device;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief set timer subdevice
Packit 4a16fb
 * \param tid pointer to #snd_timer_id_t structure
Packit 4a16fb
 * \param subdevice subdevice number
Packit 4a16fb
 */
Packit 4a16fb
void snd_timer_id_set_subdevice(snd_timer_id_t * tid, int subdevice)
Packit 4a16fb
{
Packit 4a16fb
	assert(tid);
Packit 4a16fb
	tid->subdevice = subdevice;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief get timer subdevice
Packit 4a16fb
 * \param tid pointer to #snd_timer_id_t structure
Packit 4a16fb
 * \return timer subdevice number
Packit 4a16fb
 */
Packit 4a16fb
int snd_timer_id_get_subdevice(snd_timer_id_t * tid)
Packit 4a16fb
{
Packit 4a16fb
	assert(tid);
Packit 4a16fb
	return tid->subdevice;
Packit 4a16fb
}