⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcm.h

📁 linux 内核源代码
💻 H
📖 第 1 页 / 共 3 页
字号:
struct snd_pcm_group {		/* keep linked substreams */	spinlock_t lock;	struct list_head substreams;	int count;};struct snd_pcm_substream {	struct snd_pcm *pcm;	struct snd_pcm_str *pstr;	void *private_data;		/* copied from pcm->private_data */	int number;	char name[32];			/* substream name */	int stream;			/* stream (direction) */	char latency_id[20];		/* latency identifier */	size_t buffer_bytes_max;	/* limit ring buffer size */	struct snd_dma_buffer dma_buffer;	unsigned int dma_buf_id;	size_t dma_max;	/* -- hardware operations -- */	struct snd_pcm_ops *ops;	/* -- runtime information -- */	struct snd_pcm_runtime *runtime;        /* -- timer section -- */	struct snd_timer *timer;		/* timer */	unsigned timer_running: 1;	/* time is running */	spinlock_t timer_lock;	/* -- next substream -- */	struct snd_pcm_substream *next;	/* -- linked substreams -- */	struct list_head link_list;	/* linked list member */	struct snd_pcm_group self_group;	/* fake group for non linked substream (with substream lock inside) */	struct snd_pcm_group *group;		/* pointer to current group */	/* -- assigned files -- */	void *file;	int ref_count;	atomic_t mmap_count;	unsigned int f_flags;	void (*pcm_release)(struct snd_pcm_substream *);#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)	/* -- OSS things -- */	struct snd_pcm_oss_substream oss;#endif#ifdef CONFIG_SND_VERBOSE_PROCFS	struct snd_info_entry *proc_root;	struct snd_info_entry *proc_info_entry;	struct snd_info_entry *proc_hw_params_entry;	struct snd_info_entry *proc_sw_params_entry;	struct snd_info_entry *proc_status_entry;	struct snd_info_entry *proc_prealloc_entry;	struct snd_info_entry *proc_prealloc_max_entry;#endif	/* misc flags */	unsigned int hw_opened: 1;};#define SUBSTREAM_BUSY(substream) ((substream)->ref_count > 0)struct snd_pcm_str {	int stream;				/* stream (direction) */	struct snd_pcm *pcm;	/* -- substreams -- */	unsigned int substream_count;	unsigned int substream_opened;	struct snd_pcm_substream *substream;#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)	/* -- OSS things -- */	struct snd_pcm_oss_stream oss;#endif#ifdef CONFIG_SND_VERBOSE_PROCFS	struct snd_info_entry *proc_root;	struct snd_info_entry *proc_info_entry;#ifdef CONFIG_SND_PCM_XRUN_DEBUG	unsigned int xrun_debug;	/* 0 = disabled, 1 = verbose, 2 = stacktrace */	struct snd_info_entry *proc_xrun_debug_entry;#endif#endif};struct snd_pcm {	struct snd_card *card;	struct list_head list;	unsigned int device;	/* device number */	unsigned int info_flags;	unsigned short dev_class;	unsigned short dev_subclass;	char id[64];	char name[80];	struct snd_pcm_str streams[2];	struct mutex open_mutex;	wait_queue_head_t open_wait;	void *private_data;	void (*private_free) (struct snd_pcm *pcm);	struct device *dev; /* actual hw device this belongs to */#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)	struct snd_pcm_oss oss;#endif};struct snd_pcm_notify {	int (*n_register) (struct snd_pcm * pcm);	int (*n_disconnect) (struct snd_pcm * pcm);	int (*n_unregister) (struct snd_pcm * pcm);	struct list_head list;};/* *  Registering */extern const struct file_operations snd_pcm_f_ops[2];int snd_pcm_new(struct snd_card *card, char *id, int device,		int playback_count, int capture_count,		struct snd_pcm **rpcm);int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count);int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree);/* *  Native I/O */extern rwlock_t snd_pcm_link_rwlock;int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info);int snd_pcm_info_user(struct snd_pcm_substream *substream,		      struct snd_pcm_info __user *info);int snd_pcm_status(struct snd_pcm_substream *substream,		   struct snd_pcm_status *status);int snd_pcm_start(struct snd_pcm_substream *substream);int snd_pcm_stop(struct snd_pcm_substream *substream, int status);int snd_pcm_drain_done(struct snd_pcm_substream *substream);#ifdef CONFIG_PMint snd_pcm_suspend(struct snd_pcm_substream *substream);int snd_pcm_suspend_all(struct snd_pcm *pcm);#endifint snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg);int snd_pcm_open_substream(struct snd_pcm *pcm, int stream, struct file *file,			   struct snd_pcm_substream **rsubstream);void snd_pcm_release_substream(struct snd_pcm_substream *substream);int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream, struct file *file,			     struct snd_pcm_substream **rsubstream);void snd_pcm_detach_substream(struct snd_pcm_substream *substream);void snd_pcm_vma_notify_data(void *client, void *data);int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area);#if BITS_PER_LONG >= 64static inline void div64_32(u_int64_t *n, u_int32_t div, u_int32_t *rem){	*rem = *n % div;	*n /= div;}#elif defined(i386)static inline void div64_32(u_int64_t *n, u_int32_t div, u_int32_t *rem){	u_int32_t low, high;	low = *n & 0xffffffff;	high = *n >> 32;	if (high) {		u_int32_t high1 = high % div;		high /= div;		asm("divl %2":"=a" (low), "=d" (*rem):"rm" (div), "a" (low), "d" (high1));		*n = (u_int64_t)high << 32 | low;	} else {		*n = low / div;		*rem = low % div;	}}#elsestatic inline void divl(u_int32_t high, u_int32_t low,			u_int32_t div,			u_int32_t *q, u_int32_t *r){	u_int64_t n = (u_int64_t)high << 32 | low;	u_int64_t d = (u_int64_t)div << 31;	u_int32_t q1 = 0;	int c = 32;	while (n > 0xffffffffU) {		q1 <<= 1;		if (n >= d) {			n -= d;			q1 |= 1;		}		d >>= 1;		c--;	}	q1 <<= c;	if (n) {		low = n;		*q = q1 | (low / div);		*r = low % div;	} else {		*r = 0;		*q = q1;	}	return;}static inline void div64_32(u_int64_t *n, u_int32_t div, u_int32_t *rem){	u_int32_t low, high;	low = *n & 0xffffffff;	high = *n >> 32;	if (high) {		u_int32_t high1 = high % div;		u_int32_t low1 = low;		high /= div;		divl(high1, low1, div, &low, rem);		*n = (u_int64_t)high << 32 | low;	} else {		*n = low / div;		*rem = low % div;	}}#endif/* *  PCM library */static inline int snd_pcm_stream_linked(struct snd_pcm_substream *substream){	return substream->group != &substream->self_group;}static inline void snd_pcm_stream_lock(struct snd_pcm_substream *substream){	read_lock(&snd_pcm_link_rwlock);	spin_lock(&substream->self_group.lock);}static inline void snd_pcm_stream_unlock(struct snd_pcm_substream *substream){	spin_unlock(&substream->self_group.lock);	read_unlock(&snd_pcm_link_rwlock);}static inline void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream){	read_lock_irq(&snd_pcm_link_rwlock);	spin_lock(&substream->self_group.lock);}static inline void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream){	spin_unlock(&substream->self_group.lock);	read_unlock_irq(&snd_pcm_link_rwlock);}#define snd_pcm_stream_lock_irqsave(substream, flags) \do { \	read_lock_irqsave(&snd_pcm_link_rwlock, (flags)); \	spin_lock(&substream->self_group.lock); \} while (0)#define snd_pcm_stream_unlock_irqrestore(substream, flags) \do { \	spin_unlock(&substream->self_group.lock); \	read_unlock_irqrestore(&snd_pcm_link_rwlock, (flags)); \} while (0)#define snd_pcm_group_for_each_entry(s, substream) \	list_for_each_entry(s, &substream->group->substreams, link_list)static inline int snd_pcm_running(struct snd_pcm_substream *substream){	return (substream->runtime->status->state == SNDRV_PCM_STATE_RUNNING ||		(substream->runtime->status->state == SNDRV_PCM_STATE_DRAINING &&		 substream->stream == SNDRV_PCM_STREAM_PLAYBACK));}static inline ssize_t bytes_to_samples(struct snd_pcm_runtime *runtime, ssize_t size){	return size * 8 / runtime->sample_bits;}static inline snd_pcm_sframes_t bytes_to_frames(struct snd_pcm_runtime *runtime, ssize_t size){	return size * 8 / runtime->frame_bits;}static inline ssize_t samples_to_bytes(struct snd_pcm_runtime *runtime, ssize_t size){	return size * runtime->sample_bits / 8;}static inline ssize_t frames_to_bytes(struct snd_pcm_runtime *runtime, snd_pcm_sframes_t size){	return size * runtime->frame_bits / 8;}static inline int frame_aligned(struct snd_pcm_runtime *runtime, ssize_t bytes){	return bytes % runtime->byte_align == 0;}static inline size_t snd_pcm_lib_buffer_bytes(struct snd_pcm_substream *substream){	struct snd_pcm_runtime *runtime = substream->runtime;	return frames_to_bytes(runtime, runtime->buffer_size);}static inline size_t snd_pcm_lib_period_bytes(struct snd_pcm_substream *substream){	struct snd_pcm_runtime *runtime = substream->runtime;	return frames_to_bytes(runtime, runtime->period_size);}/* *  result is: 0 ... (boundary - 1) */static inline snd_pcm_uframes_t snd_pcm_playback_avail(struct snd_pcm_runtime *runtime){	snd_pcm_sframes_t avail = runtime->status->hw_ptr + runtime->buffer_size - runtime->control->appl_ptr;	if (avail < 0)		avail += runtime->boundary;	else if ((snd_pcm_uframes_t) avail >= runtime->boundary)		avail -= runtime->boundary;	return avail;}/* *  result is: 0 ... (boundary - 1) */static inline snd_pcm_uframes_t snd_pcm_capture_avail(struct snd_pcm_runtime *runtime){	snd_pcm_sframes_t avail = runtime->status->hw_ptr - runtime->control->appl_ptr;	if (avail < 0)		avail += runtime->boundary;	return avail;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -