(二)Linux ALSA 音频系统:逻辑设备篇

逻辑设备篇

转自:https://me.csdn.net/zyuanyun

Linux ALSA 音频系统:逻辑设备篇

Linux ALSA 音频系统:逻辑设备篇

6. 声卡和 PCM 设备的建立过程

前面几章分析了 Codec、Platform、Machine 驱动的组成部分及其注册过程,这三者都是物理设备相关的,大家应该对音频物理链路有了一定的认知。接着分析音频驱动的中间层,由于这些并不是真正的物理设备,故我们称之为逻辑设备。

PCM 逻辑设备,我们又习惯称之为 PCM 中间层或 pcm native,起着承上启下的作用:往上是与用户态接口的交互,实现音频数据在用户态和内核态之间的拷贝;往下是触发 codec、platform、machine 的操作函数,实现音频数据在 dma_buffer <-> cpu_dai <-> codec 之间的传输。后面章节将会详细分析这个过程,这里还是先从声卡的注册谈起。

//
// 声明:本文由 http://blog.csdn.net/zyuanyun 原创,转载请注明出处,谢谢!
//

声卡驱动中,一般挂载着多个逻辑设备,看看我们计算机的声卡驱动有几个逻辑设备:

$ cat /proc/asound/devices 
  1:        : sequencer
  2: [ 0- 7]: digital audio playback
  3: [ 0- 3]: digital audio playback
  4: [ 0- 2]: digital audio capture
  5: [ 0- 0]: digital audio playback
  6: [ 0- 0]: digital audio capture
  7: [ 0- 3]: hardware dependent
  8: [ 0- 0]: hardware dependent
  9: [ 0]   : control
 33:        : timer

     
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
DeviceDescription
digital audio playback用于回放的 PCM 设备
digital audio capture用于录制的 PCM 设备
control用于声卡控制的 CTL 设备,如通路控制、音量调整等
timer定时器设备
sequencer音序器设备

嵌入式系统中,通常我们更关心 PCM 和 CTL 这两种设备。

设备节点如下:

$ ll /dev/snd
drwxr-xr-x   3 root root      260 Feb 26 13:59 ./
drwxr-xr-x  16 root root     4300 Mar  6 17:07 ../
drwxr-xr-x   2 root root       60 Feb 26 13:59 by-path/
crw-rw---T+  1 root audio 116,  9 Feb 26 13:59 controlC0
crw-rw---T+  1 root audio 116,  8 Feb 26 13:59 hwC0D0
crw-rw---T+  1 root audio 116,  7 Feb 26 13:59 hwC0D3
crw-rw---T+  1 root audio 116,  6 Feb 26 13:59 pcmC0D0c
crw-rw---T+  1 root audio 116,  5 Mar  6 19:08 pcmC0D0p
crw-rw---T+  1 root audio 116,  4 Feb 26 13:59 pcmC0D2c
crw-rw---T+  1 root audio 116,  3 Feb 26 13:59 pcmC0D3p
crw-rw---T+  1 root audio 116,  2 Feb 26 13:59 pcmC0D7p
crw-rw---T+  1 root audio 116,  1 Feb 26 13:59 seq
crw-rw---T+  1 root audio 116, 33 Feb 26 13:59 timer

 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

可以看到这些设备节点的 Major=116,Minor 则与 /proc/asound/devices 所列的对应起来,都是字符设备。上层可以通过 open/close/read/write/ioctl 等系统调用来操作声卡设备,这和其他字符设备类似,但一般情况下我们会使用已封装好的用户接口库如 tinyalsa、alsa-lib。

6.1. 声卡结构概述

回顾下 ASoC 是如何注册声卡的,详细请参考章节 5. ASoC machine driver,这里仅简单陈述下:

  • Machine 驱动初始化时,.name = "soc-audio" 的 platform_device 与 platform_driver 匹配成功,触发 soc_probe() 调用;
  • 继而调用 snd_soc_register_card()
    • 为每个音频物理链路找到对应的 codec、codec_dai、cpu_dai、platform 设备实例,完成 dai_link 的绑定;
    • 调用 snd_card_create() 创建声卡;
    • 依次回调 cpu_dai、codec、platform 的 probe() 函数,完成物理设备的初始化;
  • 随后调用 soc_new_pcm()
    • 设置 pcm native 中要使用的 pcm 操作函数,这些函数用于驱动音频物理设备,包括 machine、codec_dai、cpu_dai、platform;
    • 调用 snd_pcm_new() 创建 pcm 逻辑设备,回放子流和录制子流都在这里创建;
    • 回调 platform 驱动的 pcm_new(),完成音频 dma 设备初始化和 dma buffer 内存分配;
  • 最后调用 snd_card_register() 注册声卡。

关于音频物理设备部分(Codec/Platform/Machine)不再累述,下面详细分析声卡和 PCM 逻辑设备的注册过程。

上面提到声卡驱动上挂着多个逻辑子设备,有 pcm 音频数据流、control 混音器、midi 迷笛、timer 定时器、sequencer 音序器等。

                  +-----------+
                  | snd_card  |
                  +-----------+
                    |   |   |
        +-----------+   |   +------------+
		|               |                |
+-----------+    +-----------+    +-----------+
 |  snd_pcm  |    |snd_control|    | snd_timer |    ...
 +-----------+    +-----------+    +-----------+

 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

这些与声音相关的逻辑设备都在结构体 snd_card 管理之下,可以说 snd_card 是 alsa 中最顶层的结构。我们再看看 alsa 声卡驱动的大致结构图(不是严格的 UML 类图,有结构体定义、模块关系、函数调用,方便标示结构模块的层次及关系):

snd_card

