ALSA on Raspbian
Posted: Thu May 31, 2012 4:32 pm
Has anyone managed to get ALSA working? I've installed Shairport but can't get it to output anything through the headphone jack.
A small, affordable computer with free resources to help people learn, make things, and have fun
https://www.raspberrypi.org/forums/
https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=7107
Code: Select all
drewharris@drew-rpi:/opt/vc/src/hello_pi/hello_audio$ sudo make
cc -DSTANDALONE -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -D_LINUX -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -Wall -g -DHAVE_LIBOPENMAX=2 -DOMX -DOMX_SKIP64BIT -ftree-vectorize -pipe -DUSE_EXTERNAL_OMX -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DUSE_VCHIQ_ARM -Wno-psabi -I/opt/vc/include/ -I/opt/vc/include/ -I./ -I../libs -g -c audio.c -o audio.o -Wno-deprecated-declarations
cc -DSTANDALONE -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -D_LINUX -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -Wall -g -DHAVE_LIBOPENMAX=2 -DOMX -DOMX_SKIP64BIT -ftree-vectorize -pipe -DUSE_EXTERNAL_OMX -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DUSE_VCHIQ_ARM -Wno-psabi -I/opt/vc/include/ -I/opt/vc/include/ -I./ -I../libs -g -c sinewave.c -o sinewave.o -Wno-deprecated-declarations
cc -o hello_audio.bin -Wl,--whole-archive -L/opt/vc/lib/ -lGLESv2 -lEGL -lopenmaxil -lbcm_host -lvcos -lvchiq_arm ../libs/libilclient.a audio.o sinewave.o -Wl,--no-whole-archive -rdynamic
audio.o: In function `audioplay_create':
/opt/vc/src/hello_pi/hello_audio/audio.c:69: multiple definition of `audioplay_create'
../libs/libilclient.a(audioplay.c.o):audioplay.c:(.text+0x4): first defined here
audio.o: In function `audioplay_delete':
/opt/vc/src/hello_pi/hello_audio/audio.c:202: multiple definition of `audioplay_delete'
../libs/libilclient.a(audioplay.c.o):audioplay.c:(.text+0x34c): first defined here
audio.o: In function `audioplay_get_buffer':
/opt/vc/src/hello_pi/hello_audio/audio.c:226: multiple definition of `audioplay_get_buffer'
../libs/libilclient.a(audioplay.c.o):audioplay.c:(.text+0x3e0): first defined here
audio.o: In function `audioplay_play_buffer':
/opt/vc/src/hello_pi/hello_audio/audio.c:248: multiple definition of `audioplay_play_buffer'
../libs/libilclient.a(audioplay.c.o):audioplay.c:(.text+0x444): first defined here
audio.o: In function `audioplay_get_latency':
/opt/vc/src/hello_pi/hello_audio/audio.c:314: multiple definition of `audioplay_get_latency'
../libs/libilclient.a(audioplay.c.o):audioplay.c:(.text+0x54c): first defined here
collect2: ld returned 1 exit status
make: *** [hello_audio.bin] Error 1
rm sinewave.o audio.o
Code: Select all
Playing /mnt/server/Music/Keane/Hopes and Fears/01 Somewhere Only We Know.mp3.
libavformat version 53.21.0 (external)
Mismatching header version 53.19.0
Audio only file format detected.
Clip info:
Title: Somewhere Only We Know
Artist: Keane
Album: Hopes And Fears
Year: 2004
Comment: Created by Grip
Track: 1
Genre: Indie
Load subtitles in /mnt/server/Music/Keane/Hopes and Fears/
==========================================================================
Requested audio codec family [mpg123] (afm=mpg123) not available.
Enable it at compilation.
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
libavcodec version 53.35.0 (external)
Mismatching header version 53.32.2
AUDIO: 44100 Hz, 2 ch, floatle, 128.0 kbit/4.54% (ratio: 16001->352800)
Selected audio codec: [ffmp3float] afm: ffmpeg (FFmpeg MPEG layer-3 audio)
==========================================================================
AO: [pulse] Init failed: Connection refused
Failed to initialize audio driver 'pulse'
[AO_ALSA] Unable to set hw-parameters: Invalid argument
Failed to initialize audio driver 'alsa'
[AO SDL] Samplerate: 44100Hz Channels: Stereo Format floatle
[AO SDL] using aalib audio driver.
[AO SDL] Unsupported audio format: 0x1d.
[AO SDL] Unable to open audio: No available audio device
Failed to initialize audio driver 'sdl:aalib'
Could not open/initialize audio device -> no sound.
Audio: no sound
Video: no video
Exiting... (End of file)
Code: Select all
[0x14b9f38] alsa audio output error: cannot commit hardware parameters: Invalid argument
[0x14b9f38] pulse audio output error: PulseAudio server connection failure: Connection refused
[0x14b9f38] oss audio output error: cannot open audio device (/dev/dsp)
[0x14b9f38] main audio output error: no suitable audio output module
[0x43f00a08] main decoder error: failed to create audio output
Code: Select all
mplayer -srate 48000 FILE
Yes works for me, thanks.kadamski wrote:The problem seems to be resolved by using -srate 48000 mplayer parameter. ...
It shouldn't be needed, alsa driver should select this automaticaly. I will debug this some more.
Code: Select all
mplayer -ao alsa:device=hw FILE
Code: Select all
pcm.!default {
type hw
card 0
}
ctl.!default {
type hw
card 0
}
Code: Select all
type plug
slave.pcm {
type hw
card $CARD
}
Please, do continue to post what you find. I really haven't had time to play around with sound on my Raspberry Pi, but I will eventually. Having notes in these forums as to what problems people encountered and how they worked around them will definitely be a big help to me. I hope that much of the information in these forums, such as getting ALSA to work, will eventually be edited and find their way onto the Wiki. However, in the meantime this forum is the best place to keep track of issues and their solutions.kadamski wrote:I don't know if anybody is still interested but I have some more informations.
Code: Select all
pcm.float {
type lfloat
slave {
pcm "plughw:0,0"
format S16_LE
}
}
Code: Select all
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4170:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4170:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4170:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4649:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2190:(snd_pcm_open_noupdate) Unknown PCM default
aplay: main:654: audio open error: No such file or directory
Code: Select all
root@piplayer:/music# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: Interface [Schiit USB Interface], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Interface [Schiit USB Interface], device 1: USB Audio [USB Audio #1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Interface [Schiit USB Interface], device 2: USB Audio [USB Audio #2]
Subdevices: 1/1
Subdevice #0: subdevice #0
Code: Select all
root@piplayer:/music# aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
default:CARD=Interface
Schiit USB Interface, USB Audio
Default Audio Device
front:CARD=Interface,DEV=0
Schiit USB Interface, USB Audio
Front speakers
surround40:CARD=Interface,DEV=0
Schiit USB Interface, USB Audio
4.0 Surround output to Front and Rear speakers
surround41:CARD=Interface,DEV=0
Schiit USB Interface, USB Audio
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Interface,DEV=0
Schiit USB Interface, USB Audio
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Interface,DEV=0
Schiit USB Interface, USB Audio
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Interface,DEV=0
Schiit USB Interface, USB Audio
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Interface,DEV=0
Schiit USB Interface, USB Audio
IEC958 (S/PDIF) Digital Audio Output
Code: Select all
aplay - D hw:1,0 FILE.WAV
This is quite odd. When I originally tried the above, it worked just fine. Then I tried using MPD to play the file and all I got was garbage for sound. In fact, the system usage was so high, I lost my SSH connection. I was able to get SSH back after the system finished playing the sound file.kadamski wrote:Please try using aplay like this:Code: Select all
aplay - D hw:1,0 FILE.WAV