Hi,
I got video part of my SDL applicatio working fine but facing lots if
issues with audio build and run. The application gives a segmentation fault
in Mix_OpenAudio call.
My environment:
host - linux machine
target - arm-linux
debug tool - gdb
I have done SDL_AUDIODRIVER=“alsa” and AUDIODEV=“hw”
I want SDL to use my ALSA driver which is already running fine with my mp3
decoder and aplay applications. In mySDL_Init, I can see that ALSA is
getting invoked and Audio_CreateDevice in SDL_alsa_audio.c goes through
fine.
To debug this issue, I wanted to build a statically build image but ran
into many issues. First of all I’m not able to generate libasound.a for ALSA
and its giving only libasound.so.2.* even if I change the configure option
to --disable-shared, but this does work fine for SDL, SDL_image and
SDL_mixer libraries. After so many work around like linking libasound from
.a files generated as intermediate files I got it built but only if *sdl
configure option is --enable-alsa-shared * but if add -static to my final
image I get errors like
…/SDL-1.2.13/bin/lib/libSDL.a(SDL_alsa_audio.o): In function
Audio_Available': ./src/audio/alsa/SDL_alsa_audio.c:198: undefined reference to
snd_pcm_open’
./src/audio/alsa/SDL_alsa_audio.c:201: undefined reference to
snd_pcm_close' ../SDL-1.2.13/bin/lib/libSDL.a(SDL_alsa_audio.o): In function
ALSA_PlayAudio’:
./src/audio/alsa/SDL_alsa_audio.c:336: undefined reference to
snd_pcm_writei' ./src/audio/alsa/SDL_alsa_audio.c:345: undefined reference to
snd_pcm_resume’
./src/audio/alsa/SDL_alsa_audio.c:349: undefined reference to
snd_pcm_prepare' ../SDL-1.2.13/bin/lib/libSDL.a(SDL_alsa_audio.o): In function
ALSA_CloseAudio’:
./src/audio/alsa/SDL_alsa_audio.c:378: undefined reference to
snd_pcm_drain' ./src/audio/alsa/SDL_alsa_audio.c:379: undefined reference to
snd_pcm_close’
…/SDL-1.2.13/bin/lib/libSDL.a(SDL_alsa_audio.o): In function
ALSA_OpenAudio': ./src/audio/alsa/SDL_alsa_audio.c:401: undefined reference to
snd_pcm_open’
./src/audio/alsa/SDL_alsa_audio.c:404: undefined reference to snd_strerror' ./src/audio/alsa/SDL_alsa_audio.c:408: undefined reference to
snd_pcm_hw_params_sizeof’
./src/audio/alsa/SDL_alsa_audio.c:408: undefined reference to
snd_pcm_hw_params_sizeof' ./src/audio/alsa/SDL_alsa_audio.c:409: undefined reference to
snd_pcm_hw_params_any’
./src/audio/alsa/SDL_alsa_audio.c:411: undefined reference to snd_strerror' ./src/audio/alsa/SDL_alsa_audio.c:416: undefined reference to
snd_pcm_hw_params_set_access’
./src/audio/alsa/SDL_alsa_audio.c:418: undefined reference to snd_strerror' ./src/audio/alsa/SDL_alsa_audio.c:450: undefined reference to
snd_pcm_hw_params_set_format’
./src/audio/alsa/SDL_alsa_audio.c:466: undefined reference to
snd_pcm_hw_params_set_channels' ./src/audio/alsa/SDL_alsa_audio.c:468: undefined reference to
snd_pcm_hw_params_get_channels at ALSA_0.9’
./src/audio/alsa/SDL_alsa_audio.c:478: undefined reference to
snd_pcm_hw_params_set_rate_near at ALSA_0.9' ./src/audio/alsa/SDL_alsa_audio.c:480: undefined reference to
snd_strerror’
./src/audio/alsa/SDL_alsa_audio.c:490: undefined reference to
snd_pcm_hw_params_set_period_size_near at ALSA_0.9' ./src/audio/alsa/SDL_alsa_audio.c:492: undefined reference to
snd_pcm_hw_params_set_periods_near at ALSA_0.9’
./src/audio/alsa/SDL_alsa_audio.c:495: undefined reference to
snd_pcm_hw_params' ./src/audio/alsa/SDL_alsa_audio.c:497: undefined reference to
snd_strerror’
./src/audio/alsa/SDL_alsa_audio.c:514: undefined reference to
snd_pcm_sw_params_sizeof' ./src/audio/alsa/SDL_alsa_audio.c:514: undefined reference to
snd_pcm_sw_params_sizeof’
./src/audio/alsa/SDL_alsa_audio.c:515: undefined reference to
snd_pcm_sw_params_current' ./src/audio/alsa/SDL_alsa_audio.c:517: undefined reference to
snd_strerror’
./src/audio/alsa/SDL_alsa_audio.c:521: undefined reference to
snd_pcm_sw_params_set_start_threshold' ./src/audio/alsa/SDL_alsa_audio.c:523: undefined reference to
snd_strerror’
./src/audio/alsa/SDL_alsa_audio.c:527: undefined reference to
snd_pcm_sw_params_set_avail_min' ./src/audio/alsa/SDL_alsa_audio.c:529: undefined reference to
snd_strerror’
./src/audio/alsa/SDL_alsa_audio.c:533: undefined reference to
snd_pcm_sw_params' ./src/audio/alsa/SDL_alsa_audio.c:535: undefined reference to
snd_strerror’
./src/audio/alsa/SDL_alsa_audio.c:556: undefined reference to
`snd_pcm_nonblock’
collect2: ld returned 1 exit status
make: *** [bin] Error 1
Whatever I configure options I try I get, I get the following error in
many cases
./src/audio/alsa/SDL_alsa_audio.c:468: undefined reference to
snd_pcm_hw_params_get_channels at ALSA_0.9' ./src/audio/alsa/SDL_alsa_audio.c:478: undefined reference to
snd_pcm_hw_params_set_rate_near at ALSA_0.9’
./src/audio/alsa/SDL_alsa_audio.c:490: undefined reference to
snd_pcm_hw_params_set_period_size_near at ALSA_0.9' ./src/audio/alsa/SDL_alsa_audio.c:492: undefined reference to
snd_pcm_hw_params_set_periods_near at ALSA_0.9’
When I played around with --enable/disable-loadso, --enable-shared-alsa
etc, once when I got the application built I could step in into
ALSA_OpenAudio but it crashes in one the calls to snd_pcm_hw_params_xxx. ANy
issue with dynamic loading ?
I have spent almost a week on this and I’m not able to conclude anything.
Any sort of help will get me out of this trouble
Thanks in advance
Sanu