ALSA driver基本概念
https://blog.csdn.net/zyuanyun/article/details/59180272#t6
1.Card
For each soundcard, a “card” record must be allocated.
A card record is the headquarters of the soundcard. It manages the whole list of devices (components) on the soundcard, such as PCM, mixers, MIDI, synthesizer, and so on. Also, the card record holds the ID and the name strings of the card, manages the root of proc files, and controls the power-management states and hotplug disconnections. The component list on the card record is used to manage the correct release of resources at destruction.
Card是对声卡硬件的抽象。对于每一个声卡硬件,在alsa driver都对应一个Card record. Card管理声卡上的多个device。
我们可以通过cat /poc/asound/看到机器上的声卡。
2.Device
After the card is created, you can attach the components (devices) to the card instance. In an ALSA driver, a component is represented as a struct snd_device object. A component can be a PCM instance, a control interface, a raw MIDI interface, etc. Each such instance has one component entry.
每个device是一个snd_device 的结构体。device可以是PCM 实例,control interface (mixer),MIDI interface.
3.PCM
Each card device can have up to four pcm instances. A pcm instance corresponds to a pcm device file. The limitation of number of instances comes only from the available bit size of the Linux's device numbers. Once when 64bit device number is used, we'll have more pcm instances available.
A pcm instance consists of pcm playback and capture streams, and each pcm stream consists of one or more pcm substreams. Some soundcards support multiple playback functions. For example, emu10k1 has a PCM playback of 32 stereo substreams. In this case, at each open, a free substream is (usually) automatically chosen and opened. Meanwhile, when only one substream exists and it was already opened, the successful open will either block or error with EAGAIN
according to the file open mode. But you don't have to care about such details in your driver. The PCM middle layer will take care of such work.
个声卡最多可以包含4个pcm的实例,每个pcm实例对应一个pcm设备文件。pcm实例数量的这种限制源于linux设备号所占用的位大小,如果以后使用64位的设备号,我们将可以创建更多的pcm实例。
一个pcm实例由一个playback stream和一个capture stream组成,这两个stream又分别有一个或多个substreams组成。如果playback stream有多个substream, 那么说明声卡支持多路播放。如果只有一个substream, 如果已经有其他的app open了,说明pcm substream被占用,那么在open pcm时,那么open 会block 或者返回EAGAIN。
4. Runtime
When the PCM substream is opened, a PCM runtime instance is allocated and assigned to the substream. This pointer is accessible via substream->runtime
. This runtime pointer holds most information you need to control the PCM: the copy of hw_params and sw_params configurations, the buffer pointers, mmap records, spinlocks, etc.
每个substream都有一个runtime的实例。rutime这个结构体包含了一些control PCM的大部分信息,比如hw_params 和sw_params的配置,buffer pointer等等。
ALSA driver基本概念的更多相关文章
- ALSA lib基本概念
1.channel 通道,即我们熟知的声道数.左/右声道,5.1channel等等 2.sample A sample is a single value that describes the amp ...
- ALSA driver --PCM 实例创建过程
前面已经写过PCM 实例的创建框架,我们现在来看看PCM 实例是如何创建的. 在调用snd_pcm_new时就会创建一个snd_pcm类型的PCM 实例. struct snd_pcm { struc ...
- ALSA 学习小记
对于playback snd_pcm_begin snd_pcm_commit, 貌似 commit给的frame才会使得alsa去把数据填充 转自 http://magodo.github.io/ ...
- Linux内核中的GPIO系统之(3):pin controller driver代码分析
一.前言 对于一个嵌入式软件工程师,我们的软件模块经常和硬件打交道,pin control subsystem也不例外,被它驱动的硬件叫做pin controller(一般ARM soc的datash ...
- ALSA学习资料
一.内核文档 Linux Sound Subsystem Documentation 二.一些API 1.snd_pcm_period_elapsed 2.snd_pcm_lib_buffer_by ...
- ALSA声卡11_从零编写之调试——学习笔记
1.调试 (1)把程序拷贝到服务器上进行编译 (2)把程序放到内核上面去 重新配置内核,吧原来的声卡驱动程序去掉 a. 修改语法错误 11th_myalsa b. 配置内核去掉原来的声卡驱动 -> ...
- Linux内核中的GPIO系统之(3):pin controller driver代码分析--devm_kzalloc使用【转】
转自:http://www.wowotech.net/linux_kenrel/pin-controller-driver.html 一.前言 对于一个嵌入式软件工程师,我们的软件模块经常和硬件打交道 ...
- Linux ALSA声卡驱动之八:ASoC架构中的Platform
1. Platform驱动在ASoC中的作用 前面几章内容已经说过,ASoC被分为Machine,Platform和Codec三大部件,Platform驱动的主要作用是完成音频数据的管理,最终通过C ...
- 36、ALSA声卡驱动和应用
(注意:内核上电的时候会把一些没运行的控制器模块的时钟都关掉,所有在写驱动的时候需要在使用的使用使用clk_get和clk_enable使能时钟) (说明:与ALSA声卡对应的是OSS架构,第二期视频 ...
随机推荐
- 三行代码实现垂直居中和cube
三行代码实现上下居中 position: relative;top: 50%;transform: translateY(-50%); 效果如下: 代码: <!DOCTYPE html> ...
- c++ 踩坑大法好 枚举
1,枚举是个啥? c++允许程序员创建自己的数据类型,枚举数据类型是程序员自定义的一种数据类型,其值是一组命名整数常量. ,wed,thu,fri,sat,sun}; //定义一个叫day的数据类型, ...
- AcWing 272. 最长公共上升子序列
#include<iostream> using namespace std ; ; int n; int a[N]; int b[N]; int f[N][N]; //f[i][j] / ...
- Postman:下载安装与基本介绍
1.下载: (1)官网APP: https://www.getpostman.com/ (即: https://app.getpostman.com/app/download/win64 ) (2)插 ...
- zabbix4.2配置监控TCP连接状态
1.使用命令查看TCP连接状态 (1)过去常用命令:netstat -antp [root@ansible-control zabbix]# netstat -antp Active Internet ...
- SQLserver各种时间取值格式
叫大哥 SQLServer提取日期中的年月日及其他格式 SQLServer提取日期中的年月日及其他格式 提取年:datepart(yy,getdate())提取月:datepart(mm,getd ...
- [CF705B] Spider Man - 博弈论
[CF705B] Description ICG 游戏有若干个环,每次操作将一个环断成非空的两部分,节点数总和不变.集合初态为空,每次向集合中添加一个环,询问当前集合用于游戏的胜负. \(n \le ...
- visual env VS conda environment of python
1. There's two types of python environment in pycharm: virtualenv Environment conda environment For ...
- ET框架之SceneChangeComponent
初始化事件 using ETModel; namespace ETHotfix { [Event(EventIdType.InitSceneStart)] public class InitScene ...
- java 判断数据是否为空
/** * 方法描述:自定义判断是否为空 * 创建作者:李兴武 * 创建日期:2017-06-22 19:50:01 * * @param str the str * @return the bool ...