Blame src/pcm/pcm_local.h

Packit 4a16fb
/*
Packit 4a16fb
 *  PCM Interface - local header file
Packit 4a16fb
 *  Copyright (c) 2000 by Jaroslav Kysela <perex@perex.cz>
Packit 4a16fb
 *                        Abramo Bagnara <abramo@alsa-project.org>
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 <stdio.h>
Packit 4a16fb
#include <stdlib.h>
Packit 4a16fb
#include <limits.h>
Packit 4a16fb
#include <sys/uio.h>
Packit 4a16fb
#include <time.h>
Packit 4a16fb
#include <sys/time.h>
Packit 4a16fb
Packit 4a16fb
#define _snd_mask sndrv_mask
Packit 4a16fb
#define _snd_pcm_access_mask _snd_mask
Packit 4a16fb
#define _snd_pcm_format_mask _snd_mask
Packit 4a16fb
#define _snd_pcm_subformat_mask _snd_mask
Packit 4a16fb
Packit 4a16fb
#include "local.h"
Packit 4a16fb
Packit 4a16fb
#ifdef THREAD_SAFE_API
Packit 4a16fb
#define __USE_UNIX98 1	/* for old glibc */
Packit 4a16fb
#include <pthread.h>
Packit 4a16fb
#endif
Packit 4a16fb
Packit 4a16fb
#define SND_INTERVAL_INLINE
Packit 4a16fb
#include "interval.h"
Packit 4a16fb
Packit 4a16fb
#define SND_MASK_INLINE
Packit 4a16fb
#include "mask.h"
Packit 4a16fb
Packit 4a16fb
#define SND_PCM_HW_PARAM_ACCESS SNDRV_PCM_HW_PARAM_ACCESS
Packit 4a16fb
#define SND_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_FIRST_MASK
Packit 4a16fb
#define SND_PCM_HW_PARAM_FORMAT SNDRV_PCM_HW_PARAM_FORMAT
Packit 4a16fb
#define SND_PCM_HW_PARAM_SUBFORMAT SNDRV_PCM_HW_PARAM_SUBFORMAT
Packit 4a16fb
#define SND_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_LAST_MASK
Packit 4a16fb
#define SND_PCM_HW_PARAM_SAMPLE_BITS SNDRV_PCM_HW_PARAM_SAMPLE_BITS
Packit 4a16fb
#define SND_PCM_HW_PARAM_FIRST_INTERVAL SNDRV_PCM_HW_PARAM_FIRST_INTERVAL
Packit 4a16fb
#define SND_PCM_HW_PARAM_FRAME_BITS SNDRV_PCM_HW_PARAM_FRAME_BITS
Packit 4a16fb
#define SND_PCM_HW_PARAM_CHANNELS SNDRV_PCM_HW_PARAM_CHANNELS
Packit 4a16fb
#define SND_PCM_HW_PARAM_RATE SNDRV_PCM_HW_PARAM_RATE
Packit 4a16fb
#define SND_PCM_HW_PARAM_PERIOD_TIME SNDRV_PCM_HW_PARAM_PERIOD_TIME
Packit 4a16fb
#define SND_PCM_HW_PARAM_PERIOD_SIZE SNDRV_PCM_HW_PARAM_PERIOD_SIZE
Packit 4a16fb
#define SND_PCM_HW_PARAM_PERIOD_BYTES SNDRV_PCM_HW_PARAM_PERIOD_BYTES
Packit 4a16fb
#define SND_PCM_HW_PARAM_PERIODS SNDRV_PCM_HW_PARAM_PERIODS
Packit 4a16fb
#define SND_PCM_HW_PARAM_BUFFER_TIME SNDRV_PCM_HW_PARAM_BUFFER_TIME
Packit 4a16fb
#define SND_PCM_HW_PARAM_BUFFER_SIZE SNDRV_PCM_HW_PARAM_BUFFER_SIZE
Packit 4a16fb
#define SND_PCM_HW_PARAM_BUFFER_BYTES SNDRV_PCM_HW_PARAM_BUFFER_BYTES
Packit 4a16fb
#define SND_PCM_HW_PARAM_TICK_TIME SNDRV_PCM_HW_PARAM_TICK_TIME
Packit 4a16fb
#define SND_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_LAST_INTERVAL
Packit 4a16fb
#define SND_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_LAST_MASK
Packit 4a16fb
#define SND_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_FIRST_MASK
Packit 4a16fb
#define SND_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_LAST_INTERVAL
Packit 4a16fb
#define SND_PCM_HW_PARAM_FIRST_INTERVAL SNDRV_PCM_HW_PARAM_FIRST_INTERVAL
Packit 4a16fb
Packit 4a16fb
/** device accepts mmaped access */
Packit 4a16fb
#define SND_PCM_INFO_MMAP SNDRV_PCM_INFO_MMAP
Packit 4a16fb
/** device accepts  mmaped access with sample resolution */
Packit 4a16fb
#define SND_PCM_INFO_MMAP_VALID SNDRV_PCM_INFO_MMAP_VALID
Packit 4a16fb
/** device is doing double buffering */
Packit 4a16fb
#define SND_PCM_INFO_DOUBLE SNDRV_PCM_INFO_DOUBLE
Packit 4a16fb
/** device transfers samples in batch */
Packit 4a16fb
#define SND_PCM_INFO_BATCH SNDRV_PCM_INFO_BATCH
Packit 4a16fb
/** device accepts interleaved samples */
Packit 4a16fb
#define SND_PCM_INFO_INTERLEAVED SNDRV_PCM_INFO_INTERLEAVED
Packit 4a16fb
/** device accepts non-interleaved samples */
Packit 4a16fb
#define SND_PCM_INFO_NONINTERLEAVED SNDRV_PCM_INFO_NONINTERLEAVED
Packit 4a16fb
/** device accepts complex sample organization */
Packit 4a16fb
#define SND_PCM_INFO_COMPLEX SNDRV_PCM_INFO_COMPLEX
Packit 4a16fb
/** device is capable block transfers */
Packit 4a16fb
#define SND_PCM_INFO_BLOCK_TRANSFER SNDRV_PCM_INFO_BLOCK_TRANSFER
Packit 4a16fb
/** device can detect DAC/ADC overrange */
Packit 4a16fb
#define SND_PCM_INFO_OVERRANGE SNDRV_PCM_INFO_OVERRANGE
Packit 4a16fb
/** device supports resume */
Packit 4a16fb
#define SND_PCM_INFO_RESUME SNDRV_PCM_INFO_RESUME
Packit 4a16fb
/** device is capable to pause */
Packit 4a16fb
#define SND_PCM_INFO_PAUSE SNDRV_PCM_INFO_PAUSE
Packit 4a16fb
/** device can do only half duplex */
Packit 4a16fb
#define SND_PCM_INFO_HALF_DUPLEX SNDRV_PCM_INFO_HALF_DUPLEX
Packit 4a16fb
/** device can do only joint duplex (same parameters) */
Packit 4a16fb
#define SND_PCM_INFO_JOINT_DUPLEX SNDRV_PCM_INFO_JOINT_DUPLEX
Packit 4a16fb
/** device can do a kind of synchronized start */
Packit 4a16fb
#define SND_PCM_INFO_SYNC_START SNDRV_PCM_INFO_SYNC_START
Packit 4a16fb
/** device can disable period wakeups */
Packit 4a16fb
#define SND_PCM_INFO_NO_PERIOD_WAKEUP SNDRV_PCM_INFO_NO_PERIOD_WAKEUP
Packit 4a16fb
Packit 4a16fb
#define SND_PCM_HW_PARAMS_NORESAMPLE SNDRV_PCM_HW_PARAMS_NORESAMPLE
Packit 4a16fb
#define SND_PCM_HW_PARAMS_EXPORT_BUFFER SNDRV_PCM_HW_PARAMS_EXPORT_BUFFER
Packit 4a16fb
#define SND_PCM_HW_PARAMS_NO_PERIOD_WAKEUP SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP
Packit 4a16fb
Packit 4a16fb
#define SND_PCM_INFO_MONOTONIC	0x80000000
Packit 4a16fb
Packit 4a16fb
typedef struct _snd_pcm_rbptr {
Packit 4a16fb
	snd_pcm_t *master;
Packit 4a16fb
	volatile snd_pcm_uframes_t *ptr;
Packit 4a16fb
	int fd;
Packit 4a16fb
	off_t offset;
Packit 4a16fb
	int link_dst_count;
Packit 4a16fb
	snd_pcm_t **link_dst;
Packit 4a16fb
	void *private_data;
Packit 4a16fb
	void (*changed)(snd_pcm_t *pcm, snd_pcm_t *src);
Packit 4a16fb
} snd_pcm_rbptr_t;
Packit 4a16fb
Packit 4a16fb
typedef struct _snd_pcm_channel_info {
Packit 4a16fb
	unsigned int channel;
Packit 4a16fb
	void *addr;			/* base address of channel samples */
Packit 4a16fb
	unsigned int first;		/* offset to first sample in bits */
Packit 4a16fb
	unsigned int step;		/* samples distance in bits */
Packit 4a16fb
	enum { SND_PCM_AREA_SHM, SND_PCM_AREA_MMAP, SND_PCM_AREA_LOCAL } type;
Packit 4a16fb
	union {
Packit 4a16fb
		struct {
Packit 4a16fb
			struct snd_shm_area *area;
Packit 4a16fb
			int shmid;
Packit 4a16fb
		} shm;
Packit 4a16fb
		struct {
Packit 4a16fb
			int fd;
Packit 4a16fb
			off_t offset;
Packit 4a16fb
		} mmap;
Packit 4a16fb
	} u;
Packit 4a16fb
	char reserved[64];
Packit 4a16fb
} snd_pcm_channel_info_t;
Packit 4a16fb
Packit 4a16fb
typedef struct {
Packit 4a16fb
	int (*close)(snd_pcm_t *pcm);
Packit 4a16fb
	int (*nonblock)(snd_pcm_t *pcm, int nonblock); /* always locked */
Packit 4a16fb
	int (*async)(snd_pcm_t *pcm, int sig, pid_t pid);
Packit 4a16fb
	int (*info)(snd_pcm_t *pcm, snd_pcm_info_t *info);
Packit 4a16fb
	int (*hw_refine)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
Packit 4a16fb
	int (*hw_params)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
Packit 4a16fb
	int (*hw_free)(snd_pcm_t *pcm);
Packit 4a16fb
	int (*sw_params)(snd_pcm_t *pcm, snd_pcm_sw_params_t *params); /* always locked */
Packit 4a16fb
	int (*channel_info)(snd_pcm_t *pcm, snd_pcm_channel_info_t *info);
Packit 4a16fb
	void (*dump)(snd_pcm_t *pcm, snd_output_t *out);
Packit 4a16fb
	int (*mmap)(snd_pcm_t *pcm);
Packit 4a16fb
	int (*munmap)(snd_pcm_t *pcm);
Packit 4a16fb
	snd_pcm_chmap_query_t **(*query_chmaps)(snd_pcm_t *pcm);
Packit 4a16fb
	snd_pcm_chmap_t *(*get_chmap)(snd_pcm_t *pcm);
Packit 4a16fb
	int (*set_chmap)(snd_pcm_t *pcm, const snd_pcm_chmap_t *map);
Packit 4a16fb
} snd_pcm_ops_t;
Packit 4a16fb
Packit 4a16fb
typedef struct {
Packit 4a16fb
	int (*status)(snd_pcm_t *pcm, snd_pcm_status_t *status); /* locked */
Packit 4a16fb
	int (*prepare)(snd_pcm_t *pcm); /* locked */
Packit 4a16fb
	int (*reset)(snd_pcm_t *pcm); /* locked */
Packit 4a16fb
	int (*start)(snd_pcm_t *pcm); /* locked */
Packit 4a16fb
	int (*drop)(snd_pcm_t *pcm); /* locked */
Packit 4a16fb
	int (*drain)(snd_pcm_t *pcm); /* need own locking */
Packit 4a16fb
	int (*pause)(snd_pcm_t *pcm, int enable); /* locked */
Packit 4a16fb
	snd_pcm_state_t (*state)(snd_pcm_t *pcm); /* locked */
Packit 4a16fb
	int (*hwsync)(snd_pcm_t *pcm); /* locked */
Packit 4a16fb
	int (*delay)(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp); /* locked */
Packit 4a16fb
	int (*resume)(snd_pcm_t *pcm); /* need own locking */
Packit 4a16fb
	int (*link)(snd_pcm_t *pcm1, snd_pcm_t *pcm2);
Packit 4a16fb
	int (*link_slaves)(snd_pcm_t *pcm, snd_pcm_t *master);
Packit 4a16fb
	int (*unlink)(snd_pcm_t *pcm);
Packit 4a16fb
	snd_pcm_sframes_t (*rewindable)(snd_pcm_t *pcm); /* locked */
Packit 4a16fb
	snd_pcm_sframes_t (*rewind)(snd_pcm_t *pcm, snd_pcm_uframes_t frames); /* locked */
Packit 4a16fb
	snd_pcm_sframes_t (*forwardable)(snd_pcm_t *pcm); /* locked */
Packit 4a16fb
	snd_pcm_sframes_t (*forward)(snd_pcm_t *pcm, snd_pcm_uframes_t frames); /* locked */
Packit 4a16fb
	snd_pcm_sframes_t (*writei)(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size); /* need own locking */
Packit 4a16fb
	snd_pcm_sframes_t (*writen)(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size); /* need own locking */
Packit 4a16fb
	snd_pcm_sframes_t (*readi)(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size); /* need own locking */
Packit 4a16fb
	snd_pcm_sframes_t (*readn)(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size); /* need own locking */
Packit 4a16fb
	snd_pcm_sframes_t (*avail_update)(snd_pcm_t *pcm); /* locked */
Packit 4a16fb
	snd_pcm_sframes_t (*mmap_commit)(snd_pcm_t *pcm, snd_pcm_uframes_t offset, snd_pcm_uframes_t size); /* locked */
Packit 4a16fb
	int (*htimestamp)(snd_pcm_t *pcm, snd_pcm_uframes_t *avail, snd_htimestamp_t *tstamp); /* locked */
Packit 4a16fb
	int (*poll_descriptors_count)(snd_pcm_t *pcm); /* locked */
Packit 4a16fb
	int (*poll_descriptors)(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space); /* locked */
Packit 4a16fb
	int (*poll_revents)(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int nfds, unsigned short *revents); /* locked */
Packit 4a16fb
	int (*may_wait_for_avail_min)(snd_pcm_t *pcm, snd_pcm_uframes_t avail);
Packit 4a16fb
	int (*mmap_begin)(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas, snd_pcm_uframes_t *offset, snd_pcm_uframes_t *frames); /* locked */
Packit 4a16fb
} snd_pcm_fast_ops_t;
Packit 4a16fb
Packit 4a16fb
struct _snd_pcm {
Packit 4a16fb
	void *open_func;
Packit 4a16fb
	char *name;
Packit 4a16fb
	snd_pcm_type_t type;
Packit 4a16fb
	snd_pcm_stream_t stream;
Packit 4a16fb
	int mode;
Packit 4a16fb
	long minperiodtime;		/* in us */
Packit 4a16fb
	int poll_fd_count;
Packit 4a16fb
	int poll_fd;
Packit 4a16fb
	unsigned short poll_events;
Packit 4a16fb
	int setup: 1,
Packit 4a16fb
	    compat: 1;
Packit 4a16fb
	snd_pcm_access_t access;	/* access mode */
Packit 4a16fb
	snd_pcm_format_t format;	/* SND_PCM_FORMAT_* */
Packit 4a16fb
	snd_pcm_subformat_t subformat;	/* subformat */
Packit 4a16fb
	unsigned int channels;		/* channels */
Packit 4a16fb
	unsigned int rate;		/* rate in Hz */
Packit 4a16fb
	snd_pcm_uframes_t period_size;
Packit 4a16fb
	unsigned int period_time;	/* period duration */
Packit 4a16fb
	snd_interval_t periods;
Packit 4a16fb
	snd_pcm_tstamp_t tstamp_mode;	/* timestamp mode */
Packit 4a16fb
	snd_pcm_tstamp_type_t tstamp_type;	/* timestamp type */
Packit 4a16fb
	unsigned int period_step;
Packit 4a16fb
	snd_pcm_uframes_t avail_min;	/* min avail frames for wakeup */
Packit 4a16fb
	int period_event;
Packit 4a16fb
	snd_pcm_uframes_t start_threshold;
Packit 4a16fb
	snd_pcm_uframes_t stop_threshold;
Packit 4a16fb
	snd_pcm_uframes_t silence_threshold;	/* Silence filling happens when
Packit 4a16fb
					   noise is nearest than this */
Packit 4a16fb
	snd_pcm_uframes_t silence_size;	/* Silence filling size */
Packit 4a16fb
	snd_pcm_uframes_t boundary;	/* pointers wrap point */
Packit 4a16fb
	unsigned int info;		/* Info for returned setup */
Packit 4a16fb
	unsigned int msbits;		/* used most significant bits */
Packit 4a16fb
	unsigned int rate_num;		/* rate numerator */
Packit 4a16fb
	unsigned int rate_den;		/* rate denominator */
Packit 4a16fb
	unsigned int hw_flags;		/* actual hardware flags */
Packit 4a16fb
	snd_pcm_uframes_t fifo_size;	/* chip FIFO size in frames */
Packit 4a16fb
	snd_pcm_uframes_t buffer_size;
Packit 4a16fb
	snd_interval_t buffer_time;
Packit 4a16fb
	unsigned int sample_bits;
Packit 4a16fb
	unsigned int frame_bits;
Packit 4a16fb
	snd_pcm_rbptr_t appl;
Packit 4a16fb
	snd_pcm_rbptr_t hw;
Packit 4a16fb
	snd_pcm_uframes_t min_align;
Packit 4a16fb
	unsigned int mmap_rw: 1;	/* use always mmapped buffer */
Packit 4a16fb
	unsigned int mmap_shadow: 1;	/* don't call actual mmap,
Packit 4a16fb
					 * use the mmaped buffer of the slave
Packit 4a16fb
					 */
Packit 4a16fb
	unsigned int donot_close: 1;	/* don't close this PCM */
Packit 4a16fb
	unsigned int own_state_check:1; /* plugin has own PCM state check */
Packit 4a16fb
	snd_pcm_channel_info_t *mmap_channels;
Packit 4a16fb
	snd_pcm_channel_area_t *running_areas;
Packit 4a16fb
	snd_pcm_channel_area_t *stopped_areas;
Packit 4a16fb
	const snd_pcm_ops_t *ops;
Packit 4a16fb
	const snd_pcm_fast_ops_t *fast_ops;
Packit 4a16fb
	snd_pcm_t *op_arg;
Packit 4a16fb
	snd_pcm_t *fast_op_arg;
Packit 4a16fb
	void *private_data;
Packit 4a16fb
	struct list_head async_handlers;
Packit 4a16fb
#ifdef THREAD_SAFE_API
Packit 4a16fb
	int need_lock;		/* true = this PCM (plugin) is thread-unsafe,
Packit 4a16fb
				 * thus it needs a lock.
Packit 4a16fb
				 */
Packit 4a16fb
	int lock_enabled;	/* thread-safety lock is enabled on the system;
Packit 4a16fb
				 * it's set depending on $LIBASOUND_THREAD_SAFE.
Packit 4a16fb
				 */
Packit 4a16fb
	pthread_mutex_t lock;
Packit 4a16fb
#endif
Packit 4a16fb
};
Packit 4a16fb
Packit 4a16fb
/* make local functions really local */
Packit 4a16fb
/* Grrr, these cannot be local - a bad aserver uses them!
Packit 4a16fb
#define snd_pcm_async \
Packit 4a16fb
	snd1_pcm_async
Packit 4a16fb
#define snd_pcm_mmap \
Packit 4a16fb
	snd1_pcm_mmap
Packit 4a16fb
#define snd_pcm_munmap \
Packit 4a16fb
	snd1_pcm_munmap
Packit 4a16fb
#define snd_pcm_hw_refine \
Packit 4a16fb
	snd1_pcm_hw_refine
Packit 4a16fb
*/
Packit 4a16fb
#define snd_pcm_new \
Packit 4a16fb
	snd1_pcm_new
Packit 4a16fb
#define snd_pcm_free \
Packit 4a16fb
	snd1_pcm_free
Packit 4a16fb
#define snd_pcm_areas_from_buf \
Packit 4a16fb
	snd1_pcm_areas_from_buf
Packit 4a16fb
#define snd_pcm_areas_from_bufs \
Packit 4a16fb
	snd1_pcm_areas_from_bufs
Packit 4a16fb
#define snd_pcm_open_named_slave \
Packit 4a16fb
	snd1_pcm_open_named_slave
Packit 4a16fb
#define snd_pcm_hw_open_fd \
Packit 4a16fb
	snd1_pcm_hw_open_fd
Packit 4a16fb
#define snd_pcm_wait_nocheck \
Packit 4a16fb
	snd1_pcm_wait_nocheck
Packit 4a16fb
#define snd_pcm_rate_get_default_converter \
Packit 4a16fb
	snd1_pcm_rate_get_default_converter
Packit 4a16fb
#define snd_pcm_set_hw_ptr \
Packit 4a16fb
	snd1_pcm_set_hw_ptr
Packit 4a16fb
#define snd_pcm_set_appl_ptr \
Packit 4a16fb
	snd1_pcm_set_appl_ptr
Packit 4a16fb
#define snd_pcm_link_hw_ptr \
Packit 4a16fb
	snd1_pcm_link_hw_ptr
