
ALSA 샘플 소스 코드를 다운로드했습니다(https://gist.github.com/ghedo/963382) 퍼티 창에서 테스트를 실행하면 작동합니다. 그러나 "sudo" 유무에 관계없이 시작 스크립트(예: rc.local)에 넣으면 충돌이 발생합니다.
참고: 애플리케이션은 전원을 켠 후 자동 실행된 후에만 충돌합니다. 퍼티(명령줄)에서 스크립트를 실행하면 문제가 없습니다.
각 snd_xxx 함수 호출 전에 로깅을 추가한 후 snd_pcm_hw_params_any 호출 후 애플리케이션이 중지되는 것을 발견했습니다. 즉, snd_pcm_open 및 snd_pcm_hw_params_alloca 이후 충돌이 발생함을 의미합니다. 다음은 코드입니다:
g_pLog->LogInfo(LOG_SYS, "[audio]snd_pcm_open"); /////logged
if ((pcm = snd_pcm_open(&pcm_handle, acDev, /////PCM_DEVICE, acDev="default:0"
SND_PCM_STREAM_PLAYBACK, 0)) < 0)
{
sprintf(acLog, "[audio]Can't open \"%s\" PCM device. %s\n", acDev, snd_strerror(pcm));
g_pLog->LogInfo(LOG_SYS, acLog);
return -1;
}
g_pLog->LogInfo(LOG_SYS, "[audio]snd_pcm_hw_params_alloca"); /////logged
/* Allocate parameters object and fill it with default values*/
snd_pcm_hw_params_alloca(¶ms);
g_pLog->LogInfo(LOG_SYS, "[audio]snd_pcm_hw_params_any"); /////logged and is the last line
snd_pcm_hw_params_any(pcm_handle, params);
g_pLog->LogInfo(LOG_SYS, "[audio]snd_pcm_hw_params_set_access");
/* Set parameters */
if (pcm = snd_pcm_hw_params_set_access(pcm_handle, params,
SND_PCM_ACCESS_RW_INTERLEAVED) < 0)
...
코어 덤프 파일을 수집하고 gdb "bt full"을 사용하여 확인한 후 결과는 다음과 같습니다.
root@linaro-ubuntu-desktop:/test# gdb ./AudioPlayer /opt/core.AudioPlayer.6277.1604311455.6
GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabi".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /test/AudioPlayer...(no debugging symbols found)...done.
[New LWP 6277]
[Thread debugging using libthread_db enabled]
Core was generated by `/test/AudioPlayer'.
Program terminated with signal 6, Aborted.
#0 0x2ad8bed6 in ?? () from /lib/arm-linux-gnueabi/libc.so.6
(gdb) bt full
#0 0x2ad8bed6 in ?? () from /lib/arm-linux-gnueabi/libc.so.6
No symbol table info available.
#1 0x2ad9a0da in raise () from /lib/arm-linux-gnueabi/libc.so.6
No symbol table info available.
#2 0x2ad9c506 in abort () from /lib/arm-linux-gnueabi/libc.so.6
No symbol table info available.
#3 0x2ad951ec in __assert_fail () from /lib/arm-linux-gnueabi/libc.so.6
No symbol table info available.
#4 0x2ac6cb72 in snd_pcm_hw_refine () from /usr/lib/arm-linux-gnueabi/libasound.so.2
No symbol table info available.
#5 0x0000aca8 in main ()
No symbol table info available.
참고 "snd_pcm_hw_refine"은 응용 프로그램에서 직접 호출되지 않습니다.
Putty에서 실행하는 것과 전원을 켠 시작 스크립트에서 실행하는 것의 차이점과 이 오류를 해결하는 방법이 궁금합니다. 조언해주시면 감사하겠습니다...