📄 pcm.h
字号:
}static inline int frame_aligned(snd_pcm_runtime_t *runtime, ssize_t bytes){ return bytes % runtime->byte_align == 0;}static inline size_t snd_pcm_lib_buffer_bytes(snd_pcm_substream_t *substream){ snd_pcm_runtime_t *runtime = substream->runtime; return frames_to_bytes(runtime, runtime->buffer_size);}static inline size_t snd_pcm_lib_period_bytes(snd_pcm_substream_t *substream){ snd_pcm_runtime_t *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(snd_pcm_runtime_t *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(snd_pcm_runtime_t *runtime){ snd_pcm_sframes_t avail = runtime->status->hw_ptr - runtime->control->appl_ptr; if (avail < 0) avail += runtime->boundary; return avail;}static inline snd_pcm_sframes_t snd_pcm_playback_hw_avail(snd_pcm_runtime_t *runtime){ return runtime->buffer_size - snd_pcm_playback_avail(runtime);}static inline snd_pcm_sframes_t snd_pcm_capture_hw_avail(snd_pcm_runtime_t *runtime){ return runtime->buffer_size - snd_pcm_capture_avail(runtime);}static inline void snd_pcm_trigger_done(snd_pcm_substream_t *substream, snd_pcm_substream_t *master){ substream->runtime->trigger_master = master;}static inline int hw_is_mask(int var){ return var >= SNDRV_PCM_HW_PARAM_FIRST_MASK && var <= SNDRV_PCM_HW_PARAM_LAST_MASK;}static inline int hw_is_interval(int var){ return var >= SNDRV_PCM_HW_PARAM_FIRST_INTERVAL && var <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL;}static inline snd_mask_t *hw_param_mask(snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var){ return ¶ms->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK];}static inline snd_interval_t *hw_param_interval(snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var){ return ¶ms->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL];}static inline const snd_mask_t *hw_param_mask_c(const snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var){ return (const snd_mask_t *)hw_param_mask((snd_pcm_hw_params_t*) params, var);}static inline const snd_interval_t *hw_param_interval_c(const snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var){ return (const snd_interval_t *)hw_param_interval((snd_pcm_hw_params_t*) params, var);}#define params_access(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_ACCESS))#define params_format(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_FORMAT))#define params_subformat(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_SUBFORMAT))#define params_channels(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_CHANNELS)->min#define params_rate(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_RATE)->min#define params_period_size(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_PERIOD_SIZE)->min#define params_period_bytes(p) ((params_period_size(p)*snd_pcm_format_physical_width(params_format(p))*params_channels(p))/8)#define params_periods(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_PERIODS)->min#define params_buffer_size(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_BUFFER_SIZE)->min#define params_buffer_bytes(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_BUFFER_BYTES)->min#define params_tick_time(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_TICK_TIME)->minint snd_interval_refine(snd_interval_t *i, const snd_interval_t *v);void snd_interval_mul(const snd_interval_t *a, const snd_interval_t *b, snd_interval_t *c);void snd_interval_div(const snd_interval_t *a, const snd_interval_t *b, snd_interval_t *c);void snd_interval_muldivk(const snd_interval_t *a, const snd_interval_t *b, unsigned int k, snd_interval_t *c);void snd_interval_mulkdiv(const snd_interval_t *a, unsigned int k, const snd_interval_t *b, snd_interval_t *c);int snd_interval_list(snd_interval_t *i, unsigned int count, unsigned int *list, unsigned int mask);int snd_interval_step(snd_interval_t *i, unsigned int min, unsigned int step);int snd_interval_ratnum(snd_interval_t *i, unsigned int rats_count, ratnum_t *rats, unsigned int *nump, unsigned int *denp);int snd_interval_ratden(snd_interval_t *i, unsigned int rats_count, ratden_t *rats, unsigned int *nump, unsigned int *denp);void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params);void _snd_pcm_hw_param_setempty(snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var);int snd_pcm_hw_param_min(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var, unsigned int val, int *dir);int snd_pcm_hw_param_max(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var, unsigned int val, int *dir);int snd_pcm_hw_param_setinteger(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var);int snd_pcm_hw_param_first(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var, int *dir);int snd_pcm_hw_param_last(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var, int *dir);int snd_pcm_hw_param_near(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var, unsigned int val, int *dir);int snd_pcm_hw_param_set(snd_pcm_substream_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var, unsigned int val, int dir);int snd_pcm_hw_params_choose(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params);int snd_pcm_hw_refine(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params);int snd_pcm_hw_constraints_init(snd_pcm_substream_t *substream);int snd_pcm_hw_constraints_complete(snd_pcm_substream_t *substream);int snd_pcm_hw_constraint_mask(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var, u_int32_t mask);int snd_pcm_hw_constraint_mask64(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var, u_int64_t mask);int snd_pcm_hw_constraint_minmax(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var, unsigned int min, unsigned int max);int snd_pcm_hw_constraint_integer(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var);int snd_pcm_hw_constraint_list(snd_pcm_runtime_t *runtime, unsigned int cond, snd_pcm_hw_param_t var, snd_pcm_hw_constraint_list_t *l);int snd_pcm_hw_constraint_ratnums(snd_pcm_runtime_t *runtime, unsigned int cond, snd_pcm_hw_param_t var, snd_pcm_hw_constraint_ratnums_t *r);int snd_pcm_hw_constraint_ratdens(snd_pcm_runtime_t *runtime, unsigned int cond, snd_pcm_hw_param_t var, snd_pcm_hw_constraint_ratdens_t *r);int snd_pcm_hw_constraint_msbits(snd_pcm_runtime_t *runtime, unsigned int cond, unsigned int width, unsigned int msbits);int snd_pcm_hw_constraint_step(snd_pcm_runtime_t *runtime, unsigned int cond, snd_pcm_hw_param_t var, unsigned long step);int snd_pcm_hw_constraint_pow2(snd_pcm_runtime_t *runtime, unsigned int cond, snd_pcm_hw_param_t var);int snd_pcm_hw_rule_add(snd_pcm_runtime_t *runtime, unsigned int cond, int var, snd_pcm_hw_rule_func_t func, void *private, int dep, ...);int snd_pcm_format_signed(snd_pcm_format_t format);int snd_pcm_format_unsigned(snd_pcm_format_t format);int snd_pcm_format_linear(snd_pcm_format_t format);int snd_pcm_format_little_endian(snd_pcm_format_t format);int snd_pcm_format_big_endian(snd_pcm_format_t format);int snd_pcm_format_width(snd_pcm_format_t format); /* in bits */int snd_pcm_format_physical_width(snd_pcm_format_t format); /* in bits */const unsigned char *snd_pcm_format_silence_64(snd_pcm_format_t format);int snd_pcm_format_set_silence(snd_pcm_format_t format, void *buf, unsigned int frames);snd_pcm_format_t snd_pcm_build_linear_format(int width, int unsignd, int big_endian);ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples);const char *snd_pcm_format_name(snd_pcm_format_t format);const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat);void snd_pcm_set_ops(snd_pcm_t * pcm, int direction, snd_pcm_ops_t *ops);void snd_pcm_set_sync(snd_pcm_substream_t * substream);int snd_pcm_lib_interleave_len(snd_pcm_substream_t *substream);int snd_pcm_lib_ioctl(snd_pcm_substream_t *substream, unsigned int cmd, void *arg); int snd_pcm_update_hw_ptr(snd_pcm_substream_t *substream);int snd_pcm_playback_xrun_check(snd_pcm_substream_t *substream);int snd_pcm_capture_xrun_check(snd_pcm_substream_t *substream);int snd_pcm_playback_xrun_asap(snd_pcm_substream_t *substream);int snd_pcm_capture_xrun_asap(snd_pcm_substream_t *substream);void snd_pcm_playback_silence(snd_pcm_substream_t *substream, snd_pcm_uframes_t new_hw_ptr);int snd_pcm_playback_ready(snd_pcm_substream_t *substream);int snd_pcm_capture_ready(snd_pcm_substream_t *substream);long snd_pcm_playback_ready_jiffies(snd_pcm_substream_t *substream);long snd_pcm_capture_ready_jiffies(snd_pcm_substream_t *substream);int snd_pcm_playback_data(snd_pcm_substream_t *substream);int snd_pcm_playback_empty(snd_pcm_substream_t *substream);int snd_pcm_capture_empty(snd_pcm_substream_t *substream);void snd_pcm_tick_prepare(snd_pcm_substream_t *substream);void snd_pcm_tick_set(snd_pcm_substream_t *substream, unsigned long ticks);void snd_pcm_tick_elapsed(snd_pcm_substream_t *substream);void snd_pcm_period_elapsed(snd_pcm_substream_t *substream);snd_pcm_sframes_t snd_pcm_lib_write(snd_pcm_substream_t *substream, const void __user *buf, snd_pcm_uframes_t frames);snd_pcm_sframes_t snd_pcm_lib_read(snd_pcm_substream_t *substream, void __user *buf, snd_pcm_uframes_t frames);snd_pcm_sframes_t snd_pcm_lib_writev(snd_pcm_substream_t *substream, void __user **bufs, snd_pcm_uframes_t frames);snd_pcm_sframes_t snd_pcm_lib_readv(snd_pcm_substream_t *substream, void __user **bufs, snd_pcm_uframes_t frames);int snd_pcm_limit_hw_rates(snd_pcm_runtime_t *runtime);static inline void snd_pcm_set_runtime_buffer(snd_pcm_substream_t *substream, struct snd_dma_buffer *bufp){ snd_pcm_runtime_t *runtime = substream->runtime; if (bufp) { runtime->dma_buffer_p = bufp; runtime->dma_area = bufp->area; runtime->dma_addr = bufp->addr; runtime->dma_bytes = bufp->bytes; } else { runtime->dma_buffer_p = NULL; runtime->dma_area = NULL; runtime->dma_addr = 0; runtime->dma_bytes = 0; }}/* * Timer interface */void snd_pcm_timer_resolution_change(snd_pcm_substream_t *substream);void snd_pcm_timer_init(snd_pcm_substream_t * substream);void snd_pcm_timer_done(snd_pcm_substream_t * substream);/* * Memory */int snd_pcm_lib_preallocate_free(snd_pcm_substream_t *substream);int snd_pcm_lib_preallocate_free_for_all(snd_pcm_t *pcm);int snd_pcm_lib_preallocate_pages(snd_pcm_substream_t *substream, int type, struct device *data, size_t size, size_t max);int snd_pcm_lib_preallocate_pages_for_all(snd_pcm_t *pcm, int type, void *data, size_t size, size_t max);int snd_pcm_lib_malloc_pages(snd_pcm_substream_t *substream, size_t size);int snd_pcm_lib_free_pages(snd_pcm_substream_t *substream);#define snd_pcm_substream_sgbuf(substream) ((substream)->runtime->dma_buffer_p->private_data)#define snd_pcm_sgbuf_pages(size) snd_sgbuf_aligned_pages(size)#define snd_pcm_sgbuf_get_addr(sgbuf,ofs) snd_sgbuf_get_addr(sgbuf,ofs)struct page *snd_pcm_sgbuf_ops_page(snd_pcm_substream_t *substream, unsigned long offset);/* handle mmap counter - PCM mmap callback should handle this counter properly */static inline void snd_pcm_mmap_data_open(struct vm_area_struct *area){ snd_pcm_substream_t *substream = (snd_pcm_substream_t *)area->vm_private_data; atomic_inc(&substream->runtime->mmap_count);}static inline void snd_pcm_mmap_data_close(struct vm_area_struct *area){ snd_pcm_substream_t *substream = (snd_pcm_substream_t *)area->vm_private_data; atomic_dec(&substream->runtime->mmap_count);}/* mmap for io-memory area */#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_ALPHA)#define SNDRV_PCM_INFO_MMAP_IOMEM SNDRV_PCM_INFO_MMAPint snd_pcm_lib_mmap_iomem(snd_pcm_substream_t *substream, struct vm_area_struct *area);#else#define SNDRV_PCM_INFO_MMAP_IOMEM 0#define snd_pcm_lib_mmap_iomem NULL#endifstatic inline void snd_pcm_limit_isa_dma_size(int dma, size_t *max){ *max = dma < 4 ? 64 * 1024 : 128 * 1024;}/* * Misc */#define SNDRV_PCM_DEFAULT_CON_SPDIF (IEC958_AES0_CON_EMPHASIS_NONE|\ (IEC958_AES1_CON_ORIGINAL<<8)|\ (IEC958_AES1_CON_PCM_CODER<<8)|\ (IEC958_AES3_CON_FS_48000<<24))#endif /* __SOUND_PCM_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -