• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# lws minimal raw audio
2
3This demonstrates operating ALSA playback and capture using the lws event loop
4via raw file descriptors.
5
6You need the lws cmake option `-DLWS_WITH_ALSA=1`
7
8This example opens the default ALSA playback and capture devices and pipes the
9capture data into the playback with something over 1s delay via a ringbuffer.
10
11ALSA doesn't really lend itself to direct use with event loops... this example
12uses the capture channel which does create POLLIN normally as the timesource
13for the playback as well; they're both set to 16000Hz sample rate.
14
15## build
16
17```
18 $ cmake . && make
19```
20
21## usage
22
23```
24 $ ./lws-minimal-raw-audio
25[2019/10/14 18:58:49:3288] U: LWS minimal raw audio
26[2019/10/14 18:58:50:3438] N: LWS_CALLBACK_RAW_ADOPT_FILE
27[2019/10/14 18:58:50:3455] N: LWS_CALLBACK_RAW_ADOPT_FILE
28[2019/10/14 18:58:50:4764] N: LWS_CALLBACK_RAW_RX_FILE: 2062 samples
29[2019/10/14 18:58:50:6132] N: LWS_CALLBACK_RAW_RX_FILE: 2205 samples
30[2019/10/14 18:58:50:7592] N: LWS_CALLBACK_RAW_RX_FILE: 2328 samples
31...
32^C[2019/10/14 18:58:56:8460] N: LWS_CALLBACK_RAW_CLOSE_FILE
33[2019/10/14 18:58:56:8461] N: LWS_CALLBACK_RAW_CLOSE_FILE
34[2019/10/14 18:58:56:8461] N: LWS_CALLBACK_PROTOCOL_DESTROY
35$
36
37```
38