Packit 4a16fb
#define snd_pcm_link_appl_ptr \
Packit 4a16fb
	snd1_pcm_link_appl_ptr
Packit 4a16fb
#define snd_pcm_unlink_hw_ptr \
Packit 4a16fb
	snd1_pcm_unlink_hw_ptr
Packit 4a16fb
#define snd_pcm_unlink_appl_ptr \
Packit 4a16fb
	snd1_pcm_unlink_appl_ptr
Packit 4a16fb
#define snd_pcm_mmap_appl_ptr \
Packit 4a16fb
	snd1_pcm_mmap_appl_ptr
Packit 4a16fb
#define snd_pcm_mmap_appl_backward \
Packit 4a16fb
	snd1_pcm_mmap_appl_backward
Packit 4a16fb
#define snd_pcm_mmap_appl_forward \
Packit 4a16fb
	snd1_pcm_mmap_appl_forward
Packit 4a16fb
#define snd_pcm_mmap_hw_backward \
Packit 4a16fb
	snd1_pcm_mmap_hw_backward
Packit 4a16fb
#define snd_pcm_mmap_hw_forward \
Packit 4a16fb
	snd1_pcm_mmap_hw_forward
Packit 4a16fb
#define snd_pcm_read_areas \
Packit 4a16fb
	snd1_pcm_read_areas
Packit 4a16fb
#define snd_pcm_write_areas \
Packit 4a16fb
	snd1_pcm_write_areas
Packit 4a16fb
#define snd_pcm_read_mmap \
Packit 4a16fb
	snd1_pcm_read_mmap
Packit 4a16fb
#define snd_pcm_write_mmap \
Packit 4a16fb
	snd1_pcm_write_mmap
Packit 4a16fb
#define snd_pcm_channel_info_shm \
Packit 4a16fb
	snd1_pcm_channel_info_shm
Packit 4a16fb
#define snd_pcm_hw_refine_soft \
Packit 4a16fb
	snd1_pcm_hw_refine_soft
Packit 4a16fb
#define snd_pcm_hw_refine_slave \
Packit 4a16fb
	snd1_pcm_hw_refine_slave
Packit 4a16fb
#define snd_pcm_hw_params_slave \
Packit 4a16fb
	snd1_pcm_hw_params_slave
Packit 4a16fb
#define snd_pcm_hw_param_refine_near \
Packit 4a16fb
	snd1_pcm_hw_param_refine_near
Packit 4a16fb
#define snd_pcm_hw_param_refine_multiple \
Packit 4a16fb
	snd1_pcm_hw_param_refine_multiple
Packit 4a16fb
#define snd_pcm_hw_param_empty \
Packit 4a16fb
	snd1_pcm_hw_param_empty
Packit 4a16fb
#define snd_pcm_hw_param_always_eq \
Packit 4a16fb
	snd1_pcm_hw_param_always_eq
Packit 4a16fb
#define snd_pcm_hw_param_never_eq \
Packit 4a16fb
	snd1_pcm_hw_param_never_eq
Packit 4a16fb
#define snd_pcm_hw_param_get_mask \
Packit 4a16fb
	snd1_pcm_hw_param_get_mask
Packit 4a16fb
#define snd_pcm_hw_param_get_interval \
Packit 4a16fb
	snd1_pcm_hw_param_get_interval
Packit 4a16fb
#define snd_pcm_hw_param_any \
Packit 4a16fb
	snd1_pcm_hw_param_any
Packit 4a16fb
#define snd_pcm_hw_param_set_integer \
Packit 4a16fb
	snd1_pcm_hw_param_set_integer
Packit 4a16fb
#define snd_pcm_hw_param_set_first \
Packit 4a16fb
	snd1_pcm_hw_param_set_first
Packit 4a16fb
#define snd_pcm_hw_param_set_last \
Packit 4a16fb
	snd1_pcm_hw_param_set_last
Packit 4a16fb
#define snd_pcm_hw_param_set_near \
Packit 4a16fb
	snd1_pcm_hw_param_set_near
Packit 4a16fb
#define snd_pcm_hw_param_set_min \
Packit 4a16fb
	snd1_pcm_hw_param_set_min
Packit 4a16fb
#define snd_pcm_hw_param_set_max \
Packit 4a16fb
	snd1_pcm_hw_param_set_max
Packit 4a16fb
#define snd_pcm_hw_param_set_minmax \
Packit 4a16fb
	snd1_pcm_hw_param_set_minmax
Packit 4a16fb
#define snd_pcm_hw_param_set \
Packit 4a16fb
	snd1_pcm_hw_param_set
Packit 4a16fb
#define snd_pcm_hw_param_set_mask \
Packit 4a16fb
	snd1_pcm_hw_param_set_mask
Packit 4a16fb
#define snd_pcm_hw_param_get \
Packit 4a16fb
	snd1_pcm_hw_param_get
Packit 4a16fb
#define snd_pcm_hw_param_get_min \
Packit 4a16fb
	snd1_pcm_hw_param_get_min
Packit 4a16fb
#define snd_pcm_hw_param_get_max \
Packit 4a16fb
	snd1_pcm_hw_param_get_max
Packit 4a16fb
#define snd_pcm_hw_param_name		\
Packit 4a16fb
	snd1_pcm_hw_param_name
Packit 4a16fb
Packit 4a16fb
int snd_pcm_new(snd_pcm_t **pcmp, snd_pcm_type_t type, const char *name,
Packit 4a16fb
		snd_pcm_stream_t stream, int mode);
