?????????????
????Ubuntu 14
????MonoDevelop
????CodeBlocks
????1??????????????shared library??
?????????????linux?μ?????????alsa-lib?? alsa??linux?μ?????????????????????Advanced Linux Sound Architecture???????????????£?
????sudo apt-get install libasound2-dev
??????? Coceblocks ??????? shared library ??????????libTest2????????????C????main?м????′???
1#include<alsa/asoundlib.h>
2#include<stdio.h>
3
4
5snd_pcm_t*handle;
6snd_pcm_sframes_tframes;
7
8
9intPcmOpen()
10{
11
12if(snd_pcm_open(&handle??"hw:0??0"??SND_PCM_STREAM_PLAYBACK??0)<0)
13{
14printf("pcmopenerror");
15return0;
16}
17
18if(snd_pcm_set_params(handle??SND_PCM_FORMAT_U8??SND_PCM_ACCESS_RW_INTERLEAVED??1??8000??1??500000)<0)//0.5sec500000
19{
20printf("pcmseterror");
21return0;
22}
23
24return1;
25}
26
27
28
29voidPlay(unsignedchar*buffer??intlength)
30{
31frames=snd_pcm_writei(handle??buffer??length);
32if(frames<0)
33{
34frames=snd_pcm_recover(handle??frames??0);
35}
36}
37
38
39
40
41intPcmClose()
42{
43snd_pcm_close(handle);
44return1;
45}
????????????????????alsa-lib?????巽??????codeblocks??????????У????linker settings?????Other linker options??????-lasound??
????????????

?????????????????????cd ??main.c????????????????????
????gcc -o main.o -c main.c
????gcc -o libTest1.so -shared main.o -lasound