Linux??mono????PCM???
???????????? ???????[ 2015/3/9 14:43:40 ] ????????Linux ?????? mono
?????????????
????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
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11