Packit 4a16fb
int snd_pcm_free(snd_pcm_t *pcm);
Packit 4a16fb
Packit 4a16fb
void snd_pcm_areas_from_buf(snd_pcm_t *pcm, snd_pcm_channel_area_t *areas, void *buf);
Packit 4a16fb
void snd_pcm_areas_from_bufs(snd_pcm_t *pcm, snd_pcm_channel_area_t *areas, void **bufs);
Packit 4a16fb
Packit 4a16fb
int snd_pcm_async(snd_pcm_t *pcm, int sig, pid_t pid);
Packit 4a16fb
int snd_pcm_mmap(snd_pcm_t *pcm);
Packit 4a16fb
int snd_pcm_munmap(snd_pcm_t *pcm);
Packit 4a16fb
int snd_pcm_mmap_ready(snd_pcm_t *pcm);
Packit 4a16fb
void snd_pcm_set_hw_ptr(snd_pcm_t *pcm, volatile snd_pcm_uframes_t *hw_ptr, int fd, off_t offset);
Packit 4a16fb
void snd_pcm_set_appl_ptr(snd_pcm_t *pcm, volatile snd_pcm_uframes_t *appl_ptr, int fd, off_t offset);
Packit 4a16fb
void snd_pcm_link_hw_ptr(snd_pcm_t *pcm, snd_pcm_t *slave);
Packit 4a16fb
void snd_pcm_link_appl_ptr(snd_pcm_t *pcm, snd_pcm_t *slave);
Packit 4a16fb
void snd_pcm_unlink_hw_ptr(snd_pcm_t *pcm, snd_pcm_t *slave);
Packit 4a16fb
void snd_pcm_unlink_appl_ptr(snd_pcm_t *pcm, snd_pcm_t *slave);
Packit 4a16fb
snd_pcm_sframes_t snd_pcm_mmap_appl_ptr(snd_pcm_t *pcm, off_t offset);
Packit 4a16fb
void snd_pcm_mmap_appl_backward(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
Packit 4a16fb
void snd_pcm_mmap_appl_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
Packit 4a16fb
void snd_pcm_mmap_hw_backward(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
Packit 4a16fb
void snd_pcm_mmap_hw_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
Packit 4a16fb
Packit 4a16fb
snd_pcm_sframes_t snd_pcm_mmap_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
Packit 4a16fb
snd_pcm_sframes_t snd_pcm_mmap_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size);
Packit 4a16fb
snd_pcm_sframes_t snd_pcm_mmap_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
Packit 4a16fb
snd_pcm_sframes_t snd_pcm_mmap_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
Packit 4a16fb
Packit 4a16fb
typedef snd_pcm_sframes_t (*snd_pcm_xfer_areas_func_t)(snd_pcm_t *pcm, 
Packit 4a16fb
						       const snd_pcm_channel_area_t *areas,
Packit 4a16fb
						       snd_pcm_uframes_t offset, 
Packit 4a16fb
						       snd_pcm_uframes_t size);
Packit 4a16fb
Packit 4a16fb
snd_pcm_sframes_t snd_pcm_read_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_t *areas,
Packit 4a16fb
				     snd_pcm_uframes_t offset, snd_pcm_uframes_t size,
Packit 4a16fb
				     snd_pcm_xfer_areas_func_t func);
Packit 4a16fb
snd_pcm_sframes_t snd_pcm_write_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_t *areas,
Packit 4a16fb
				      snd_pcm_uframes_t offset, snd_pcm_uframes_t size,
Packit 4a16fb
				      snd_pcm_xfer_areas_func_t func);
Packit 4a16fb
snd_pcm_sframes_t snd_pcm_read_mmap(snd_pcm_t *pcm, snd_pcm_uframes_t offset,
Packit 4a16fb
				    snd_pcm_uframes_t size);
Packit 4a16fb
snd_pcm_sframes_t snd_pcm_write_mmap(snd_pcm_t *pcm, snd_pcm_uframes_t offset,
Packit 4a16fb
				     snd_pcm_uframes_t size);
Packit 4a16fb
static inline int snd_pcm_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t *info)
Packit 4a16fb
{
Packit 4a16fb
	if (!pcm->ops->channel_info)
Packit 4a16fb
		return -ENOSYS;
Packit 4a16fb
	return pcm->ops->channel_info(pcm, info);
Packit 4a16fb
}
Packit 4a16fb
int snd_pcm_channel_info_shm(snd_pcm_t *pcm, snd_pcm_channel_info_t *info, int shmid);
Packit 4a16fb
int _snd_pcm_poll_descriptor(snd_pcm_t *pcm);
Packit 4a16fb
#define _snd_pcm_link_descriptor _snd_pcm_poll_descriptor /* FIXME */
Packit 4a16fb
#define _snd_pcm_async_descriptor _snd_pcm_poll_descriptor /* FIXME */
Packit 4a16fb
Packit 4a16fb
/* locked versions */
Packit 4a16fb
int __snd_pcm_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas,
Packit 4a16fb
			 snd_pcm_uframes_t *offset, snd_pcm_uframes_t *frames);
Packit 4a16fb
snd_pcm_sframes_t __snd_pcm_mmap_commit(snd_pcm_t *pcm,
Packit 4a16fb
					snd_pcm_uframes_t offset,
Packit 4a16fb
					snd_pcm_uframes_t frames);