snd_cards:记录着所注册的声卡实例,每个声卡实例有着各自的逻辑设备,如 PCM 设备、CTL 设备、MIDI 设备等,并一一记录到 snd_carddevices 链表上
snd_minors:记录着所有逻辑设备的上下文信息,它是声卡逻辑设备与系统调用 API 之间的桥梁;每个 snd_minor 在逻辑设备注册时被填充,在逻辑设备使用时就可以从该结构体中得到相应的信息(主要是系统调用函数集 file_operations

6.2. 声卡的创建

声卡实例通过函数 snd_card_create() 来创建,其函数原型:

/**
 *  snd_card_create - create and initialize a soundcard structure
 *  @idx: card index (address) [0 ... (SNDRV_CARDS-1)]
 *  @xid: card identification (ASCII string)
 *  @module: top level module for locking
 *  @extra_size: allocate this extra size after the main soundcard structure
 *  @card_ret: the pointer to store the created card instance
 *
 *  Creates and initializes a soundcard structure.
 *
 *  The function allocates snd_card instance via kzalloc with the given
 *  space for the driver to use freely.  The allocated struct is stored
 *  in the given card_ret pointer.
 *
 *  Returns zero if successful or a negative error code.
 */
int snd_card_create(int idx, const char *xid,
            struct module *module, int extra_size,
            struct snd_card **card_ret)

 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

注释非常详细,简单说下:

  • idx:声卡的编号,如为 -1,则由系统自动分配
  • xid:声卡标识符,如为 NULL,则以 snd_card 的 shortname 或 longname 代替
  • card_ret:返回所创建的声卡实例的指针

如下是我的计算机的声卡信息:

$ cat /proc/asound/cards
 0 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xf7c30000 irq 47

 
  • 1
  • 2
  • 3
  • number:0
  • id:PCH
  • shortname:HDA Intel PCH
  • longname:HDA Intel PCH at 0xf7c30000 irq 47

shortname、longname 常用于打印信息,上面的声卡信息是通过如下函数打印出来的:

static void snd_card_info_read(struct snd_info_entry *entry,
                   struct snd_info_buffer *buffer)
{
    int idx, count;
    struct snd_card *card;
<span class="token keyword">for</span> <span class="token punctuation">(</span>idx <span class="token operator">=</span> count <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> idx <span class="token operator">&lt;</span> SNDRV_CARDS<span class="token punctuation">;</span> idx<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">mutex_lock</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>snd_card_mutex<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>card <span class="token operator">=</span> snd_cards<span class="token punctuation">[</span>idx<span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token constant">NULL</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        count<span class="token operator">++</span><span class="token punctuation">;</span>
        <span class="token function">snd_iprintf</span><span class="token punctuation">(</span>buffer<span class="token punctuation">,</span> <span class="token string">"%2i [%-15s]: %s - %s\n"</span><span class="token punctuation">,</span>
                idx<span class="token punctuation">,</span>
                card<span class="token operator">-&gt;</span>id<span class="token punctuation">,</span>
                card<span class="token operator">-&gt;</span>driver<span class="token punctuation">,</span>
                card<span class="token operator">-&gt;</span>shortname<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">snd_iprintf</span><span class="token punctuation">(</span>buffer<span class="token punctuation">,</span> <span class="token string">"                      %s\n"</span><span class="token punctuation">,</span>
                card<span class="token operator">-&gt;</span>longname<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token function">mutex_unlock</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>snd_card_mutex<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>count<span class="token punctuation">)</span>
    <span class="token function">snd_iprintf</span><span class="token punctuation">(</span>buffer<span class="token punctuation">,</span> <span class="token string">"--- no soundcards ---\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

6.3. 逻辑设备的创建

当声卡实例建立后,接着可以创建声卡下面的各个逻辑设备了。每个逻辑设备创建时,都会调用 snd_device_new() 生成一个 snd_device 实例,并把该实例挂到声卡 snd_carddevices 链表上。alsa 驱动为各种逻辑设备提供了创建接口,如下:

DeviceInterface
PCMsnd_pcm_new()
CONTROLsnd_ctl_create()
MIDIsnd_rawmidi_new()
TIMERsnd_timer_new()
SEQUENCERsnd_seq_device_new()
JACKsnd_jack_new()

这些接口的一般过程如下:

int snd_xxx_new()
{
    // 这些接口供逻辑设备注册时回调
    static struct snd_device_ops ops = {
        .dev_free = snd_xxx_dev_free,
        .dev_register = snd_xxx_dev_register,
        .dev_disconnect = snd_xxx_dev_disconnect,
    };
<span class="token comment">// 逻辑设备实例初始化</span>

<span class="token comment">// 新建一个设备实例 snd_device,挂到 snd_card 的 devices 链表上,把该逻辑设备纳入声卡的管理当中,SNDRV_DEV_xxx 是逻辑设备的类型</span>
<span class="token keyword">return</span> <span class="token function">snd_device_new</span><span class="token punctuation">(</span>card<span class="token punctuation">,</span> SNDRV_DEV_xxx<span class="token punctuation">,</span> card<span class="token punctuation">,</span> <span class="token operator">&amp;</span>ops<span class="token punctuation">)</span><span class="token punctuation">;</span>

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

其中 snd_device_ops 是声卡逻辑设备的注册函数集,dev_register() 回调尤其重要,它在声卡注册时被调用,用于建立系统的设备节点,/dev/snd/ 目录的设备节点都是在这里创建的,通过这些设备节点可系统调用 open/release/read/write/ioctl… 访问操作该逻辑设备。

例如 snd_ctl_dev_register()

// CTL 设备的系统调用接口
static const struct file_operations snd_ctl_f_ops =
{
    .owner =    THIS_MODULE,
    .read =     snd_ctl_read,
    .open =     snd_ctl_open,
    .release =  snd_ctl_release,
    .llseek =   no_llseek,
    .poll =     snd_ctl_poll,
    .unlocked_ioctl =   snd_ctl_ioctl,
    .compat_ioctl = snd_ctl_ioctl_compat,
    .fasync =   snd_ctl_fasync,
};

/*

  • registration of the control device
    /
    static int snd_ctl_dev_register(struct snd_device
    device)
    {
    struct snd_card *card = device->device_data;
    int err, cardnum;
    char name[16];

    if (snd_BUG_ON(!card))
    return -ENXIO;
    cardnum = card->number;
    if (snd_BUG_ON(cardnum < 0 || cardnum >= SNDRV_CARDS))
    return -ENXIO;
    sprintf(name, “controlC%i”, cardnum);
    if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, card, -1,
    &snd_ctl_f_ops, card, name)) < 0)
    return err;
    return 0;
    }

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34

事实是调用 snd_register_device_for_dev ()

  • 分配并初始化一个 snd_minor 实例;
  • 保存该 snd_minor 实例到 snd_minors 数组中;
  • 调用 device_create() 生成设备文件节点。
/**
 * snd_register_device_for_dev - Register the ALSA device file for the card
 * @type: the device type, SNDRV_DEVICE_TYPE_XXX
 * @card: the card instance
 * @dev: the device index
 * @f_ops: the file operations
 * @private_data: user pointer for f_ops->open()
 * @name: the device file name
 * @device: the &struct device to link this new device to
 *
 * Registers an ALSA device file for the given card.
 * The operators have to be set in reg parameter.
 *
 * Returns zero if successful, or a negative error code on failure.
 */
int snd_register_device_for_dev(int type, struct snd_card *card, int dev,
                const struct file_operations *f_ops,
                void *private_data,
                const char *name, struct device *device)
{
    int minor;
    struct snd_minor *preg;
<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token function">snd_BUG_ON</span><span class="token punctuation">(</span><span class="token operator">!</span>name<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token keyword">return</span> <span class="token operator">-</span>EINVAL<span class="token punctuation">;</span>
preg <span class="token operator">=</span> <span class="token function">kmalloc</span><span class="token punctuation">(</span><span class="token keyword">sizeof</span> <span class="token operator">*</span>preg<span class="token punctuation">,</span> GFP_KERNEL<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>preg <span class="token operator">==</span> <span class="token constant">NULL</span><span class="token punctuation">)</span>
    <span class="token keyword">return</span> <span class="token operator">-</span>ENOMEM<span class="token punctuation">;</span>
preg<span class="token operator">-&gt;</span>type <span class="token operator">=</span> type<span class="token punctuation">;</span>
preg<span class="token operator">-&gt;</span>card <span class="token operator">=</span> card <span class="token operator">?</span> card<span class="token operator">-&gt;</span>number <span class="token punctuation">:</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">;</span>
preg<span class="token operator">-&gt;</span>device <span class="token operator">=</span> dev<span class="token punctuation">;</span>
preg<span class="token operator">-&gt;</span>f_ops <span class="token operator">=</span> f_ops<span class="token punctuation">;</span>
preg<span class="token operator">-&gt;</span>private_data <span class="token operator">=</span> private_data<span class="token punctuation">;</span>
<span class="token function">mutex_lock</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>sound_mutex<span class="token punctuation">)</span><span class="token punctuation">;</span>

#ifdef CONFIG_SND_DYNAMIC_MINORS
minor = snd_find_free_minor(type);
#else
minor = snd_kernel_minor(type, card, dev);
if (minor >= 0 && snd_minors[minor])
minor = -EBUSY;
#endif
if (minor < 0) {
mutex_unlock(&sound_mutex);
kfree(preg);
return minor;
}
snd_minors[minor] = preg;
preg->dev = device_create(sound_class, device, MKDEV(major, minor),
private_data, “%s”, name);
if (IS_ERR(preg->dev)) {
snd_minors[minor] = NULL;
mutex_unlock(&sound_mutex);
minor = PTR_ERR(preg->dev);
kfree(preg);
return minor;
}

<span class="token function">mutex_unlock</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>sound_mutex<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60

上面过程是声卡注册时才被回调的。

6.4. 声卡的注册

当声卡下的所有逻辑设备都已经准备就绪后,就可以调用 snd_card_register() 注册声卡了:

  • 创建声卡的 sysfs 设备;
  • 调用 snd_device_register_all() 注册所有挂在该声卡下的逻辑设备;
  • 建立 proc 信息文件和 sysfs 属性文件。
/**
 *  snd_card_register - register the soundcard
 *  @card: soundcard structure
 *
 *  This function registers all the devices assigned to the soundcard.
 *  Until calling this, the ALSA control interface is blocked from the
 *  external accesses.  Thus, you should call this function at the end
 *  of the initialization of the card.
 *
 *  Returns zero otherwise a negative error code if the registration failed.
 */
int snd_card_register(struct snd_card *card)
{
    int err;
<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token function">snd_BUG_ON</span><span class="token punctuation">(</span><span class="token operator">!</span>card<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token keyword">return</span> <span class="token operator">-</span>EINVAL<span class="token punctuation">;</span>

<span class="token comment">// 创建 sysfs 设备,声卡的 class 将会出现在 /sys/class/sound/ 下面</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>card<span class="token operator">-&gt;</span>card_dev<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    card<span class="token operator">-&gt;</span>card_dev <span class="token operator">=</span> <span class="token function">device_create</span><span class="token punctuation">(</span>sound_class<span class="token punctuation">,</span> card<span class="token operator">-&gt;</span>dev<span class="token punctuation">,</span>
                       <span class="token function">MKDEV</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span> card<span class="token punctuation">,</span>
                       <span class="token string">"card%i"</span><span class="token punctuation">,</span> card<span class="token operator">-&gt;</span>number<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token function">IS_ERR</span><span class="token punctuation">(</span>card<span class="token operator">-&gt;</span>card_dev<span class="token punctuation">)</span><span class="token punctuation">)</span>
        card<span class="token operator">-&gt;</span>card_dev <span class="token operator">=</span> <span class="token constant">NULL</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token comment">// 遍历挂在该声卡的所有逻辑设备,回调各 snd_device 的 ops-&gt;dev_register() 完成各逻辑设备的注册</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>err <span class="token operator">=</span> <span class="token function">snd_device_register_all</span><span class="token punctuation">(</span>card<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">&lt;</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token keyword">return</span> err<span class="token punctuation">;</span>
<span class="token function">mutex_lock</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>snd_card_mutex<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>snd_cards<span class="token punctuation">[</span>card<span class="token operator">-&gt;</span>number<span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token comment">/* already registered */</span>
    <span class="token function">mutex_unlock</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>snd_card_mutex<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">*</span>card<span class="token operator">-&gt;</span>id<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token comment">/* make a unique id name from the given string */</span>
    <span class="token keyword">char</span> tmpid<span class="token punctuation">[</span><span class="token keyword">sizeof</span><span class="token punctuation">(</span>card<span class="token operator">-&gt;</span>id<span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token function">memcpy</span><span class="token punctuation">(</span>tmpid<span class="token punctuation">,</span> card<span class="token operator">-&gt;</span>id<span class="token punctuation">,</span> <span class="token keyword">sizeof</span><span class="token punctuation">(</span>card<span class="token operator">-&gt;</span>id<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">snd_card_set_id_no_lock</span><span class="token punctuation">(</span>card<span class="token punctuation">,</span> tmpid<span class="token punctuation">,</span> tmpid<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
    <span class="token comment">/* create an id from either shortname or longname */</span>
    <span class="token keyword">const</span> <span class="token keyword">char</span> <span class="token operator">*</span>src<span class="token punctuation">;</span>
    src <span class="token operator">=</span> <span class="token operator">*</span>card<span class="token operator">-&gt;</span>shortname <span class="token operator">?</span> card<span class="token operator">-&gt;</span>shortname <span class="token punctuation">:</span> card<span class="token operator">-&gt;</span>longname<span class="token punctuation">;</span>
    <span class="token function">snd_card_set_id_no_lock</span><span class="token punctuation">(</span>card<span class="token punctuation">,</span> src<span class="token punctuation">,</span>
                <span class="token function">retrieve_id_from_card_name</span><span class="token punctuation">(</span>src<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
snd_cards<span class="token punctuation">[</span>card<span class="token operator">-&gt;</span>number<span class="token punctuation">]</span> <span class="token operator">=</span> card<span class="token punctuation">;</span> <span class="token comment">// 把该声卡实例保存到 snd_cards 数组中</span>
<span class="token function">mutex_unlock</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>snd_card_mutex<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 声卡相关信息,见:/proc/asound/card0</span>
<span class="token function">init_info_for_card</span><span class="token punctuation">(</span>card<span class="token punctuation">)</span><span class="token punctuation">;</span>

#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
if (snd_mixer_oss_notify_callback)
snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER);
#endif
// 声卡的 sysfs 属性节点
if (card->card_dev) {
err = device_create_file(card->card_dev, &card_id_attrs);
if (err < 0)
return err;
err = device_create_file(card->card_dev, &card_number_attrs);
if (err < 0)
return err;
}

<span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68

至此完成了声卡及声卡下的所有逻辑设备的注册,用户态可以通过系统调用来访问这些设备了。

6.5. PCM 设备的创建

最后我们简单描述下 PCM 设备的建立过程:

snd_soc_instantiate_card

snd_pcm_set_ops:设置 PCM 设备的操作接口,设置完成后,在 PCM 设备层即可访问操作底层音频物理设备。
snd_pcm_new

  • 创建一个 PCM 设备实例 snd_pcm
  • 创建 playback stream 和 capture stream,旗下的 substream 也同时建立;
  • 调用 snd_device_new() 把 PCM 设备挂到声卡的 devices 链表上。
static int _snd_pcm_new(struct snd_card *card, const char *id, int device,
        int playback_count, int capture_count, bool internal,
        struct snd_pcm **rpcm)
{
    struct snd_pcm *pcm;
    int err;
    static struct snd_device_ops ops = {
        .dev_free = snd_pcm_dev_free,
        .dev_register = snd_pcm_dev_register,
        .dev_disconnect = snd_pcm_dev_disconnect,
    };
if (snd_BUG_ON(!card))
    return -ENXIO;
if (rpcm)
    *rpcm = NULL;
pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
if (pcm == NULL) {
    snd_printk(KERN_ERR "Cannot allocate PCM\n");
    return -ENOMEM;
}
pcm-&gt;card = card;
pcm-&gt;device = device;
pcm-&gt;internal = internal;
if (id)
    strlcpy(pcm-&gt;id, id, sizeof(pcm-&gt;id));
if ((err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK, playback_count)) &lt; 0) {
    snd_pcm_free(pcm);
    return err;
}
if ((err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_CAPTURE, capture_count)) &lt; 0) {
    snd_pcm_free(pcm);
    return err;
}
mutex_init(&amp;pcm-&gt;open_mutex);
init_waitqueue_head(&amp;pcm-&gt;open_wait);
if ((err = snd_device_new(card, SNDRV_DEV_PCM, pcm, &amp;ops)) &lt; 0) {
    snd_pcm_free(pcm);
    return err;
}
if (rpcm)
    *rpcm = pcm;
return 0;

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44

我们再看看 PCM 设备的系统调用:

const struct file_operations snd_pcm_f_ops[2] = {
    {
        .owner =        THIS_MODULE,
        .write =        snd_pcm_write,
        .aio_write =        snd_pcm_aio_write,
        .open =         snd_pcm_playback_open,
        .release =      snd_pcm_release,
        .llseek =       no_llseek,
        .poll =         snd_pcm_playback_poll,
        .unlocked_ioctl =   snd_pcm_playback_ioctl,
        .compat_ioctl =     snd_pcm_ioctl_compat,
        .mmap =         snd_pcm_mmap,
        .fasync =       snd_pcm_fasync,
        .get_unmapped_area =    snd_pcm_get_unmapped_area,
    },
    {
        .owner =        THIS_MODULE,
        .read =         snd_pcm_read,
        .aio_read =     snd_pcm_aio_read,
        .open =         snd_pcm_capture_open,
        .release =      snd_pcm_release,
        .llseek =       no_llseek,
        .poll =         snd_pcm_capture_poll,
        .unlocked_ioctl =   snd_pcm_capture_ioctl,
        .compat_ioctl =     snd_pcm_ioctl_compat,
        .mmap =         snd_pcm_mmap,
        .fasync =       snd_pcm_fasync,
        .get_unmapped_area =    snd_pcm_get_unmapped_area,
    }
};

 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

snd_pcm_f_ops 作为 snd_register_device_for_dev() 的参数被传入,并被记录在 snd_minors[minor] 中的字段 f_ops 中。snd_pcm_f_ops[0] 是回放使用的系统调用接口,snd_pcm_f_ops[1] 是录制使用的系统调用接口。

7. Frame & Period

后面章节将分析 dma buffer 的管理,其中细节需要对音频数据相关概念有一定的了解。因此本章说明下音频数据中的几个重要概念:

  • Sample:样本长度,音频数据最基本的单位,常见的有 8 位和 16 位;
  • Channel:声道数,分为单声道 mono 和立体声 stereo;
  • Frame:帧,构成一个完整的声音单元,所谓的声音单元是指一个采样样本,Frame = Sample * channel
  • Rate:又称 sample rate,采样率,即每秒的采样次数,针对帧而言;
  • Period Size:周期,每次硬件中断处理音频数据的帧数,对于音频设备的数据读写,以此为单位;
  • Buffer Size:数据缓冲区大小,这里指 runtime 的 buffer size,而不是结构图 snd_pcm_hardware 中定义的 buffer_bytes_max;一般来说 buffer_size = period_size * period_count, period_count 相当于处理完一个 buffer 数据所需的硬件中断次数。

下面一张图直观的表示 buffer/period/frame/sample 之间的关系:

      read/write pointer
               |
               v
+-----------------------------+--------------+--------------+
|              |              |              |              |buffer = 4 periods
+--------------+--------------+--------------+--------------+
                     ^
                     |
               +---+---+------+
               |   |   |  ... |period = 1024 frames
               +---+---+------+
                     ^
                     |
                   +---+
                   |L|R|frame = 2 samples (left + right)
                   +---+
                    sample = 2 bytes (16bit)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

这个 buffer 中有 4 个 period,每当 DMA 搬运完一个 period 的数据就会出生一次中断,因此搬运这个 buffer 中的数据将产生 4 次中断。ALSA 为什么这样做?因为数据缓存区可能很大,一次传输可能会导致不可接受的延迟;为了解决这个问题,alsa 把缓存区拆分成多个周期,以周期为单元传输数据。

7.1. Frames & Periods

敏感的读者会察觉到 period 和 buffer size 在 PCM 数据搬运中扮演着非常重要的角色。下面引用两段来自 alsa 官网对 Period 的详细解释:

Period

The interval between interrupts from the hardware. This defines the input latency, since the CPU will not have any idea that there is data waiting until the audio interface interrupts it.
The audio interface has a “pointer” that marks the current position for read/write in its h/w buffer. The pointer circles around the buffer as long as the interface is running.
Typically, there are an integral number of periods per traversal of the h/w buffer, but not always. There is at least one card (ymfpci) that generates interrupts at a fixed rate indepedent of the buffer size (which can be changed), resulting in some “odd” effects compared to more traditional designs.
Note: h/w generally defines the interrupt in frames, though not always.
Alsa’s period size setting will affect how much work the CPU does. if you set the period size low, there will be more interrupts and the work that is done every interrupt will be done more often. So, if you don’t care about low latency, set the period size large as possible and you’ll have more CPU cycles for other things. The defaults that ALSA provides are in the middle of the range, typically.
(from an old AlsaDevel thread[1], quoting Paul Davis)
Retrieved from “http://alsa.opensrc.org/Period

FramesPeriods

A frame is equivalent of one sample being played, irrespective of the number of channels or the number of bits. e.g.

  • 1 frame of a Stereo 48khz 16bit PCM stream is 4 bytes.
  • 1 frame of a 5.1 48khz 16bit PCM stream is 12 bytes.
    A period is the number of frames in between each hardware interrupt. The poll() will return once a period.
    The buffer is a ring buffer. The buffer size always has to be greater than one period size. Commonly this is 2*period size, but some hardware can do 8 periods per buffer. It is also possible for the buffer size to not be an integer multiple of the period size.
    Now, if the hardware has been set to 48000Hz , 2 periods, of 1024 frames each, making a buffer size of 2048 frames. The hardware will interrupt 2 times per buffer. ALSA will endeavor to keep the buffer as full as possible. Once the first period of samples has been played, the third period of samples is transfered into the space the first one occupied while the second period of samples is being played. (normal ring buffer behaviour).

Additional example
Here is an alternative example for the above discussion.
Say we want to work with a stereo, 16-bit, 44.1 KHz stream, one-way (meaning, either in playback or in capture direction). Then we have:

  • ‘stereo’ = number of channels: 2
  • 1 analog sample is represented with 16 bits = 2 bytes
  • 1 frame represents 1 analog sample from all channels; here we have 2 channels, and so: 1 frame = (num_channels) * (1 sample in bytes) = (2 channels) * (2 bytes (16 bits) per sample) = 4 bytes (32 bits)
  • To sustain 2x 44.1 KHz analog rate - the system must be capable of data transfer rate, in Bytes/sec: Bps_rate = (num_channels) * (1 sample in bytes) * (analog_rate) = (1 frame) * (analog_rate) = ( 2 channels ) * (2 bytes/sample) * (44100 samples/sec) = 2244100 = 176400 Bytes/sec

Now, if ALSA would interrupt each second, asking for bytes - we’d need to have 176400 bytes ready for it (at end of each second), in order to sustain analog 16-bit stereo @ 44.1Khz.

  • If it would interrupt each half a second, correspondingly for the same stream we’d need 176400/2 = 88200 bytes ready, at each interrupt;
  • if the interrupt hits each 100 ms, we’d need to have 176400*(0.1/1) = 17640 bytes ready, at each interrupt.

We can control when this PCM interrupt is generated, by setting a period size, which is set in frames.

  • Thus, if we set 16-bit stereo @ 44.1Khz, and the period_size to 4410 frames => (for 16-bit stereo @ 44.1Khz, 1 frame equals 4 bytes - so 4410 frames equal 4410*4 = 17640 bytes) => an interrupt will be generated each 17640 bytes - that is, each 100 ms.
  • Correspondingly, buffer_size should be at least 2period_size = 24410 = 8820 frames (or 8820*4 = 35280 bytes).

It seems (writing-an-alsa-driver.pdf), however, that it is the ALSA runtime that decides on the actual buffer_size and period_size, depending on: the requested number of channels, and their respective properties (rate and sampling resolution) - as well as the parameters set in the snd_pcm_hardware structure (in the driver).
Also, the following quote may be relevant, from “(alsa-devel) Questions about writing a new ALSA driver for a very limitted device”:

The “frame” represents the unit, 1 frame = # channels x sample_bytes.
In your case, 1 frame corresponds to 2 channels x 16 bits = 4 bytes.

The periods is the number of periods in a ring-buffer. In OSS, called
as “fragments”.

So,

  • buffer_size = period_size * periods
  • period_bytes = period_size * bytes_per_frame
  • bytes_per_frame = channels * bytes_per_sample

I still don’t understand what ‘period_size’ and a ‘period’ is?

The “period” defines the frequency to update the status, usually via the invokation of interrupts. The “period_size” defines the frame sizes corresponding to the “period time”. This term corresponds to the “fragment size” on OSS. On major sound hardwares, a ring-buffer is divided to several parts and an irq is issued on each boundary. The period_size defines the size of this chunk.

On some hardwares, the irq is controlled on the basis of a timer. In this case, the period is defined as the timer frequency to invoke an irq.

这里不做翻译了,简单说下 Frame 和 Period 要点:

  • Frame:帧,构成一个完整的声音单元,它的大小等于 sample_bits * channels;
  • Peroid:周期大小,即每次 dma 运输处理音频数据的帧数。如果周期大小设定得较大,则单次处理的数据较多,这意味着单位时间内硬件中断的次数较少,CPU 也就有更多时间处理其他任务,功耗也更低,但这样也带来一个显著的弊端——数据处理的时延会增大。

再说说 period bytes,对于 dma 处理来说,它直接关心的是数据大小,而非 period_size(一个周期的帧数),有个转换关系:period_bytes = period_size * sample_bits * channels / 8

由于 I2S 总线采样率是稳定的,我们可以计算 I2S 传输一个周期的数据所需的时间:transfer_time = 1 * period_size / sample_rate, in second

例如 period_size = 1024,sample_rate = 48KHz ,那么一个周期数据的传输时间是: 1 * 1024 / 48000 = 21.3 (ms)。

7.2. hrtimer 模拟 PCM 周期中断

4.2.1. pcm operations 章节中,我们提到:每次 dma 传输完成一个周期的数据传输后,都要调用 snd_pcm_period_elapsed() 告知 pcm native 一个周期的数据已经传送到 FIFO 上了,然后再次调用 dma 传输音频数据…如此循环。

但有些 Platform 可能由于设计如此或设计缺陷,dma 传输完一个周期的数据不会产生硬件中断。这样系统如何知道什么时候传输完一个周期的数据了呢?在上个章节的最后,我们提到 I2S 总线传输一个周期的数据所需的时间,这其实也是 dma 搬运一个周期的数据所需的时间,这很容易理解:I2S FIFO 消耗完一个周期的数据,dma 才接着搬运一个周期的数据到 I2S FIFO。

因此我们可以用定时器来模拟这种硬件中断:

  1. 触发dma搬运数据时,启动定时器开始计时;
  2. 当定时到 1 * period_size / sample_rate,这时 I2S 已传输完一个周期的音频数据了,进入定时器中断处理:调用 snd_pcm_period_elapsed() 告知 pcm native 一个周期的数据已经处理完毕了,同时准备下一次的数据搬运;
  3. 继续执行步骤 1…

为了更好保证数据传输的实时性,建议采用高精度定时器 hrtimer。

作者见过至少两家芯片在传输音频数据时需要用定时器模拟周期中断,一是 MTK 的智能手机处理器,二是 Freescale 的 i.MX 系列处理器。后者已经合入 Linux 内核代码,具体见:sound/soc/imx/imx-pcm-fiq.c,这里简略分析:

// 定时器中断处理例程
static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt)
{
    ...
<span class="token comment">/* If we've transferred at least a period then report it and
 * reset our poll time */</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>delta <span class="token operator">&gt;=</span> iprtd<span class="token operator">-&gt;</span>period<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">snd_pcm_period_elapsed</span><span class="token punctuation">(</span>substream<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 告知 pcm native 一个周期的数据已经处理完毕</span>
    iprtd<span class="token operator">-&gt;</span>last_offset <span class="token operator">=</span> iprtd<span class="token operator">-&gt;</span>offset<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token function">hrtimer_forward_now</span><span class="token punctuation">(</span>hrt<span class="token punctuation">,</span> <span class="token function">ns_to_ktime</span><span class="token punctuation">(</span>iprtd<span class="token operator">-&gt;</span>poll_time_ns<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 重新计时,poll_time_ns:I2S 传输一个周期的数据所需的时间</span>
<span class="token keyword">return</span> HRTIMER_RESTART<span class="token punctuation">;</span>

}

// hw_params 回调,数据传输开始前,先设置 dma 传输参数
static int snd_imx_pcm_hw_params(struct snd_pcm_substream substream,
struct snd_pcm_hw_params params)
{
struct snd_pcm_runtime runtime = substream->runtime;
struct imx_pcm_runtime_data iprtd = runtime->private_data;

iprtd<span class="token operator">-&gt;</span>size <span class="token operator">=</span> <span class="token function">params_buffer_bytes</span><span class="token punctuation">(</span>params<span class="token punctuation">)</span><span class="token punctuation">;</span>    <span class="token comment">// dma 缓冲区大小</span>
iprtd<span class="token operator">-&gt;</span>periods <span class="token operator">=</span> <span class="token function">params_periods</span><span class="token punctuation">(</span>params<span class="token punctuation">)</span><span class="token punctuation">;</span>      <span class="token comment">// 周期数</span>
iprtd<span class="token operator">-&gt;</span>period <span class="token operator">=</span> <span class="token function">params_period_bytes</span><span class="token punctuation">(</span>params<span class="token punctuation">)</span> <span class="token punctuation">;</span> <span class="token comment">// 周期大小</span>
iprtd<span class="token operator">-&gt;</span>offset <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
iprtd<span class="token operator">-&gt;</span>last_offset <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
iprtd<span class="token operator">-&gt;</span>poll_time_ns <span class="token operator">=</span> <span class="token number">1000000000</span> <span class="token operator">/</span> <span class="token function">params_rate</span><span class="token punctuation">(</span>params<span class="token punctuation">)</span> <span class="token operator">*</span>
            <span class="token function">params_period_size</span><span class="token punctuation">(</span>params<span class="token punctuation">)</span><span class="token punctuation">;</span>       <span class="token comment">// 计算 I2S 传输一个周期的数据所需的时间</span>
<span class="token function">snd_pcm_set_runtime_buffer</span><span class="token punctuation">(</span>substream<span class="token punctuation">,</span> <span class="token operator">&amp;</span>substream<span class="token operator">-&gt;</span>dma_buffer<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 设置 dma 缓冲区</span>

<span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>

}

// trigger 回调,触发 dma 传输或停止
static int snd_imx_pcm_trigger(struct snd_pcm_substream substream, int cmd)
{
struct snd_pcm_runtime runtime = substream->runtime;
struct imx_pcm_runtime_data *iprtd = runtime->private_data;

<span class="token keyword">switch</span> <span class="token punctuation">(</span>cmd<span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">case</span> SNDRV_PCM_TRIGGER_START<span class="token punctuation">:</span>
<span class="token keyword">case</span> SNDRV_PCM_TRIGGER_RESUME<span class="token punctuation">:</span>
<span class="token keyword">case</span> SNDRV_PCM_TRIGGER_PAUSE_RELEASE<span class="token punctuation">:</span>
    <span class="token function">atomic_set</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>iprtd<span class="token operator">-&gt;</span>running<span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">hrtimer_start</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>iprtd<span class="token operator">-&gt;</span>hrt<span class="token punctuation">,</span> <span class="token function">ns_to_ktime</span><span class="token punctuation">(</span>iprtd<span class="token operator">-&gt;</span>poll_time_ns<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token comment">// 准备传输数据,启动定时器,开始计时</span>
          HRTIMER_MODE_REL<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">++</span>fiq_enable <span class="token operator">==</span> <span class="token number">1</span><span class="token punctuation">)</span>
        <span class="token function">enable_fiq</span><span class="token punctuation">(</span>imx_pcm_fiq<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 开始 dma 传输</span>

    <span class="token keyword">break</span><span class="token punctuation">;</span>

<span class="token keyword">case</span> SNDRV_PCM_TRIGGER_STOP<span class="token punctuation">:</span>
<span class="token keyword">case</span> SNDRV_PCM_TRIGGER_SUSPEND<span class="token punctuation">:</span>
<span class="token keyword">case</span> SNDRV_PCM_TRIGGER_PAUSE_PUSH<span class="token punctuation">:</span>
    <span class="token function">atomic_set</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>iprtd<span class="token operator">-&gt;</span>running<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">--</span>fiq_enable <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span>
        <span class="token function">disable_fiq</span><span class="token punctuation">(</span>imx_pcm_fiq<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 停止 dma 传输</span>

    <span class="token keyword">break</span><span class="token punctuation">;</span>
<span class="token keyword">default</span><span class="token punctuation">:</span>
    <span class="token keyword">return</span> <span class="token operator">-</span>EINVAL<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69

– to be continued…

                                </div>
            <link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-b6c3c6d139.css" rel="stylesheet">
                                            <div class="more-toolbox">
            <div class="left-toolbox">
                <ul class="toolbox-list">
                    
                    <li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
                        <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#csdnc-thumbsup"></use>
                    </svg><span class="name">点赞</span>
                    <span class="count">11</span>
                    </a></li>
                    <li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{&quot;mod&quot;:&quot;popu_824&quot;}"><svg class="icon" aria-hidden="true">
                        <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-csdnc-Collection-G"></use>
                    </svg><span class="name">收藏</span></a></li>
                    <li class="tool-item tool-active is-share"><a href="javascript:;"><svg class="icon" aria-hidden="true">
                        <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-csdnc-fenxiang"></use>
                    </svg>分享</a></li>
                    <!--打赏开始-->
                                            <!--打赏结束-->
                                            <li class="tool-item tool-more">
                        <a>
                        <svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
                        </a>
                        <ul class="more-box">
                            <li class="item"><a class="article-report">文章举报</a></li>
                        </ul>
                    </li>
                                        </ul>
            </div>
                        </div>
        <div class="person-messagebox">
            <div class="left-message"><a href="https://blog.csdn.net/zyuanyun">
                <img src="https://profile.csdnimg.cn/5/D/E/3_zyuanyun" class="avatar_pic" username="zyuanyun">
                                        <img src="https://g.csdnimg.cn/static/user-reg-year/1x/3.png" class="user-years">
                                </a></div>
            <div class="middle-message">
                                    <div class="title"><span class="tit"><a href="https://blog.csdn.net/zyuanyun" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}" target="_blank">zyuanyun</a></span>
                                        </div>
                <div class="text"><span>发布了4 篇原创文章</span> · <span>获赞 93</span> · <span>访问量 8万+</span></div>
            </div>
                            <div class="right-message">
                                        <a href="https://im.csdn.net/im/main.html?userName=zyuanyun" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信
                    </a>
                                                        <a class="btn btn-sm attented bt-button personal-watch" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}">已关注</a>
                                </div>
                        </div>
                </div>
</article>
<script>
$("#blog_detail_zk_collection").click(function(){
    window.csdn.articleCollection()
})
        <div class="recommend-box"><div class="recommend-item-box type_blog clearfix" data-report-click="{&quot;mod&quot;:&quot;popu_614&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/yankunkunkun/article/details/17535851&quot;,&quot;strategy&quot;:&quot;BlogCommendFromMachineLearnPai2&quot;,&quot;index&quot;:&quot;0&quot;}">
<div class="content" style="width: 852px;">
	<a href="https://blog.csdn.net/yankunkunkun/article/details/17535851" target="_blank" rel="noopener" title="ALSA驱动分析,比ALSA官方文档好理解多了">
	<h4 class="text-truncate oneline" style="width: 692px;">
			<em>ALSA</em>驱动分析,比<em>ALSA</em>官方文档好理解多了		</h4>
	<div class="info-box d-flex align-content-center">
		<p class="date-and-readNum oneline">
			<span class="date hover-show">12-24</span>
			<span class="read-num hover-hide">
				阅读数 
				987</span>
			</p>
		</div>
	</a>
	<p class="content" style="width: 852px;">
		<a href="https://blog.csdn.net/yankunkunkun/article/details/17535851" target="_blank" rel="noopener" title="ALSA驱动分析,比ALSA官方文档好理解多了">
			<span class="desc oneline">Linux ALSA声卡驱动之一:ALSA架构简介 http://blog.csdn.net/droidphone/article/details/6271122Linux ALSA声卡驱动之二:声卡...</span>
		</a>
		<span class="blog_title_box oneline ">
								<span class="type-show type-show-blog type-show-after">博文</span>
										<a target="_blank" rel="noopener" href="https://blog.csdn.net/yankunkunkun">来自:	<span class="blog_title"> yankunkunkun的专栏</span></a>
											</span>
	</p>
</div>
</div>
还能输入1000个字符
<div class="comment-list-container">
	<a id="comments"></a>
	<div class="comment-list-box"><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="9456537" data-replyname="lzbsnb2017">      <a target="_blank" href="https://me.csdn.net/lzbsnb2017"><img src="https://profile.csdnimg.cn/6/D/1/3_lzbsnb2017" username="lzbsnb2017" alt="lzbsnb2017" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a target="_blank" href="https://me.csdn.net/lzbsnb2017"><span class="name ">lzbsnb2017</span></a><span class="date" title="2019-04-01 22:51:44">9个月前</span><span class="floor-num"></span><span class="new-comment" style="">嗨,前辈,最近我在arm底下调试USB声卡,但是系统起来以后使用amixer列出 control设备 只识别到 Mic 单声道的设备,但是我USB声卡接的是LineIn双声道,系统却只识别MIC单身道,导致我用amixer调节音量不成功,请教您一下,这个您知道什么原因吗?怎么设置USB声卡为LineI你模式?<pre name="code2" class="csharp hljs"><ol class="hljs-ln" style="width:823px"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><code><span class="hljs-meta"># amixer </span></code></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><code>Simple mixer control <span class="hljs-string">'Speaker'</span>,<span class="hljs-number">0</span></code></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><code>  Capabilities: pvolume pswitch pswitch-joined</code></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><code>  Playback channels: Front Left - Front Right</code></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><code>  Limits: Playback <span class="hljs-number">0</span> - <span class="hljs-number">1008</span></code></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><code>  Mono:</code></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><code>  Front Left: Playback <span class="hljs-number">848</span> [<span class="hljs-number">84</span>%] [<span class="hljs-number">-10.00</span>dB] [<span class="hljs-keyword">on</span>]</code></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><code>  Front Right: Playback <span class="hljs-number">848</span> [<span class="hljs-number">84</span>%] [<span class="hljs-number">-10.00</span>dB] [<span class="hljs-keyword">on</span>]</code></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><code>Simple mixer control <span class="hljs-string">'Mic'</span>,<span class="hljs-number">0</span></code></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><code>  Capabilities: pvolume pvolume-joined cvolume cvolume-joined pswitch pswitch-joined cswitch cswitch-joined</code></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><code>  Playback channels: Mono</code></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><code>  Capture channels: Mono</code></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><code>  Limits: Playback <span class="hljs-number">0</span> - <span class="hljs-number">496</span> Capture <span class="hljs-number">0</span> - <span class="hljs-number">496</span></code></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><code>  Mono: Playback <span class="hljs-number">496</span> [<span class="hljs-number">100</span>%] [<span class="hljs-number">31.00</span>dB] [off] Capture <span class="hljs-number">496</span> [<span class="hljs-number">100</span>%] [<span class="hljs-number">31.00</span>dB] [<span class="hljs-keyword">on</span>]</code></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><code><span class="hljs-meta">#</span></code></div></div></li></ol></pre></span><span class="new-opt-box"><a class="btn btn-link-blue btn-report" data-type="report">举报</a><a class="btn btn-link-blue btn-reply" data-type="reply">回复</a></span></div><div class="comment-like " data-commentid="9456537"><svg t="1569296798904" class="icon " viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5522" width="200" height="200"><path d="M726.016 906.666667h-348.586667a118.016 118.016 0 0 1-116.992-107.904l-29.013333-362.666667A117.589333 117.589333 0 0 1 348.458667 309.333333H384c126.549333 0 160-104.661333 160-160 0-51.413333 39.296-88.704 93.397333-88.704 36.906667 0 71.68 18.389333 92.928 49.194667 26.88 39.04 43.178667 111.658667 12.714667 199.509333h95.530667a117.418667 117.418667 0 0 1 115.797333 136.106667l-49.28 308.522667a180.608 180.608 0 0 1-179.072 152.704zM348.458667 373.333333l-4.48 0.170667a53.461333 53.461333 0 0 0-48.768 57.472l29.013333 362.666667c2.218667 27.52 25.6 49.024 53.205333 49.024h348.544a116.949333 116.949333 0 0 0 115.925334-98.816l49.322666-308.736a53.418667 53.418667 0 0 0-52.650666-61.781334h-144.085334a32 32 0 0 1-28.458666-46.634666c45.909333-89.130667 28.885333-155.434667 11.562666-180.522667a48.981333 48.981333 0 0 0-40.192-21.504c-6.912 0-29.397333 1.792-29.397333 24.704 0 111.317333-76.928 224-224 224h-35.541333zM170.624 906.666667a32.042667 32.042667 0 0 1-31.872-29.44l-42.666667-533.333334a32.042667 32.042667 0 0 1 29.354667-34.474666c17.066667-1.408 33.024 11.733333 34.432 29.354666l42.666667 533.333334a32.042667 32.042667 0 0 1-31.914667 34.56z" p-id="5523"></path></svg><span></span></div></div></li></ul><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="8294264" data-replyname="qq_29545231">      <a target="_blank" href="https://me.csdn.net/qq_29545231"><img src="https://profile.csdnimg.cn/D/C/1/3_qq_29545231" username="qq_29545231" alt="qq_29545231" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a target="_blank" href="https://me.csdn.net/qq_29545231"><span class="name ">码农u号</span></a><span class="date" title="2018-08-02 12:54:34">1年前</span><span class="floor-num"></span><span class="new-comment" style="display:inline-block;margin-top:0px">1</span><span class="new-opt-box"><a class="btn btn-link-blue btn-report" data-type="report">举报</a><a class="btn btn-link-blue btn-reply" data-type="reply">回复</a></span></div><div class="comment-like " data-commentid="8294264"><svg t="1569296798904" class="icon " viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5522" width="200" height="200"><path d="M726.016 906.666667h-348.586667a118.016 118.016 0 0 1-116.992-107.904l-29.013333-362.666667A117.589333 117.589333 0 0 1 348.458667 309.333333H384c126.549333 0 160-104.661333 160-160 0-51.413333 39.296-88.704 93.397333-88.704 36.906667 0 71.68 18.389333 92.928 49.194667 26.88 39.04 43.178667 111.658667 12.714667 199.509333h95.530667a117.418667 117.418667 0 0 1 115.797333 136.106667l-49.28 308.522667a180.608 180.608 0 0 1-179.072 152.704zM348.458667 373.333333l-4.48 0.170667a53.461333 53.461333 0 0 0-48.768 57.472l29.013333 362.666667c2.218667 27.52 25.6 49.024 53.205333 49.024h348.544a116.949333 116.949333 0 0 0 115.925334-98.816l49.322666-308.736a53.418667 53.418667 0 0 0-52.650666-61.781334h-144.085334a32 32 0 0 1-28.458666-46.634666c45.909333-89.130667 28.885333-155.434667 11.562666-180.522667a48.981333 48.981333 0 0 0-40.192-21.504c-6.912 0-29.397333 1.792-29.397333 24.704 0 111.317333-76.928 224-224 224h-35.541333zM170.624 906.666667a32.042667 32.042667 0 0 1-31.872-29.44l-42.666667-533.333334a32.042667 32.042667 0 0 1 29.354667-34.474666c17.066667-1.408 33.024 11.733333 34.432 29.354666l42.666667 533.333334a32.042667 32.042667 0 0 1-31.914667 34.56z" p-id="5523"></path></svg><span></span></div></div></li></ul><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="8044448" data-replyname="flappy_boy">      <a target="_blank" href="https://me.csdn.net/flappy_boy"><img src="https://profile.csdnimg.cn/C/4/C/3_flappy_boy" username="flappy_boy" alt="flappy_boy" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a target="_blank" href="https://me.csdn.net/flappy_boy"><span class="name ">冇二哥</span></a><span class="date" title="2018-06-08 10:27:37">1年前</span><span class="floor-num"></span><span class="new-comment" style="display:inline-block;margin-top:0px">哥们,可以贴下你另外一个博客的地址吗?</span><span class="new-opt-box"><a class="btn btn-link-blue btn-report" data-type="report">举报</a><a class="btn btn-link-blue btn-reply" data-type="reply">回复</a></span></div><div class="comment-like " data-commentid="8044448"><svg t="1569296798904" class="icon " viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5522" width="200" height="200"><path d="M726.016 906.666667h-348.586667a118.016 118.016 0 0 1-116.992-107.904l-29.013333-362.666667A117.589333 117.589333 0 0 1 348.458667 309.333333H384c126.549333 0 160-104.661333 160-160 0-51.413333 39.296-88.704 93.397333-88.704 36.906667 0 71.68 18.389333 92.928 49.194667 26.88 39.04 43.178667 111.658667 12.714667 199.509333h95.530667a117.418667 117.418667 0 0 1 115.797333 136.106667l-49.28 308.522667a180.608 180.608 0 0 1-179.072 152.704zM348.458667 373.333333l-4.48 0.170667a53.461333 53.461333 0 0 0-48.768 57.472l29.013333 362.666667c2.218667 27.52 25.6 49.024 53.205333 49.024h348.544a116.949333 116.949333 0 0 0 115.925334-98.816l49.322666-308.736a53.418667 53.418667 0 0 0-52.650666-61.781334h-144.085334a32 32 0 0 1-28.458666-46.634666c45.909333-89.130667 28.885333-155.434667 11.562666-180.522667a48.981333 48.981333 0 0 0-40.192-21.504c-6.912 0-29.397333 1.792-29.397333 24.704 0 111.317333-76.928 224-224 224h-35.541333zM170.624 906.666667a32.042667 32.042667 0 0 1-31.872-29.44l-42.666667-533.333334a32.042667 32.042667 0 0 1 29.354667-34.474666c17.066667-1.408 33.024 11.733333 34.432 29.354666l42.666667 533.333334a32.042667 32.042667 0 0 1-31.914667 34.56z" p-id="5523"></path></svg><span></span></div></div></li></ul><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="8008225" data-replyname="weiqifa0">      <a target="_blank" href="https://me.csdn.net/weiqifa0"><img src="https://profile.csdnimg.cn/3/1/E/3_weiqifa0" username="weiqifa0" alt="weiqifa0" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a target="_blank" href="https://me.csdn.net/weiqifa0"><span class="name ">写代码的篮球球痴</span></a><span class="date" title="2018-05-30 17:57:51">1年前</span><span class="floor-num"></span><span class="new-comment" style="display:inline-block;margin-top:0px">分析的太到位了

大神,收下我的膝盖举报回复


  • 上一页
  • 1
  • 下一页

</div>
<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_59" data-pid="59"><script type="text/javascript">
(function() {
    var s = "_" + Math.random().toString(36).slice(2);
    document.write('<div style="" id="' + s + '"></div>');
    (window.slotbydup = window.slotbydup || []).push({
        id: "u3491668",
        container:  s
    });
})();

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_60" data-pid="60"><iframe src="https://adaccount.csdn.net/#/preview/1119?m=JctyncHpDLpJnLUJJinmLAHcbAStvLXpnnbSALboHXJQHAcSccpotSpHntQWibUQEUEpiiSnpbJALAJJJnQmEbUAncAcHJcnQtnQ&amp;k=" frameborder="0" width="100%" height="75px" scrolling="no"></iframe><img class="pre-img-lasy" data-src="https://kunyu.csdn.net/1.png?d=2&amp;k=&amp;m=JctyncHpDLpJnLUJJinmLAHcbAStvLXpnnbSALboHXJQHAcSccpotSpHntQWibUQEUEpiiSnpbJALAJJJnQmEbUAncAcHJcnQtnQ"></div></div>
		<div class="recommend-item-box blog-expert-recommend-box" style="display: block;">
		<div class="d-flex">
			<div class="blog-expert-recommend">
				<div class="blog-expert">
					<div class="blog-expert-flexbox" data-report-view="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/zyuanyun/article/details/59180272&quot;}"><div class="blog-expert-item"><div class="blog-expert-info-box"><div class="blog-expert-img-box" data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/zyuanyun/article/details/59180272&quot;}"><a href="https://blog.csdn.net/yankunkunkun" target="_blank"><img src="https://profile.csdnimg.cn/F/E/2/3_yankunkunkun" username="yankunkunkun" alt="maidong600" title="maidong600"></a><span data-report-click="{&quot;mod&quot;:&quot;popu_710&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/zyuanyun/article/details/59180272&quot;}"><span class="blog-expert-button-follow btn-red-follow" data-name="yankunkunkun" data-nick="maidong600">关注</span></span></div><div class="info"><span data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/zyuanyun/article/details/59180272&quot;}"><a href="https://blog.csdn.net/yankunkunkun" target="_blank"><h5 class="oneline" title="maidong600">maidong600</h5></a></span>  <p></p><p class="article-num" title="5篇文章"> 5篇文章</p><p class="article-num" title="排名:千里之外"> 排名:千里之外</p><p></p></div></div></div><div class="blog-expert-item"><div class="blog-expert-info-box"><div class="blog-expert-img-box" data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/zyuanyun/article/details/59180272&quot;}"><a href="https://blog.csdn.net/RadianceBlau" target="_blank"><img src="https://profile.csdnimg.cn/E/C/C/3_radianceblau" username="RadianceBlau" alt="RadianceBlau" title="RadianceBlau"></a><span data-report-click="{&quot;mod&quot;:&quot;popu_710&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/zyuanyun/article/details/59180272&quot;}"><span class="blog-expert-button-follow btn-red-follow" data-name="RadianceBlau" data-nick="RadianceBlau">关注</span></span></div><div class="info"><span data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/zyuanyun/article/details/59180272&quot;}"><a href="https://blog.csdn.net/RadianceBlau" target="_blank"><h5 class="oneline" title="RadianceBlau">RadianceBlau</h5></a></span>  <p></p><p class="article-num" title="88篇文章"> 88篇文章</p><p class="article-num" title="排名:千里之外"> 排名:千里之外</p><p></p></div></div></div><div class="blog-expert-item"><div class="blog-expert-info-box"><div class="blog-expert-img-box" data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/zyuanyun/article/details/59180272&quot;}"><a href="https://blog.csdn.net/weixin_41965270" target="_blank"><img src="https://profile.csdnimg.cn/7/E/6/3_weixin_41965270" username="weixin_41965270" alt="CNccion" title="CNccion"></a><span data-report-click="{&quot;mod&quot;:&quot;popu_710&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/zyuanyun/article/details/59180272&quot;}"><span class="blog-expert-button-follow btn-red-follow" data-name="weixin_41965270" data-nick="CNccion">关注</span></span></div><div class="info"><span data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/zyuanyun/article/details/59180272&quot;}"><a href="https://blog.csdn.net/weixin_41965270" target="_blank"><h5 class="oneline" title="CNccion">CNccion</h5></a></span>  <p></p><p class="article-num" title="29篇文章"> 29篇文章</p><p class="article-num" title="排名:千里之外"> 排名:千里之外</p><p></p></div></div></div><div class="blog-expert-item"><div class="blog-expert-info-box"><div class="blog-expert-img-box" data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/zyuanyun/article/details/59180272&quot;}"><a href="https://blog.csdn.net/DroidPhone" target="_blank"><img src="https://profile.csdnimg.cn/8/B/5/3_droidphone" username="DroidPhone" alt="DroidPhone" title="DroidPhone"></a><span data-report-click="{&quot;mod&quot;:&quot;popu_710&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/zyuanyun/article/details/59180272&quot;}"><span class="blog-expert-button-follow btn-red-follow" data-name="DroidPhone" data-nick="DroidPhone">关注</span></span></div><div class="info"><span data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/zyuanyun/article/details/59180272&quot;}"><a href="https://blog.csdn.net/DroidPhone" target="_blank"><h5 class="oneline" title="DroidPhone">DroidPhone</h5></a></span>  <p></p><p class="article-num" title="55篇文章"> 55篇文章</p><p class="article-num" title="排名:2000+"> 排名:2000+</p><p></p></div></div></div></div>
				</div>
			</div>
		</div>
	</div>

花了20分钟,给女朋友们写了一个web版群聊程序

11-28 阅读数 23万+

参考博客[1]https://www.byteslounge.com/tutorials/java-ee-html5-websocket-example 博文

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_61" data-pid="61"><iframe src="https://adaccount.csdn.net/#/preview/787?m=iJSLcfEvHDAcSSSopHcEEEUbXvbSnEbHXcpSLAHyAnEmnAyHQEttApJLiWSEEEnLEcELmLSnXpULmEDobEEEUHipiEttcAQiEAbQ&amp;k=" frameborder="0" width="100%" height="75px" scrolling="no"></iframe><img class="pre-img-lasy" data-src="https://kunyu.csdn.net/1.png?d=2&amp;k=&amp;m=iJSLcfEvHDAcSSSopHcEEEUbXvbSnEbHXcpSLAHyAnEmnAyHQEttApJLiWSEEEnLEcELmLSnXpULmEDobEEEUHipiEttcAQiEAbQ"></div></div>

相见恨晚的超实用网站

01-06 阅读数 8万+

相见恨晚的超实用网站持续更新中。。。 博文 来自: 藏冰的博客

linux alsa 音频路径切换

05-14 阅读数 1万+

linux alsa 音频路径切换 博文 来自: xiaojsj111的专栏

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_62" data-pid="62"><iframe src="https://adaccount.csdn.net/#/preview/260?m=cQpSbQHitALEiLcJnDtyEJHpncEpiQLmJSppAcJpSHpXtSASbAipnDHDtXQnSHtiQnWcvSLbEtUSAnvJLbnJmiUcfHpcQSEEtnnQ&amp;k=" frameborder="0" width="100%" height="75px" scrolling="no"></iframe><img class="pre-img-lasy" data-src="https://kunyu.csdn.net/1.png?d=2&amp;k=&amp;m=cQpSbQHitALEiLcJnDtyEJHpncEpiQLmJSppAcJpSHpXtSASbAipnDHDtXQnSHtiQnWcvSLbEtUSAnvJLbnJmiUcfHpcQSEEtnnQ"></div></div>
<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_63" data-pid="63"><script async="async" charset="utf-8" src="https://shared.ydstatic.com/js/yatdk/3.0.1/stream.js" data-id="8935aa488dd58452b9e5ee3b44f1212f" data-div-style="width:100%;" data-tit-style="margin-bottom: 6px; font-size: 18px; line-height: 24px; color: #3d3d3d;display: inline-block;font-weight:bold;" data-des-style="font-size: 13px; line-height: 22px; white-space: normal; color: #999;" data-img-style="float:left;margin-right:15px;width:90px;height:60px;" data-is-handling="1">

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_64" data-pid="64"><script async="async" charset="utf-8" src="https://shared.ydstatic.com/js/yatdk/3.0.1/stream.js" data-id="8935aa488dd58452b9e5ee3b44f1212f" data-div-style="width:100%;" data-tit-style="margin-bottom: 6px; font-size: 18px; line-height: 24px; color: #3d3d3d;display: inline-block;font-weight:bold;" data-des-style="font-size: 13px; line-height: 22px; white-space: normal; color: #999;" data-img-style="float:left;margin-right:15px;width:90px;height:60px;" data-is-handling="1">

nginx学习,看这一篇就够了:下载、安装。使用:正向代理、反向代理、负载均衡。常用命令和配置文件

10-25 阅读数 4万+

文章目录前言一、nginx简介1. 什么是 nginx 和可以做什么事情2.Nginx 作为 web 服务器3. 正向代理4. 反向代理5. 动静分离6.动静分离二、Nginx 的安装三、 Ngin... 博文 来自: 冯安晨

面试官:你连RESTful都不知道我怎么敢要你?

11-06 阅读数 10万+

干货,2019 RESTful最贱实践 博文 来自: dotNet全栈开发

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_65" data-pid="65"><script async="async" charset="utf-8" src="https://shared.ydstatic.com/js/yatdk/3.0.1/stream.js" data-id="8935aa488dd58452b9e5ee3b44f1212f" data-div-style="width:100%;" data-tit-style="margin-bottom: 6px; font-size: 18px; line-height: 24px; color: #3d3d3d;display: inline-block;font-weight:bold;" data-des-style="font-size: 13px; line-height: 22px; white-space: normal; color: #999;" data-img-style="float:left;margin-right:15px;width:90px;height:60px;" data-is-handling="1">

Python 基础(一):入门必备知识

10-30 阅读数 9万+

Python 入门必备知识,你都掌握了吗? 博文 来自: 程序之间

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_66" data-pid="66"><script type="text/javascript">
    (function() {
        var s = "_" + Math.random().toString(36).slice(2);
        document.write('<div style="" id="' + s + '"></div>');
        (window.slotbydup = window.slotbydup || []).push({
            id: "u4623747",
            container: s
        });
    })();

动…


博文



根据我们的经验,程序员兼职主要分为三种:兼职职位众包、项目整包和自由职业者驻场。

所谓的兼职职位众…


博文



<div class="recommend-item-box recommend-recommend-box"><div style="width: 100%;"><iframe width="962" frameborder="0" height="52" scrolling="no" src="//pos.baidu.com/s?hei=52&amp;wid=962&amp;di=u3491668&amp;ltu=https%3A%2F%2Fblog.csdn.net%2Fzyuanyun%2Farticle%2Fdetails%2F59180272&amp;psi=d30d5658233dfdd482bfdceb3896f6bb&amp;pis=-1x-1&amp;cec=UTF-8&amp;dtm=HTML_POST&amp;tpr=1580381291260&amp;tcn=1580381291&amp;psr=1366x768&amp;col=zh-CN&amp;pcs=1349x635&amp;par=1366x728&amp;ti=Linux%20ALSA%20%E9%9F%B3%E9%A2%91%E7%B3%BB%E7%BB%9F%EF%BC%9A%E9%80%BB%E8%BE%91%E8%AE%BE%E5%A4%87%E7%AF%87&amp;exps=111000,110011&amp;dis=0&amp;ari=2&amp;pss=1349x26259&amp;dc=3&amp;ant=0&amp;cdo=-1&amp;cja=false&amp;cce=true&amp;ccd=24&amp;ltr=https%3A%2F%2Fblog.csdn.net%2Fzyuanyun%3Ft%3D1&amp;prot=2&amp;dai=3&amp;drs=1&amp;cfv=0&amp;tlm=1580381291&amp;cmi=47&amp;cpl=27&amp;chi=1&amp;dri=1&amp;ps=23356x380"></iframe></div><script type="text/javascript" src="//rabc1.iteye.com/production/res/rxjg.js?pkcgstj=jm"></script></div>

rank
pl_
percentage

1
jav…


博文



目录

第一部分 基础知识

一、HelloWorld与命名空间

二、引用和引用参数

2…


博文



<div class="recommend-item-box recommend-recommend-box"><div id="_f1squ7ipibw" style=""><iframe width="962" frameborder="0" height="52" scrolling="no" src="https://pos.baidu.com/s?hei=52&amp;wid=962&amp;di=u3491668&amp;ltu=https%3A%2F%2Fblog.csdn.net%2Fzyuanyun%2Farticle%2Fdetails%2F59180272&amp;psi=d30d5658233dfdd482bfdceb3896f6bb&amp;pss=1349x26317&amp;ltr=https%3A%2F%2Fblog.csdn.net%2Fzyuanyun%3Ft%3D1&amp;prot=2&amp;pcs=1349x635&amp;cja=false&amp;cdo=-1&amp;exps=111000,110011&amp;tlm=1580381291&amp;cce=true&amp;ti=Linux%20ALSA%20%E9%9F%B3%E9%A2%91%E7%B3%BB%E7%BB%9F%EF%BC%9A%E9%80%BB%E8%BE%91%E8%AE%BE%E5%A4%87%E7%AF%87&amp;ant=0&amp;dri=2&amp;dc=3&amp;cec=UTF-8&amp;cmi=47&amp;dis=0&amp;cpl=27&amp;tpr=1580381291260&amp;par=1366x728&amp;psr=1366x768&amp;tcn=1580381291&amp;ps=23824x380&amp;ari=2&amp;pis=-1x-1&amp;drs=1&amp;chi=1&amp;cfv=0&amp;ccd=24&amp;dai=4&amp;col=zh-CN&amp;dtm=HTML_POST"></iframe></div><script type="text/javascript" src="//rabc1.iteye.com/production/res/rxjg.js?pkcgstj=jm"></script></div>

本阶段介绍HBase 是一个分布…


博文



刷了几千道算法题,这些我私藏的刷题网站都在这里了!

11-08 阅读数 7万+

遥想当年,机缘巧合入了 ACM 的坑,周边巨擘林立,从此过上了"天天被虐似死狗"的生活…

然而我是谁,我可是死狗中的战斗鸡,智力不够那刷题来凑,开始了夜以继日哼哧哼哧刷题的日子,从此"读题与提交…


博文



YouTube排名第一的励志英文演讲《Dream(梦想)》

11-12 阅读数 4万+

Idon’t know what that dream is that you have, I don't care how disappointing it might have been as y... 博文

《C++ Primer》学习笔记(五):循环、分支、跳转和异常处理语句

11-18 阅读数 2599

专栏C++学习笔记 《C++ Primer》学习笔记/习题答案 总目录

https://blog.csdn.net/TeFuirnever/article/details/100700212

——…


博文



“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作

11-13 阅读数 13万+

一、垃圾文字生成器介绍

最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。

项目中文名:狗屁不通文章生成器
项目英文名:BullshitGenerator
根据作…


博文



前言
这一期不算《吊打…


博文



区块链技术被认为是继蒸汽机、…


博文



程序员把地府后台管理系统做出来了,还有3.0版本!12月7号最新消息:已在开发中有github地址

11-17 阅读数 17万+

第一幕:缘起

听说阎王爷要做个生死簿后台管理系统,我们派去了一个程序员……

996程序员做的梦:

第一场:团队招募

为了应对地府管理危机,阎王打算找“人”开发一套地府后台管理系统,于是…


博文



本次分享重点介绍 AI 算法在音乐推荐中的应用实践,以及在算法…


博文



大学生活这样过,校招 offer 飞来找

11-19 阅读数 1万+

本篇我们来聊聊大学生活如何度过,才能在校招中拿到 offer。 博文

小白都能看得懂的java虚拟机内存模型

11-26 阅读数 3万+

目录

一、虚拟机

二、虚拟机组成

1.栈

栈帧

2.程序计数器

3.方法区

对象组成

4.本地方法栈

5.堆

GC

GC案例

一、虚拟机

同样的java代码在不…


博文



8年经验面试官详解 Java 面试秘诀

11-19 阅读数 9万+

作者 |胡书敏

责编 | 刘静

出品 | CSDN(ID:CSDNnews)

本人目前在一家知名外企担任架构师,而且最近八年来,在多家外企和互联网公司担任Java技术面试官,前后累计面试了有两三…


博文



腾讯“疯狂”开源!

11-20 阅读数 3万+

作者 | 马超

责编 | 胡巍巍

出品 | CSDN(ID:CSDNnews)

近日,腾讯自研的万亿级分布式消息中间件TubeMQ正式开源,并捐赠给Apache基金会,成为基金会官方认可的Inc…


博文



so easy! 10行代码写个"狗屁不通"文章生成器

11-20 阅读数 8万+

前几天,GitHub 有个开源项目特别火,只要输入标题就可以生成一篇长长的文章。

背后实现代码一定很复杂吧,里面一定有很多高深莫测的机器学习等复杂算法

不过,当我看了源代码之后…


博文



MySQL数据库总结

11-25 阅读数 7万+

一、数据库简介

数据库(Database,DB)是按照数据结构来组织,存储和管理数据的仓库。
典型特征:数据的结构化、数据间的共享、减少数据的冗余度,数据的独立性。
关系型数据库:使用关系模型把数据…


博文



张小龙-年薪近3亿的微信之父,他是如何做到的?

11-22 阅读数 10万+

张小龙生于湖南邵东魏家桥镇,

家庭主要特点:穷。

不仅自己穷,亲戚也都很穷,可以说穷以类聚。爷爷做过铜匠,总的来说,标准的劳动阶级出身。

家有兄弟两人,

一个小龙,一个小虎。

小虎好动,与邻…


博文



                <div class="recommend-item-box type_hot_word">
                <div class="content clearfix" style="width: 852px;">
                    <div class="float-left">
                                                                            <span>
                            <a href="https://blog.csdn.net/yilovexing/article/details/80577510" target="_blank">
                            python</a>
                        </span>
                                                    <span>
                            <a href="https://blog.csdn.net/slwbcsdn/article/details/53458352" target="_blank">
                            json</a>
                        </span>
                                                    <span>
                            <a href="https://blog.csdn.net/csdnnews/article/details/83753246" target="_blank">
                            java</a>
                        </span>
                                                    <span>
                            <a href="https://blog.csdn.net/qq_35077512/article/details/88952519" target="_blank">
                            mysql</a>
                        </span>
                                                    <span>
                            <a href="https://blog.csdn.net/pdcfighting/article/details/80297499" target="_blank">
                            pycharm</a>
                        </span>
                                                    <span>
                            <a href="https://blog.csdn.net/sinyu890807/article/details/97142065" target="_blank">
                            android</a>
                        </span>
                                                    <span>
                            <a href="https://blog.csdn.net/gexiaoyizhimei/article/details/100122368" target="_blank">
                            linux</a>
                        </span>
                                                    <span>
                            <a href="https://download.csdn.net/download/xhg_gszs/10978826" target="_blank">
                            json格式</a>
                        </span>
                                                
                                                                            <span>
                            <a href="https://www.csdn.net/gather_10/OtTakg2sLWRvd25sb2Fk.html" target="_blank">
                            c#交错数组</a>
                        </span>
                                                    <span>
                            <a href="https://www.csdn.net/gather_1e/OtTakg3sLWRvd25sb2Fk.html" target="_blank">
                            c# task停止</a>
                        </span>
                                                    <span>
                            <a href="https://www.csdn.net/gather_19/OtTakg4sLWRvd25sb2Fk.html" target="_blank">
                            c#使用mongodb</a>
                        </span>
                                                    <span>
                            <a href="https://www.csdn.net/gather_1b/OtTakg5sLWRvd25sb2Fk.html" target="_blank">
                            c#入门经典第七版</a>
                        </span>
                                                    <span>
                            <a href="https://www.csdn.net/gather_1a/MtTaAgwsMC1kb3dubG9hZAO0O0OO0O0O.html" target="_blank">
                            c#设置超时程序</a>
                        </span>
                                                    <span>
                            <a href="https://www.csdn.net/gather_1b/MtTaAgwsMS1kb3dubG9hZAO0O0OO0O0O.html" target="_blank">
                            c#一个日期格式加上时分</a>
                        </span>
                                                    <span>
                            <a href="https://www.csdn.net/gather_1f/MtTaAgwsMi1kb3dubG9hZAO0O0OO0O0O.html" target="_blank">
                            c# 按行读取excel</a>
                        </span>
                                                    <span>
                            <a href="https://www.csdn.net/gather_1a/MtTaAgwsMy1kb3dubG9hZAO0O0OO0O0O.html" target="_blank">
                            c#画图固定</a>
                        </span>
                                                    <span>
                            <a href="https://www.csdn.net/gather_1f/MtTaAgwsNC1kb3dubG9hZAO0O0OO0O0O.html" target="_blank">
                            c# 读取dataset</a>
                        </span>
                                                    <span>
                            <a href="https://www.csdn.net/gather_22/MtTaAgwsNS1ibG9n.html" target="_blank">
                            如何c#按钮透明</a>
                        </span>
                                                                        </div>
                </div>
                </div>
                                <div class="recommend-loading-box">
                <img src="https://csdnimg.cn/release/phoenix/images/feedLoading.gif">
            </div>
            <div class="recommend-end-box" style="display: block;">
                <p class="text-center">没有更多推荐了,<a href="https://blog.csdn.net/" class="c-blue c-blue-hover c-blue-focus">返回首页</a></p>
            </div>
        </div>
                        <div class="template-box">
                <span>©️2019 CSDN</span><span class="point"></span>
            <span>皮肤主题: 深蓝海洋</span>
            <span> 设计师:
                                        CSDN官方博客                                    </span>
            </div>
                </main>
相关推荐
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页