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. PyTorch对ResNet网络的实现解析

    PyTorch对ResNet网络的实现解析 1.首先导入需要使用的包 import torch.nn as nn import torch.utils.model_zoo as model_zoo # ...

  2. (四)tensorflow-基础(数据类型,张量操作,数学运算)

    摘要: 1.数据类型:标量.向量.矩阵.张量  :数值精度:变量(张量) 2.张量操作:索引.切片.维度操作 3.数学运算:加减乘除(整除和余除):乘方(平方.开方.指数):自然底对数(任意底对数需要 ...

  3. api接口出现Provisional headers are shown,

    问题分析:根据反馈可以知道,发起请求,但服务器未及时响应,原因可能是超时,或者被拦截

  4. QQ第三方登录(二)

    首先我们先来看一下我的目录 Connect2.1  是我们从下载的SDK,内容包含 其他文件在配置之后全部删除了! index.html 是我们点击登陆的页面(以下为html中的代码) <cen ...

  5. 【翻译】浅析为何使用融合CDN是大趋势

    使用传统CDN的用户遇到的新问题 随着云计算时代的快速发展,尤其是流媒体大视频时代的到来,用户在是使用过往CDN节点资源调配将面临很多问题: 问题1: 流媒体时代不局限于静态内容分发,直播点播等视频服 ...

  6. go语言 内置的椭圆数字签名及其验证算法

    package main import ( "crypto/ecdsa" "crypto/elliptic" "crypto/rand" & ...

  7. vue老项目升级vue-cli3.0

    第一步我们卸载全局的vue2.0然后: 打开命令行 输入npm install -g @vue/cli-init   这个就是会安装全局的vue3.0版本.安装好之后我们也可以vue -V查看当前vu ...

  8. [CF467C] George and Job - DP,前缀和

    简单dp + 前缀和 你谷这乱标难度的风气真是-- #include <bits/stdc++.h> using namespace std; #define int long long ...

  9. 大数据-redis

    redis 分布式缓存数据库 单节点安装 tar -zxvf redis-3.2.9.tar.gz cd /opt/sxt/redis-3.2.9 yum -y install gcc tcl (依赖 ...

  10. hadoop cdh 后启动群起脚本总是起不起来的一些坑

    最近都在流行大数据什么的,然后偶然之间加入了一个物联网的小公司,可以使用hadoop 来做数据分析,于是心中窃喜,可以有机会接触大数据了,从此走上人生巅峰赢取白富美. 可是成功的道路总不是一帆风顺滴, ...