Linux aplay 命令中的混乱。

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8922044/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 04:08:04  来源:igfitidea点击:

Confusion in aplay Command.

linuxbluetoothdbusalsa

提问by user1089679

Here i want to understand this commmand.

在这里我想了解这个命令。

aplay -D hw:0,0 /opt/WL1271_demo_01/gallery/Pop.wav

Why we used asound.conffile.

为什么我们使用asound.conf文件。

we have to need update bluetooth address of hands free device in this file to play audio in handsfree device?

我们必须在此文件中更新免提设备的蓝牙地址才能在免提设备中播放音频吗?

Can anybody Explain me aplaycommand and how its works?

任何人都可以解释我的aplay命令及其工作原理吗?

why we used here -D hw:0,0in this?

为什么我们在这里-D hw:0,0用这个?

why we not used here -Dplug:bluetooth hw:0,0?

为什么我们这里不使用-Dplug:bluetooth hw:0,0

==================================================================

================================================== ================

Here is my /etc/asound.conf file

这是我的 /etc/asound.conf 文件

    pcm.!bluetooth {
    type bluetooth
    device 00:23:78:41:AB:9F
        playback_ports {
                0 alsa_pcm:playback_1
                1 alsa_pcm:playback_2
        }
        capture_ports {
                0 alsa_pcm:capture_1
                1 alsa_pcm:capture_2
        }

    }

pcm.!default {
    type plug
    slave.pcm bluetooth
    }


pcm.Hyman {
        type Hyman
        playback_ports {
                0 alsa_pcm:playback_1
                1 alsa_pcm:playback_2
        }
        capture_ports {
                0 alsa_pcm:capture_1
                1 alsa_pcm:capture_2
        }
}

回答by Neox

Looks like you have a problem with your pulse audio setup. Hereis a manual for ubuntu to troubleshoot bluetooth setups including aplay. Hereis the manual for bluetooth setup for ubuntu.

您的脉冲音频设置似乎有问题。是 ubuntu 对包括 aplay 在内的蓝牙设置进行故障排除的手册。是 ubuntu 蓝牙设置的手册。

From your configuration I see that you are missing the device name, namely "aplay -D defaulthw:0,1 -c 2 -f S16_LE abc.wav &". For my headset I have used an example here, and it works for me so far.

从您的配置中,我看到您缺少设备名称,即“aplay -D defaulthw:0,1 -c 2 -f S16_LE abc.wav &”。对于我的耳机,我在这里使用了一个示例,到目前为止它对我有用。

回答by Jacek Konieczny

You are pointing aplaydirectly to some piece of hardware (hw:0,1– second output of the first sound device) instead of letting it use your asound.confdefinition. Try this instead:

aplay直接指向某个硬件(hw:0,1– 第一个声音设备的第二个输出),而不是让它使用您的asound.conf定义。试试这个:

aplay -D bluetooth -c 2 -f S16_LE abc.wav

Please note, that if you are using the ALSA interface this way anything else using that device (e.g. the Pulse Audio daemon) make this not work. You could probably use Pulse Audio instead of 'raw' ALSA, but I cannot help with that.

请注意,如果您以这种方式使用 ALSA 接口,则使用该设备的其他任何东西(例如 Pulse Audio 守护程序)都会使此功能不起作用。您可能可以使用 Pulse Audio 而不是“原始”ALSA,但我对此无能为力。

Update:

更新:

why we used here -D hw:0,0in this?

为什么我们在这里-D hw:0,0用这个?

How can we know? You provided the command. This means: use directly (this means: ignoring the aliases in asound.conffile) the first output of the first audio hardware (this usually means the output of your primary sound card).

我们怎么知道?您提供了命令。这意味着:直接使用(这意味着:忽略asound.conf文件中的别名)第一个音频硬件的第一个输出(这通常意味着您的主声卡的输出)。

why we not used here -Dplug:bluetooth hw:0,0 ?

为什么我们在这里不使用 -Dplug:bluetooth hw:0,0 ?

Because the '-D' option accepts a single parameter. This can be 'hw:0,0', this can be 'plug:bluetooth', this can be any alias defined in the asound.conffile (like 'Hyman' or 'bluetooth' defined in your file), but it must be one parameter. 'plug:bluetooth hw:0,0' would be two parameters.

因为 '-D' 选项接受单个参数。这可以是'hw:0,0',也可以是'plug:bluetooth',这可以是asound.conf文件中定义的任何别名(如文件中定义的'Hyman'或'bluetooth'),但它必须是一个参数. 'plug:bluetooth hw:0,0' 将是两个参数。

Why we used asound.conf file.

为什么我们使用 asound.conf 文件。

  1. Not to have to provide a specific device address directly to each command. You may set the default in asound.confand omit the '-D something' option all toghether
  2. To provide more sophisticated configuration for the audio output
  1. 不必直接为每个命令提供特定的设备地址。您可以设置默认值asound.conf并一起省略“-D something”选项
  2. 为音频输出提供更复杂的配置

http://www.alsa-project.org/main/index.php/Asoundrc#The_naming_of_PCM_devices

http://www.alsa-project.org/main/index.php/Asoundrc#The_naming_of_PCM_devices