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基本概念的更多相关文章

  1. ALSA lib基本概念

    1.channel 通道,即我们熟知的声道数.左/右声道,5.1channel等等 2.sample A sample is a single value that describes the amp ...

  2. ALSA driver --PCM 实例创建过程

    前面已经写过PCM 实例的创建框架,我们现在来看看PCM 实例是如何创建的. 在调用snd_pcm_new时就会创建一个snd_pcm类型的PCM 实例. struct snd_pcm { struc ...

  3. ALSA 学习小记

    对于playback snd_pcm_begin snd_pcm_commit, 貌似 commit给的frame才会使得alsa去把数据填充 转自 http://magodo.github.io/ ...

  4. Linux内核中的GPIO系统之(3):pin controller driver代码分析

    一.前言 对于一个嵌入式软件工程师,我们的软件模块经常和硬件打交道,pin control subsystem也不例外,被它驱动的硬件叫做pin controller(一般ARM soc的datash ...

  5. ALSA学习资料

    一.内核文档  Linux Sound Subsystem Documentation 二.一些API 1.snd_pcm_period_elapsed 2.snd_pcm_lib_buffer_by ...

  6. ALSA声卡11_从零编写之调试——学习笔记

    1.调试 (1)把程序拷贝到服务器上进行编译 (2)把程序放到内核上面去 重新配置内核,吧原来的声卡驱动程序去掉 a. 修改语法错误 11th_myalsa b. 配置内核去掉原来的声卡驱动 -> ...

  7. Linux内核中的GPIO系统之(3):pin controller driver代码分析--devm_kzalloc使用【转】

    转自:http://www.wowotech.net/linux_kenrel/pin-controller-driver.html 一.前言 对于一个嵌入式软件工程师,我们的软件模块经常和硬件打交道 ...

  8. Linux ALSA声卡驱动之八:ASoC架构中的Platform

    1.  Platform驱动在ASoC中的作用 前面几章内容已经说过,ASoC被分为Machine,Platform和Codec三大部件,Platform驱动的主要作用是完成音频数据的管理,最终通过C ...

  9. 36、ALSA声卡驱动和应用

    (注意:内核上电的时候会把一些没运行的控制器模块的时钟都关掉,所有在写驱动的时候需要在使用的使用使用clk_get和clk_enable使能时钟) (说明:与ALSA声卡对应的是OSS架构,第二期视频 ...

随机推荐

  1. ASP.NET MVC 简介(附VS2019和VSCode版示例)

    MVC可以理解为一种思想,应用在web应用程序的架构上. ASP.NET MVC的核心类是实现了IHttpHandler接口的MVCHandler,它的底层仍然是HttpHandler.HttpReq ...

  2. PP: A multi-horizon quantile recurrent forecaster

    2017 NIPS, time series workshop traditional methods: ARIMA. Seq2Seq quantile forecast; RELATED WORK ...

  3. Python标准库之sys模块

    获取Python解释器的版本信息 import sys print(sys.version) #输出 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) ...

  4. MFC使用LoadBitmap方法加载位图文件失败解决方案(转)

    用如下方法在原项目中使用LoadBitmap方法加载已有的位图资源作为背景没有问题,但放在别的项目中总是加载不出来,该函数返回NULL HBITMAP hBitmap=LoadBitmap((HINS ...

  5. Pycharm操作数据库

    Pymysql 用于连接mysql数据库 连接数据库 data_ip = "192.168.34.128" data_name = "lch" data_pwd ...

  6. opencv 实现人脸检测(harr特征)

    我这里用的是已经训练好的haar级联分类器. 眼睛检测 haarcascade_eye_tree_eyeglasses.xml 人脸检测 haarcascade_frontalface_alt2.xm ...

  7. ARM(哈弗、冯氏结构、总线和IO访问、处理器状态和处理机模式)

    1.哈弗结构与冯氏结构 (1)区别: 是否有独立的存储架构和信号通道. (2)举例: 8086:冯氏结构(相同的存储相同的通道) STM32F103:哈弗结构(不同的存储.通道) 8051:改进的哈弗 ...

  8. K3违反内码唯一键约束

    K3有时候需要向数据库中插入数据,但是插入的时候遇到主键冲突的错误,可以用如下方法解决. 比如新增联系人时,完整错误如下:? ? 违反了 PRIMARY KEY 约束 'PK_CRM_Contact' ...

  9. DM642学习:CMD、GEL文件

    在建立ccs工程的时候,cmd文件和gel文件非常重要,如不能配置好会出现一些莫名其妙的问题. 1. CMD文件: 不同的DSP芯片内集成的存储器大小各异,但其配置方式是类似的.大家可通过查阅DSP芯 ...

  10. C语言结构体数组遇上typedef

    昨天韩同学在做数据结构题的时候,问了我一个关于typedef 与结构体数组的问题: typedef struct vexnode { int vertex; arcnode* firstarc; }a ...