OrangePiLibra / OrangePi_H5SDK

The Liunx SDK of OrangePi for Allwinner H5
47 stars 24 forks source link

ALSA error! #5

Closed BuddyZhang1 closed 7 years ago

BuddyZhang1 commented 7 years ago

When I use alsa tools to record sound on OPI PC2, but 'arecord' doesn't work with some errors. System output error information after using "arecord" arecord -d 5 -f cd -t wav sound.wav Normally, we should be wait 5's and get wav file "sound.wav", but this command costs 25's with some error.

root@Orangepi:~# arecord -d 5 -f cd -t wav sound.wav Recording WAVE 'sound.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo arecord: pcm_read:2031: read error: Input/output error

The system information of sound card:

root@Orangepi:~# arecord -l List of CAPTURE Hardware Devices card 0: audiocodec [audiocodec], device 0: SUNXI-CODEC sun50iw2codec-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0

more information about sound card:

root@Orangepi:~# cat /proc/asound/cards 0 [audiocodec ]: audiocodec - audiocodec audiocodec 1 [sndhdmi ]: sndhdmi - sndhdmi sndhdmi

root@Orangepi:~# cat /proc/asound/cards 0 [audiocodec ]: audiocodec - audiocodec audiocodec 1 [sndhdmi ]: sndhdmi - sndhdmi sndhdmi root@Orangepi:~# amixer Simple mixer control 'Lineout volume',0 Capabilities: volume volume-joined Playback channels: Mono Capture channels: Mono Limits: 0 - 31 Mono: 31 [100%] Simple mixer control 'Lineout_L Mux',0 Capabilities: enum Items: 'MIXER_L Switch' 'MIXER_R+MIXER_L Switch' Item0: 'MIXER_L Switch' Simple mixer control 'Lineout_R Mux',0 Capabilities: enum Items: 'MIXER_R Switch' 'MIXER_L Switch' Item0: 'MIXER_R Switch' Simple mixer control 'ADC input gain control',0 Capabilities: volume volume-joined Playback channels: Mono Capture channels: Mono Limits: 0 - 7 Mono: 3 [43%] Simple mixer control 'External Speaker',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [on] Simple mixer control 'LADC input Mixer LINEINL',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'LADC input Mixer MIC1 boost',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'LADC input Mixer MIC2 boost',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'LADC input Mixer l_output mixer',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'LADC input Mixer r_output mixer',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'LINEINL/R to L_R output mixer gain',0 Capabilities: volume volume-joined Playback channels: Mono Capture channels: Mono Limits: 0 - 7 Mono: 3 [43%] Simple mixer control 'Left Output Mixer DACL',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'Left Output Mixer DACR',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'Left Output Mixer LINEINL',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'Left Output Mixer MIC1Booststage',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'Left Output Mixer MIC2Booststage',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'MIC1 boost AMP gain control',0 Capabilities: volume volume-joined Playback channels: Mono Capture channels: Mono Limits: 0 - 7 Mono: 4 [57%] Simple mixer control 'MIC1_G boost stage output mixer control',0 Capabilities: volume volume-joined Playback channels: Mono Capture channels: Mono Limits: 0 - 7 Mono: 3 [43%] Simple mixer control 'MIC2 boost AMP gain control',0 Capabilities: volume volume-joined Playback channels: Mono Capture channels: Mono Limits: 0 - 7 Mono: 4 [57%] Simple mixer control 'MIC2_G boost stage output mixer control',0 Capabilities: volume volume-joined Playback channels: Mono Capture channels: Mono Limits: 0 - 7 Mono: 3 [43%] Simple mixer control 'RADC input Mixer LINEINR',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'RADC input Mixer MIC1 boost',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'RADC input Mixer MIC2 boost',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'RADC input Mixer l_output mixer',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'RADC input Mixer r_output mixer',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'Right Output Mixer DACL',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'Right Output Mixer DACR',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'Right Output Mixer LINEINR',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'Right Output Mixer MIC1Booststage',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'Right Output Mixer MIC2Booststage',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [off] Simple mixer control 'codec hub mode',0 Capabilities: enum Items: 'null' 'hub_disable' 'hub_enable' Item0: 'hub_disable' Simple mixer control 'digital volume',0 Capabilities: volume volume-joined Playback channels: Mono Capture channels: Mono Limits: 0 - 63 Mono: 31 [49%]

BuddyZhang1 commented 7 years ago

Just I reboot my board and run "aplay -l", system can't find soundcard!! I use xfce4 desktop.

orangepi@Orangepi:~$ aplay -l aplay: device_list:268: no soundcards found...

So, fix way: chmod -R a+rwX /dev/snd

orangepi@Orangepi:~$ aplay -l \ List of PLAYBACK Hardware Devices ** card 0: audiocodec [audiocodec], device 0: SUNXI-CODEC sun50iw2codec-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: sndhdmi [sndhdmi], device 0: SUNXI-HDMIAUDIO sndhdmi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0

BuddyZhang1 commented 7 years ago

Now, I found the user can't get sound card information and root user can get sound card. as follow: user: aplay -l

orangepi@Orangepi:/dev/snd$ aplay -l aplay: device_list:268: no soundcards found...

root: aplay -l

root@Orangepi:/dev/snd# aplay -l List of PLAYBACK Hardware Devices card 0: audiocodec [audiocodec], device 0: SUNXI-CODEC sun50iw2codec-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: sndhdmi [sndhdmi], device 0: SUNXI-HDMIAUDIO sndhdmi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0

For this issue, there are different copyright on /dev/snd, so we should set correct configure for /dev/snd, like chown orangepi:orangepi /dev/snd -R

The issue has solved, it can be closed.

BuddyZhang1 commented 7 years ago

ALSA can' record and play audio For original system, ALSA library has been exited, we only need correctly configure alsa.

Use this patch to set OP PC2 ALSA configure. Patch: https://github.com/OrangePiLibra/OrangePi_H5SDK/commit/494adcca90cd5992c33157c59f6cb67a7aabde56