Packit 4a16fb
int __snd_pcm_wait_in_lock(snd_pcm_t *pcm, int timeout);
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_sframes_t __snd_pcm_avail_update(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	if (!pcm->fast_ops->avail_update)
Packit 4a16fb
		return -ENOSYS;
Packit 4a16fb
	return pcm->fast_ops->avail_update(pcm->fast_op_arg);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline int __snd_pcm_start(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	if (!pcm->fast_ops->start)
Packit 4a16fb
		return -ENOSYS;
Packit 4a16fb
	return pcm->fast_ops->start(pcm->fast_op_arg);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_state_t __snd_pcm_state(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	if (!pcm->fast_ops->state)
Packit 4a16fb
		return -ENOSYS;
Packit 4a16fb
	return pcm->fast_ops->state(pcm->fast_op_arg);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline int __snd_pcm_hwsync(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	if (!pcm->fast_ops->hwsync)
Packit 4a16fb
		return -ENOSYS;
Packit 4a16fb
	return pcm->fast_ops->hwsync(pcm->fast_op_arg);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline int __snd_pcm_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
Packit 4a16fb
{
Packit 4a16fb
	if (!pcm->fast_ops->delay)
Packit 4a16fb
		return -ENOSYS;
Packit 4a16fb
	return pcm->fast_ops->delay(pcm->fast_op_arg, delayp);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/* handle special error cases */
Packit 4a16fb
static inline int snd_pcm_check_error(snd_pcm_t *pcm, int err)
Packit 4a16fb
{
Packit 4a16fb
	if (err == -EINTR) {
Packit 4a16fb
		switch (__snd_pcm_state(pcm)) {
Packit 4a16fb
		case SND_PCM_STATE_XRUN:
Packit 4a16fb
			return -EPIPE;
Packit 4a16fb
		case SND_PCM_STATE_SUSPENDED:
Packit 4a16fb
			return -ESTRPIPE;
Packit 4a16fb
		case SND_PCM_STATE_DISCONNECTED:
Packit 4a16fb
			return -ENODEV;
Packit 4a16fb
		default:
Packit 4a16fb
			break;
Packit 4a16fb
		}
Packit 4a16fb
	}
Packit 4a16fb
	return err;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_uframes_t __snd_pcm_playback_avail(snd_pcm_t *pcm,
Packit 4a16fb
							 const snd_pcm_uframes_t hw_ptr,
Packit 4a16fb
							 const snd_pcm_uframes_t appl_ptr)
Packit 4a16fb
{
Packit 4a16fb
	snd_pcm_sframes_t avail;
Packit 4a16fb
	avail = hw_ptr + pcm->buffer_size - appl_ptr;
Packit 4a16fb
	if (avail < 0)
Packit 4a16fb
		avail += pcm->boundary;
Packit 4a16fb
	else if ((snd_pcm_uframes_t) avail >= pcm->boundary)
Packit 4a16fb
		avail -= pcm->boundary;
Packit 4a16fb
	return avail;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_uframes_t snd_pcm_mmap_playback_avail(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	return __snd_pcm_playback_avail(pcm, *pcm->hw.ptr, *pcm->appl.ptr);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_uframes_t __snd_pcm_capture_avail(snd_pcm_t *pcm,
Packit 4a16fb
							const snd_pcm_uframes_t hw_ptr,
Packit 4a16fb
							const snd_pcm_uframes_t appl_ptr)
Packit 4a16fb
{
Packit 4a16fb
	snd_pcm_sframes_t avail;
Packit 4a16fb
	avail = hw_ptr - appl_ptr;
Packit 4a16fb
	if (avail < 0)
Packit 4a16fb
		avail += pcm->boundary;
Packit 4a16fb
	return avail;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_uframes_t snd_pcm_mmap_capture_avail(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	return __snd_pcm_capture_avail(pcm, *pcm->hw.ptr, *pcm->appl.ptr);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_uframes_t __snd_pcm_avail(snd_pcm_t *pcm,
Packit 4a16fb
						const snd_pcm_uframes_t hw_ptr,
Packit 4a16fb
						const snd_pcm_uframes_t appl_ptr)
Packit 4a16fb
{
Packit 4a16fb
	if (pcm->stream == SND_PCM_STREAM_PLAYBACK)
Packit 4a16fb
		return __snd_pcm_playback_avail(pcm, hw_ptr, appl_ptr);
Packit 4a16fb
	else
Packit 4a16fb
		return __snd_pcm_capture_avail(pcm, hw_ptr, appl_ptr);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_uframes_t snd_pcm_mmap_avail(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	return __snd_pcm_avail(pcm, *pcm->hw.ptr, *pcm->appl.ptr);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_sframes_t snd_pcm_mmap_playback_hw_avail(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	return pcm->buffer_size - snd_pcm_mmap_playback_avail(pcm);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_sframes_t snd_pcm_mmap_capture_hw_avail(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	return pcm->buffer_size - snd_pcm_mmap_capture_avail(pcm);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_sframes_t snd_pcm_mmap_hw_avail(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	return pcm->buffer_size - snd_pcm_mmap_avail(pcm);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_sframes_t snd_pcm_mmap_playback_hw_rewindable(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	snd_pcm_sframes_t ret = snd_pcm_mmap_playback_hw_avail(pcm);
Packit 4a16fb
	return (ret >= 0) ? ret : 0;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_sframes_t snd_pcm_mmap_capture_hw_rewindable(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	snd_pcm_sframes_t ret = snd_pcm_mmap_capture_hw_avail(pcm);
Packit 4a16fb
	return (ret >= 0) ? ret : 0;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_uframes_t snd_pcm_mmap_hw_rewindable(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	snd_pcm_sframes_t ret = snd_pcm_mmap_hw_avail(pcm);
Packit 4a16fb
	return (ret >= 0) ? ret : 0;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline const snd_pcm_channel_area_t *snd_pcm_mmap_areas(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	if (pcm->stopped_areas &&
Packit 4a16fb
	    __snd_pcm_state(pcm) != SND_PCM_STATE_RUNNING)
Packit 4a16fb
		return pcm->stopped_areas;
Packit 4a16fb
	return pcm->running_areas;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_uframes_t snd_pcm_mmap_offset(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
        assert(pcm);
Packit 4a16fb
	return *pcm->appl.ptr % pcm->buffer_size;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_uframes_t snd_pcm_mmap_hw_offset(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
        assert(pcm);
Packit 4a16fb
	return *pcm->hw.ptr % pcm->buffer_size;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_uframes_t snd_pcm_mmap_playback_delay(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	return snd_pcm_mmap_playback_hw_avail(pcm);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_uframes_t snd_pcm_mmap_capture_delay(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	return snd_pcm_mmap_capture_hw_avail(pcm);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_sframes_t snd_pcm_mmap_delay(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	if (pcm->stream == SND_PCM_STREAM_PLAYBACK)
Packit 4a16fb
		return snd_pcm_mmap_playback_delay(pcm);
Packit 4a16fb
	else
Packit 4a16fb
		return snd_pcm_mmap_capture_delay(pcm);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline void *snd_pcm_channel_area_addr(const snd_pcm_channel_area_t *area, snd_pcm_uframes_t offset)
Packit 4a16fb
{
Packit 4a16fb
	unsigned int bitofs = area->first + area->step * offset;
Packit 4a16fb
	assert(bitofs % 8 == 0);
Packit 4a16fb
	return (char *) area->addr + bitofs / 8;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline unsigned int snd_pcm_channel_area_step(const snd_pcm_channel_area_t *area)
Packit 4a16fb
{
Packit 4a16fb
	assert(area->step % 8 == 0);
Packit 4a16fb
	return area->step / 8;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_sframes_t _snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size)
Packit 4a16fb
{
Packit 4a16fb
	/* lock handled in the callback */
Packit 4a16fb
	if (!pcm->fast_ops->writei)
Packit 4a16fb
		return -ENOSYS;
Packit 4a16fb
	return pcm->fast_ops->writei(pcm->fast_op_arg, buffer, size);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_sframes_t _snd_pcm_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size)
Packit 4a16fb
{
Packit 4a16fb
	/* lock handled in the callback */
Packit 4a16fb
	if (!pcm->fast_ops->writen)
Packit 4a16fb
		return -ENOSYS;
Packit 4a16fb
	return pcm->fast_ops->writen(pcm->fast_op_arg, bufs, size);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_sframes_t _snd_pcm_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size)
Packit 4a16fb
{
Packit 4a16fb
	/* lock handled in the callback */
Packit 4a16fb
	if (!pcm->fast_ops->readi)
Packit 4a16fb
		return -ENOSYS;
Packit 4a16fb
	return pcm->fast_ops->readi(pcm->fast_op_arg, buffer, size);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline snd_pcm_sframes_t _snd_pcm_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size)
Packit 4a16fb
{
Packit 4a16fb
	/* lock handled in the callback */
Packit 4a16fb
	if (!pcm->fast_ops->readn)
Packit 4a16fb
		return -ENOSYS;
Packit 4a16fb
	return pcm->fast_ops->readn(pcm->fast_op_arg, bufs, size);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline int muldiv(int a, int b, int c, int *r)
Packit 4a16fb
{
Packit 4a16fb
	int64_t n = (int64_t)a * b;
Packit 4a16fb
	int64_t v = n / c;
Packit 4a16fb
	if (v > INT_MAX) {
Packit 4a16fb
		*r = 0;
Packit 4a16fb
		return INT_MAX;
Packit 4a16fb
	}
Packit 4a16fb
	if (v < INT_MIN) {
Packit 4a16fb
		*r = 0;
Packit 4a16fb
		return INT_MIN;
Packit 4a16fb
	}
Packit 4a16fb
	*r = n % c;
Packit 4a16fb
	return v;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline int muldiv_down(int a, int b, int c)
Packit 4a16fb
{
Packit 4a16fb
	int64_t v = (int64_t)a * b / c;
Packit 4a16fb
	if (v > INT_MAX) {
Packit 4a16fb
		return INT_MAX;
Packit 4a16fb
	}
Packit 4a16fb
	if (v < INT_MIN) {
Packit 4a16fb
		return INT_MIN;
Packit 4a16fb
	}
Packit 4a16fb
	return v;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline int muldiv_near(int a, int b, int c)
Packit 4a16fb
{
Packit 4a16fb
	int r;
Packit 4a16fb
	int n = muldiv(a, b, c, &r);
Packit 4a16fb
	if (r >= (c + 1) / 2)
Packit 4a16fb
		n++;
Packit 4a16fb
	return n;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
int snd_pcm_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
Packit 4a16fb
int _snd_pcm_hw_params_internal(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
Packit 4a16fb
#undef _snd_pcm_hw_params
Packit 4a16fb
int snd_pcm_hw_refine_soft(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
Packit 4a16fb
int snd_pcm_hw_refine_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
Packit 4a16fb
			    int (*cprepare)(snd_pcm_t *pcm,
Packit 4a16fb
					    snd_pcm_hw_params_t *params),
Packit 4a16fb
			    int (*cchange)(snd_pcm_t *pcm,
Packit 4a16fb
					   snd_pcm_hw_params_t *params,
Packit 4a16fb
					   snd_pcm_hw_params_t *sparams),
Packit 4a16fb
			    int (*sprepare)(snd_pcm_t *pcm,
Packit 4a16fb
					    snd_pcm_hw_params_t *params),
Packit 4a16fb
			    int (*schange)(snd_pcm_t *pcm,
Packit 4a16fb
					   snd_pcm_hw_params_t *params,
Packit 4a16fb
					   snd_pcm_hw_params_t *sparams),
Packit 4a16fb
			    int (*srefine)(snd_pcm_t *pcm,
Packit 4a16fb
					   snd_pcm_hw_params_t *sparams));
Packit 4a16fb
int snd_pcm_hw_params_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
Packit 4a16fb
			    int (*cchange)(snd_pcm_t *pcm,
Packit 4a16fb
					   snd_pcm_hw_params_t *params,
Packit 4a16fb
					   snd_pcm_hw_params_t *sparams),
Packit 4a16fb
			    int (*sprepare)(snd_pcm_t *pcm,
Packit 4a16fb
					    snd_pcm_hw_params_t *params),
Packit 4a16fb
			    int (*schange)(snd_pcm_t *pcm,
Packit 4a16fb
					   snd_pcm_hw_params_t *params,
Packit 4a16fb
					   snd_pcm_hw_params_t *sparams),
Packit 4a16fb
			    int (*sparams)(snd_pcm_t *pcm,
Packit 4a16fb
					   snd_pcm_hw_params_t *sparams));
Packit 4a16fb
Packit 4a16fb
Packit 4a16fb
void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params);
Packit 4a16fb
void _snd_pcm_hw_param_set_empty(snd_pcm_hw_params_t *params,
Packit 4a16fb
				 snd_pcm_hw_param_t var);
Packit 4a16fb
int _snd_pcm_hw_param_set_interval(snd_pcm_hw_params_t *params,
Packit 4a16fb
				   snd_pcm_hw_param_t var,
Packit 4a16fb
				   const snd_interval_t *val);
Packit 4a16fb
int _snd_pcm_hw_param_set_mask(snd_pcm_hw_params_t *params,
Packit 4a16fb
			   snd_pcm_hw_param_t var, const snd_mask_t *mask);
Packit 4a16fb
int _snd_pcm_hw_param_first(snd_pcm_hw_params_t *params,
Packit 4a16fb
			    snd_pcm_hw_param_t var);
Packit 4a16fb
int _snd_pcm_hw_param_last(snd_pcm_hw_params_t *params,
Packit 4a16fb
			   snd_pcm_hw_param_t var);
Packit 4a16fb
int _snd_pcm_hw_param_set(snd_pcm_hw_params_t *params,
Packit 4a16fb
			  snd_pcm_hw_param_t var, unsigned int val, int dir);
Packit 4a16fb
static inline int _snd_pcm_hw_params_set_format(snd_pcm_hw_params_t *params,
Packit 4a16fb
						snd_pcm_format_t val)
Packit 4a16fb
{
Packit 4a16fb
	return _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_FORMAT,
Packit 4a16fb
				     (unsigned long) val, 0);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline int _snd_pcm_hw_params_set_subformat(snd_pcm_hw_params_t *params,
Packit 4a16fb
				     snd_pcm_subformat_t val)
Packit 4a16fb
{
Packit 4a16fb
	return _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_SUBFORMAT,
Packit 4a16fb
				     (unsigned long) val, 0);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
int _snd_pcm_hw_param_set_min(snd_pcm_hw_params_t *params,
Packit 4a16fb
			      snd_pcm_hw_param_t var, unsigned int val, int dir);
Packit 4a16fb
int _snd_pcm_hw_param_set_max(snd_pcm_hw_params_t *params,
Packit 4a16fb
			      snd_pcm_hw_param_t var, unsigned int val, int dir);
Packit 4a16fb
int _snd_pcm_hw_param_set_minmax(snd_pcm_hw_params_t *params,
Packit 4a16fb
				 snd_pcm_hw_param_t var,
Packit 4a16fb
				 unsigned int min, int mindir,
Packit 4a16fb
				 unsigned int max, int maxdir);
Packit 4a16fb
int _snd_pcm_hw_param_refine(snd_pcm_hw_params_t *params,
Packit 4a16fb
			     snd_pcm_hw_param_t var,
Packit 4a16fb
			     const snd_pcm_hw_params_t *src);
Packit 4a16fb
int _snd_pcm_hw_params_refine(snd_pcm_hw_params_t *params,
Packit 4a16fb
			      unsigned int vars,
Packit 4a16fb
			      const snd_pcm_hw_params_t *src);
Packit 4a16fb
int snd_pcm_hw_param_refine_near(snd_pcm_t *pcm,
Packit 4a16fb
				 snd_pcm_hw_params_t *params,
Packit 4a16fb
				 snd_pcm_hw_param_t var,
Packit 4a16fb
				 const snd_pcm_hw_params_t *src);
Packit 4a16fb
int snd_pcm_hw_param_refine_multiple(snd_pcm_t *pcm,
Packit 4a16fb
				     snd_pcm_hw_params_t *params,
Packit 4a16fb
				     snd_pcm_hw_param_t var,
Packit 4a16fb
				     const snd_pcm_hw_params_t *src);
Packit 4a16fb
int snd_pcm_hw_param_empty(const snd_pcm_hw_params_t *params,
Packit 4a16fb
			   snd_pcm_hw_param_t var);
Packit 4a16fb
int snd_pcm_hw_param_always_eq(const snd_pcm_hw_params_t *params,
Packit 4a16fb
			       snd_pcm_hw_param_t var,
Packit 4a16fb
			       const snd_pcm_hw_params_t *params1);
Packit 4a16fb
int snd_pcm_hw_param_never_eq(const snd_pcm_hw_params_t *params,
Packit 4a16fb
			      snd_pcm_hw_param_t var,
Packit 4a16fb
			      const snd_pcm_hw_params_t *params1);
Packit 4a16fb
const snd_mask_t *snd_pcm_hw_param_get_mask(const snd_pcm_hw_params_t *params,
Packit 4a16fb
					      snd_pcm_hw_param_t var);
Packit 4a16fb
const snd_interval_t *snd_pcm_hw_param_get_interval(const snd_pcm_hw_params_t *params,
Packit 4a16fb
						      snd_pcm_hw_param_t var);
Packit 4a16fb
Packit 4a16fb
int snd_pcm_hw_param_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
Packit 4a16fb
			 snd_pcm_hw_param_t var);
Packit 4a16fb
int snd_pcm_hw_param_set_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
Packit 4a16fb
				 snd_set_mode_t mode,
Packit 4a16fb
				 snd_pcm_hw_param_t var);
Packit 4a16fb
int snd_pcm_hw_param_set_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
Packit 4a16fb
			       snd_pcm_hw_param_t var, unsigned int *rval, int *dir);
Packit 4a16fb
int snd_pcm_hw_param_set_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
Packit 4a16fb
			      snd_pcm_hw_param_t var, unsigned int *rval, int *dir);
Packit 4a16fb
int snd_pcm_hw_param_set_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
Packit 4a16fb
			      snd_pcm_hw_param_t var, unsigned int *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_param_set_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
Packit 4a16fb
			     snd_set_mode_t mode,
Packit 4a16fb
			     snd_pcm_hw_param_t var,
Packit 4a16fb
			     unsigned int *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_param_set_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
Packit 4a16fb
			     snd_set_mode_t mode,
Packit 4a16fb
			     snd_pcm_hw_param_t var, unsigned int *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_param_set_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
Packit 4a16fb
				snd_set_mode_t mode,
Packit 4a16fb
				snd_pcm_hw_param_t var,
Packit 4a16fb
				unsigned int *min, int *mindir,
Packit 4a16fb
				unsigned int *max, int *maxdir);
Packit 4a16fb
int snd_pcm_hw_param_set(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
Packit 4a16fb
			 snd_set_mode_t mode,
Packit 4a16fb
			 snd_pcm_hw_param_t var, unsigned int val, int dir);
Packit 4a16fb
int snd_pcm_hw_param_set_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
Packit 4a16fb
			      snd_set_mode_t mode,
Packit 4a16fb
			      snd_pcm_hw_param_t var, const snd_mask_t *mask);
Packit 4a16fb
int snd_pcm_hw_param_get(const snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var,
Packit 4a16fb
			 unsigned int *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_param_get_min(const snd_pcm_hw_params_t *params,
Packit 4a16fb
			     snd_pcm_hw_param_t var,
Packit 4a16fb
			     unsigned int *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_param_get_max(const snd_pcm_hw_params_t *params,
Packit 4a16fb
			     snd_pcm_hw_param_t var,
Packit 4a16fb
			     unsigned int *val, int *dir);
Packit 4a16fb
Packit 4a16fb
#ifdef INTERNAL
Packit 4a16fb
snd_pcm_sframes_t INTERNAL(snd_pcm_forward)(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
Packit 4a16fb
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_access)(const snd_pcm_hw_params_t *params, snd_pcm_access_t *access);
Packit 4a16fb
int snd_pcm_hw_params_test_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t access);
Packit 4a16fb
int snd_pcm_hw_params_set_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t access);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_access_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t *access);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_access_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t *access);
Packit 4a16fb
int snd_pcm_hw_params_set_access_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_mask_t *mask);
Packit 4a16fb
int snd_pcm_hw_params_get_access_mask(snd_pcm_hw_params_t *params, snd_pcm_access_mask_t *mask);
Packit 4a16fb
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_format)(const snd_pcm_hw_params_t *params, snd_pcm_format_t *val);
Packit 4a16fb
int snd_pcm_hw_params_test_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val);
Packit 4a16fb
int snd_pcm_hw_params_set_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_format_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t *format);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_format_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t *format);
Packit 4a16fb
int snd_pcm_hw_params_set_format_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_mask_t *mask);
Packit 4a16fb
void snd_pcm_hw_params_get_format_mask(snd_pcm_hw_params_t *params, snd_pcm_format_mask_t *mask);
Packit 4a16fb
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_subformat)(const snd_pcm_hw_params_t *params, snd_pcm_subformat_t *subformat);
Packit 4a16fb
int snd_pcm_hw_params_test_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t subformat);
Packit 4a16fb
int snd_pcm_hw_params_set_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t subformat);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_subformat_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t *subformat);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_subformat_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t *subformat);
Packit 4a16fb
int snd_pcm_hw_params_set_subformat_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_mask_t *mask);
Packit 4a16fb
void snd_pcm_hw_params_get_subformat_mask(snd_pcm_hw_params_t *params, snd_pcm_subformat_mask_t *mask);
Packit 4a16fb
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_channels)(const snd_pcm_hw_params_t *params, unsigned int *val);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_channels_min)(const snd_pcm_hw_params_t *params, unsigned int *val);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_channels_max)(const snd_pcm_hw_params_t *params, unsigned int *val);
Packit 4a16fb
int snd_pcm_hw_params_test_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
Packit 4a16fb
int snd_pcm_hw_params_set_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
Packit 4a16fb
int snd_pcm_hw_params_set_channels_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
Packit 4a16fb
int snd_pcm_hw_params_set_channels_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
Packit 4a16fb
int snd_pcm_hw_params_set_channels_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, unsigned int *max);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_channels_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_channels_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_channels_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
Packit 4a16fb
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_rate)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_rate_min)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_rate_max)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_params_test_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
Packit 4a16fb
int snd_pcm_hw_params_set_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
Packit 4a16fb
int snd_pcm_hw_params_set_rate_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_params_set_rate_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_params_set_rate_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_rate_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_rate_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_rate_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_period_time)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_period_time_min)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_period_time_max)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_params_test_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
Packit 4a16fb
int snd_pcm_hw_params_set_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
Packit 4a16fb
int snd_pcm_hw_params_set_period_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_params_set_period_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_params_set_period_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_period_time_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_period_time_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_period_time_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_period_size)(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_period_size_min)(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_period_size_max)(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
Packit 4a16fb
int snd_pcm_hw_params_test_period_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val, int dir);
Packit 4a16fb
int snd_pcm_hw_params_set_period_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val, int dir);
Packit 4a16fb
int snd_pcm_hw_params_set_period_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_params_set_period_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_params_set_period_size_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *min, int *mindir, snd_pcm_uframes_t *max, int *maxdir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_period_size_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_period_size_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_period_size_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_params_set_period_size_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
Packit 4a16fb
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_periods)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_periods_min)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_periods_max)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_params_test_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
Packit 4a16fb
int snd_pcm_hw_params_set_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
Packit 4a16fb
int snd_pcm_hw_params_set_periods_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_params_set_periods_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_params_set_periods_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_periods_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_periods_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_periods_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_params_set_periods_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
Packit 4a16fb
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_buffer_time)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_buffer_time_min)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_buffer_time_max)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_params_test_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
Packit 4a16fb
int snd_pcm_hw_params_set_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
Packit 4a16fb
int snd_pcm_hw_params_set_buffer_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_params_set_buffer_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int snd_pcm_hw_params_set_buffer_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_buffer_time_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_buffer_time_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_buffer_time_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
Packit 4a16fb
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_buffer_size)(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_buffer_size_min)(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_get_buffer_size_max)(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
Packit 4a16fb
int snd_pcm_hw_params_test_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val);
Packit 4a16fb
int snd_pcm_hw_params_set_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val);
Packit 4a16fb
int snd_pcm_hw_params_set_buffer_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
Packit 4a16fb
int snd_pcm_hw_params_set_buffer_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
Packit 4a16fb
int snd_pcm_hw_params_set_buffer_size_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *min, snd_pcm_uframes_t *max);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_buffer_size_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_buffer_size_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
Packit 4a16fb
int INTERNAL(snd_pcm_hw_params_set_buffer_size_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
Packit 4a16fb
Packit 4a16fb
int snd_pcm_sw_params_set_tstamp_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_tstamp_t val);
Packit 4a16fb
int INTERNAL(snd_pcm_sw_params_get_tstamp_mode)(const snd_pcm_sw_params_t *params, snd_pcm_tstamp_t *val);
Packit 4a16fb
int snd_pcm_sw_params_set_avail_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
Packit 4a16fb
int INTERNAL(snd_pcm_sw_params_get_avail_min)(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
Packit 4a16fb
int snd_pcm_sw_params_set_start_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
Packit 4a16fb
int INTERNAL(snd_pcm_sw_params_get_start_threshold)(const snd_pcm_sw_params_t *paramsm, snd_pcm_uframes_t *val);
Packit 4a16fb
int snd_pcm_sw_params_set_stop_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
Packit 4a16fb
int INTERNAL(snd_pcm_sw_params_get_stop_threshold)(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
Packit 4a16fb
int snd_pcm_sw_params_set_silence_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
Packit 4a16fb
int INTERNAL(snd_pcm_sw_params_get_silence_threshold)(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
Packit 4a16fb
int snd_pcm_sw_params_set_silence_size(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
Packit 4a16fb
int INTERNAL(snd_pcm_sw_params_get_silence_size)(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
Packit 4a16fb
#endif /* INTERNAL */
Packit 4a16fb
Packit 4a16fb
const char *snd_pcm_hw_param_name(snd_pcm_hw_param_t param);
Packit 4a16fb
void snd_pcm_hw_param_dump(const snd_pcm_hw_params_t *params,
Packit 4a16fb
			   snd_pcm_hw_param_t var, snd_output_t *out);
Packit 4a16fb
#if 0
Packit 4a16fb
int snd_pcm_hw_strategy_simple_near(snd_pcm_hw_strategy_t *strategy, int order,
Packit 4a16fb
				    snd_pcm_hw_param_t var,
Packit 4a16fb
				    unsigned int best,
Packit 4a16fb
				    unsigned int mul);
Packit 4a16fb
int snd_pcm_hw_strategy_simple_choices(snd_pcm_hw_strategy_t *strategy, int order,
Packit 4a16fb
				       snd_pcm_hw_param_t var,
Packit 4a16fb
				       unsigned int count,
Packit 4a16fb
				       snd_pcm_hw_strategy_simple_choices_list_t *choices);
Packit 4a16fb
#endif
Packit 4a16fb
Packit 4a16fb
#define SCONF_MANDATORY	1
Packit 4a16fb
#define SCONF_UNCHANGED	2
Packit 4a16fb
Packit 4a16fb
int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf,
Packit 4a16fb
		       snd_config_t **pcm_conf, unsigned int count, ...);
Packit 4a16fb
Packit 4a16fb
#define SND_PCM_APPEND	(1<<8)
Packit 4a16fb
Packit 4a16fb
int snd_pcm_open_named_slave(snd_pcm_t **pcmp, const char *name,
Packit 4a16fb
			     snd_config_t *root,
Packit 4a16fb
			     snd_config_t *conf, snd_pcm_stream_t stream,
Packit 4a16fb
			     int mode, snd_config_t *parent_conf);
Packit 4a16fb
static inline int
Packit 4a16fb
snd_pcm_open_slave(snd_pcm_t **pcmp, snd_config_t *root,
Packit 4a16fb
		   snd_config_t *conf, snd_pcm_stream_t stream,
Packit 4a16fb
		   int mode, snd_config_t *parent_conf)
Packit 4a16fb
{
Packit 4a16fb
	return snd_pcm_open_named_slave(pcmp, NULL, root, conf, stream,
Packit 4a16fb
					mode, parent_conf);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
#define snd_pcm_conf_generic_id(id) _snd_conf_generic_id(id)
Packit 4a16fb
Packit 4a16fb
int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd,
Packit 4a16fb
		       int sync_ptr_ioctl);
Packit 4a16fb
int __snd_pcm_mmap_emul_open(snd_pcm_t **pcmp, const char *name,
Packit 4a16fb
			     snd_pcm_t *slave, int close_slave);
Packit 4a16fb
Packit 4a16fb
int snd_pcm_wait_nocheck(snd_pcm_t *pcm, int timeout);
Packit 4a16fb
Packit 4a16fb
const snd_config_t *snd_pcm_rate_get_default_converter(snd_config_t *root);
Packit 4a16fb
Packit 4a16fb
#define SND_PCM_HW_PARBIT_ACCESS	(1U << SND_PCM_HW_PARAM_ACCESS)
Packit 4a16fb
#define SND_PCM_HW_PARBIT_FORMAT	(1U << SND_PCM_HW_PARAM_FORMAT)
Packit 4a16fb
#define SND_PCM_HW_PARBIT_SUBFORMAT	(1U << SND_PCM_HW_PARAM_SUBFORMAT)
Packit 4a16fb
#define SND_PCM_HW_PARBIT_CHANNELS	(1U << SND_PCM_HW_PARAM_CHANNELS)
Packit 4a16fb
#define SND_PCM_HW_PARBIT_RATE		(1U << SND_PCM_HW_PARAM_RATE)
Packit 4a16fb
#define SND_PCM_HW_PARBIT_PERIOD_TIME	(1U << SND_PCM_HW_PARAM_PERIOD_TIME)
Packit 4a16fb
#define SND_PCM_HW_PARBIT_PERIOD_SIZE	(1U << SND_PCM_HW_PARAM_PERIOD_SIZE)
Packit 4a16fb
#define SND_PCM_HW_PARBIT_PERIODS	(1U << SND_PCM_HW_PARAM_PERIODS)
Packit 4a16fb
#define SND_PCM_HW_PARBIT_BUFFER_TIME	(1U << SND_PCM_HW_PARAM_BUFFER_TIME)
Packit 4a16fb
#define SND_PCM_HW_PARBIT_BUFFER_SIZE	(1U << SND_PCM_HW_PARAM_BUFFER_SIZE)
Packit 4a16fb
#define SND_PCM_HW_PARBIT_SAMPLE_BITS	(1U << SND_PCM_HW_PARAM_SAMPLE_BITS)
Packit 4a16fb
#define SND_PCM_HW_PARBIT_FRAME_BITS	(1U << SND_PCM_HW_PARAM_FRAME_BITS)
Packit 4a16fb
#define SND_PCM_HW_PARBIT_PERIOD_BYTES	(1U << SND_PCM_HW_PARAM_PERIOD_BYTES)
Packit 4a16fb
#define SND_PCM_HW_PARBIT_BUFFER_BYTES	(1U << SND_PCM_HW_PARAM_BUFFER_BYTES)
Packit 4a16fb
#define SND_PCM_HW_PARBIT_TICK_TIME	(1U << SND_PCM_HW_PARAM_TICK_TIME)
Packit 4a16fb
Packit 4a16fb
Packit 4a16fb
#define SND_PCM_ACCBIT_MMAP { ((1U << SND_PCM_ACCESS_MMAP_INTERLEAVED) | \
Packit 4a16fb
			     (1U << SND_PCM_ACCESS_MMAP_NONINTERLEAVED) | \
Packit 4a16fb
			     (1U << SND_PCM_ACCESS_MMAP_COMPLEX)) }
Packit 4a16fb
#define SND_PCM_ACCBIT_MMAPI { (1U << SND_PCM_ACCESS_MMAP_INTERLEAVED) }
Packit 4a16fb
#define SND_PCM_ACCBIT_MMAPN { (1U << SND_PCM_ACCESS_MMAP_NONINTERLEAVED) }
Packit 4a16fb
#define SND_PCM_ACCBIT_MMAPC { (1U << SND_PCM_ACCESS_MMAP_COMPLEX) }
Packit 4a16fb
Packit 4a16fb
#define SND_PCM_ACCBIT_SHM { ((1U << SND_PCM_ACCESS_MMAP_INTERLEAVED) | \
Packit 4a16fb
			    (1U << SND_PCM_ACCESS_RW_INTERLEAVED) | \
Packit 4a16fb
			    (1U << SND_PCM_ACCESS_MMAP_NONINTERLEAVED) | \
Packit 4a16fb
			    (1U << SND_PCM_ACCESS_RW_NONINTERLEAVED)) }
Packit 4a16fb
#define SND_PCM_ACCBIT_SHMI { ((1U << SND_PCM_ACCESS_MMAP_INTERLEAVED) | \
Packit 4a16fb
			     (1U << SND_PCM_ACCESS_RW_INTERLEAVED)) }
Packit 4a16fb
#define SND_PCM_ACCBIT_SHMN { ((1U << SND_PCM_ACCESS_MMAP_NONINTERLEAVED) | \
Packit 4a16fb
			     (1U << SND_PCM_ACCESS_RW_NONINTERLEAVED)) }
Packit 4a16fb
Packit 4a16fb
#define SND_PCM_FMTBIT_LINEAR \
Packit 4a16fb
	{ ((1U << SND_PCM_FORMAT_S8) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_U8) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_S16_LE) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_S16_BE) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_U16_LE) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_U16_BE) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_S20_LE) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_S20_BE) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_U20_LE) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_U20_BE) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_S24_LE) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_S24_BE) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_U24_LE) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_U24_BE) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_S32_LE) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_S32_BE) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_U32_LE) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_U32_BE)), \
Packit 4a16fb
	((1U << (SND_PCM_FORMAT_S24_3LE - 32)) | \
Packit 4a16fb
	 (1U << (SND_PCM_FORMAT_U24_3LE - 32)) | \
Packit 4a16fb
	 (1U << (SND_PCM_FORMAT_S24_3BE - 32)) | \
Packit 4a16fb
	 (1U << (SND_PCM_FORMAT_U24_3BE - 32)) | \
Packit 4a16fb
	 (1U << (SND_PCM_FORMAT_S20_3LE - 32)) | \
Packit 4a16fb
	 (1U << (SND_PCM_FORMAT_U20_3LE - 32)) | \
Packit 4a16fb
	 (1U << (SND_PCM_FORMAT_S20_3BE - 32)) | \
Packit 4a16fb
	 (1U << (SND_PCM_FORMAT_U20_3BE - 32)) | \
Packit 4a16fb
	 (1U << (SND_PCM_FORMAT_S18_3LE - 32)) | \
Packit 4a16fb
	 (1U << (SND_PCM_FORMAT_U18_3LE - 32)) | \
Packit 4a16fb
	 (1U << (SND_PCM_FORMAT_S18_3BE - 32)) | \
Packit 4a16fb
	 (1U << (SND_PCM_FORMAT_U18_3BE - 32))) }
