-
Notifications
You must be signed in to change notification settings - Fork 4
/
voice_bb.c
54 lines (45 loc) · 1.03 KB
/
voice_bb.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <tinyalsa/asoundlib.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
struct pcm_config pcm_config_vx = {
.channels = 2,
.rate = 16000,
.period_size = 160,
.period_count = 2,
.format = PCM_FORMAT_S16_LE,
};
struct pcm *pcm_modem_dl = NULL; //down stream
struct pcm *pcm_modem_ul = NULL; //up stream
#define CARD_DEFAULT 0
#define PORT_MODEM 1
#define PORT_BT 2
static int start_call()
{
pcm_modem_dl = pcm_open(CARD_DEFAULT, PORT_MODEM, PCM_OUT, &pcm_config_vx);
if (!pcm_is_ready(pcm_modem_dl)) {
printf("cannot open PCM modem DL stream\n");
return -1;
}
pcm_modem_ul = pcm_open(CARD_DEFAULT, PORT_MODEM, PCM_IN, &pcm_config_vx);
if (!pcm_is_ready(pcm_modem_ul)) {
printf("cannot open PCM modem UP stream\n");
return -1;
}
pcm_start(pcm_modem_dl);
pcm_start(pcm_modem_ul);
}
static int end_call()
{
pcm_stop(pcm_modem_dl);
pcm_stop(pcm_modem_ul);
pcm_close(pcm_modem_dl);
pcm_close(pcm_modem_ul);
}
int main(void)
{
start_call();
sleep(10);
end_call();
}