Packit 4a16fb
	
Packit 4a16fb
Packit 4a16fb
#define SND_PCM_FMTBIT_FLOAT \
Packit 4a16fb
	{ ((1U << SND_PCM_FORMAT_FLOAT_LE) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_FLOAT_BE) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_FLOAT64_LE) | \
Packit 4a16fb
	 (1U << SND_PCM_FORMAT_FLOAT64_BE)) }
Packit 4a16fb
Packit 4a16fb
Packit 4a16fb
typedef union snd_tmp_float {
Packit 4a16fb
	float f;
Packit 4a16fb
	int32_t i;
Packit 4a16fb
} snd_tmp_float_t;
Packit 4a16fb
Packit 4a16fb
typedef union snd_tmp_double {
Packit 4a16fb
	double d;
Packit 4a16fb
	int64_t l;
Packit 4a16fb
} snd_tmp_double_t;
Packit 4a16fb
Packit 4a16fb
/* get the current timestamp */
Packit 4a16fb
#ifdef HAVE_CLOCK_GETTIME
Packit 4a16fb
static inline void gettimestamp(snd_htimestamp_t *tstamp,
Packit 4a16fb
				snd_pcm_tstamp_type_t tstamp_type)
Packit 4a16fb
{
Packit 4a16fb
	clockid_t id;
Packit 4a16fb
Packit 4a16fb
	switch (tstamp_type) {
Packit 4a16fb
#ifdef CLOCK_MONOTONIC_RAW
Packit 4a16fb
	case SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW:
Packit 4a16fb
		id = CLOCK_MONOTONIC_RAW;
Packit 4a16fb
		break;
Packit 4a16fb
#endif
Packit 4a16fb
#ifdef CLOCK_MONOTONIC
Packit 4a16fb
	case SND_PCM_TSTAMP_TYPE_MONOTONIC:
Packit 4a16fb
		id = CLOCK_MONOTONIC;
Packit 4a16fb
		break;
Packit 4a16fb
#endif
Packit 4a16fb
	default:
Packit 4a16fb
		id = CLOCK_REALTIME;
Packit 4a16fb
		break;
Packit 4a16fb
	}
Packit 4a16fb
	clock_gettime(id, tstamp);
Packit 4a16fb
}
Packit 4a16fb
#else /* HAVE_CLOCK_GETTIME */
Packit 4a16fb
static inline void gettimestamp(snd_htimestamp_t *tstamp,
Packit 4a16fb
				snd_pcm_tstamp_type_t tstamp_type)
Packit 4a16fb
{
Packit 4a16fb
	struct timeval tv;
Packit 4a16fb
Packit 4a16fb
	gettimeofday(&tv, 0);
Packit 4a16fb
	tstamp->tv_sec = tv.tv_sec;
Packit 4a16fb
	tstamp->tv_nsec = tv.tv_usec * 1000L;
Packit 4a16fb
}
Packit 4a16fb
#endif /* HAVE_CLOCK_GETTIME */
Packit 4a16fb
Packit 4a16fb
snd_pcm_chmap_query_t **
Packit 4a16fb
_snd_pcm_make_single_query_chmaps(const snd_pcm_chmap_t *src);
Packit 4a16fb
snd_pcm_chmap_t *_snd_pcm_copy_chmap(const snd_pcm_chmap_t *src);
Packit 4a16fb
snd_pcm_chmap_query_t **
Packit 4a16fb
_snd_pcm_copy_chmap_query(snd_pcm_chmap_query_t * const *src);
Packit 4a16fb
snd_pcm_chmap_query_t **
Packit 4a16fb
_snd_pcm_parse_config_chmaps(snd_config_t *conf);
Packit 4a16fb
snd_pcm_chmap_t *
Packit 4a16fb
_snd_pcm_choose_fixed_chmap(snd_pcm_t *pcm, snd_pcm_chmap_query_t * const *maps);
Packit 4a16fb
Packit 4a16fb
/* return true if the PCM stream may wait to get avail_min space */
Packit 4a16fb
static inline int snd_pcm_may_wait_for_avail_min(snd_pcm_t *pcm, snd_pcm_uframes_t avail)
Packit 4a16fb
{
Packit 4a16fb
	if (avail >= pcm->avail_min)
Packit 4a16fb
		return 0;
Packit 4a16fb
	if (pcm->fast_ops->may_wait_for_avail_min)
Packit 4a16fb
		return pcm->fast_ops->may_wait_for_avail_min(pcm, avail);
Packit 4a16fb
	return 1;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
/* hack to access to internal period_event in snd_pcm_sw_parmams */
Packit 4a16fb
static inline int sw_get_period_event(const snd_pcm_sw_params_t *params)
Packit 4a16fb
{
Packit 4a16fb
	return params->reserved[sizeof(params->reserved) / sizeof(params->reserved[0])- 1];
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
static inline void sw_set_period_event(snd_pcm_sw_params_t *params, int val)
Packit 4a16fb
{
Packit 4a16fb
	params->reserved[sizeof(params->reserved) / sizeof(params->reserved[0]) - 1] = val;
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
#define PCMINABORT(pcm) (((pcm)->mode & SND_PCM_ABORT) != 0)
Packit 4a16fb
Packit 4a16fb
#ifdef THREAD_SAFE_API
Packit 4a16fb
/*
Packit 4a16fb
 * __snd_pcm_lock() and __snd_pcm_unlock() are used to lock/unlock the plugin
Packit 4a16fb
 * forcibly even if it's declared as thread-safe.  It's needed only for some
Packit 4a16fb
 * codes that are thread-unsafe per design (e.g. snd_pcm_nonblock()).
Packit 4a16fb
 *
Packit 4a16fb
 * OTOH, snd_pcm_lock() and snd_pcm_unlock() are used to lock/unlock the plugin
Packit 4a16fb
 * in normal situations.  They do lock/unlock only when the plugin is
Packit 4a16fb
 * thread-unsafe.
Packit 4a16fb
 *
Packit 4a16fb
 * Both __snd_pcm_lock() and snd_pcm_lock() (and their unlocks) wouldn't do
Packit 4a16fb
 * any action when the whole locking is disabled via $LIBASOUND_THREAD_SAFE=0.
Packit 4a16fb
 */
Packit 4a16fb
static inline void __snd_pcm_lock(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	if (pcm->lock_enabled)
Packit 4a16fb
		pthread_mutex_lock(&pcm->lock);
Packit 4a16fb
}
Packit 4a16fb
static inline void __snd_pcm_unlock(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	if (pcm->lock_enabled)
Packit 4a16fb
		pthread_mutex_unlock(&pcm->lock);
Packit 4a16fb
}
Packit 4a16fb
static inline void snd_pcm_lock(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	if (pcm->lock_enabled && pcm->need_lock)
Packit 4a16fb
		pthread_mutex_lock(&pcm->lock);
Packit 4a16fb
}
Packit 4a16fb
static inline void snd_pcm_unlock(snd_pcm_t *pcm)
Packit 4a16fb
{
Packit 4a16fb
	if (pcm->lock_enabled && pcm->need_lock)
Packit 4a16fb
		pthread_mutex_unlock(&pcm->lock);
Packit 4a16fb
}
Packit 4a16fb
#else /* THREAD_SAFE_API */
Packit 4a16fb
#define __snd_pcm_lock(pcm)		do {} while (0)
Packit 4a16fb
#define __snd_pcm_unlock(pcm)		do {} while (0)
Packit 4a16fb
#define snd_pcm_lock(pcm)		do {} while (0)
Packit 4a16fb
#define snd_pcm_unlock(pcm)		do {} while (0)
Packit 4a16fb
#endif /* THREAD_SAFE_API */