1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00
libwebsockets/minimal-examples/raw/minimal-raw-audio
Andy Green b3131fdfdd cmakelist: Augean Stables refactor
Establish a new distributed CMake architecture with CMake code related to
a source directory moving to be in the subdir in its own CMakeLists.txt.
In particular, there's now one in ./lib which calls through to ones
further down the directory tree like ./lib/plat/xxx, ./lib/roles/xxx etc.

This cuts the main CMakelists.txt from 98KB -> 33KB, about a 66% reduction,
and it's much easier to maintain sub-CMakeLists.txt that are in the same
directory as the sources they manage, and conceal all the details that that
level.

Child CMakelists.txt become responsible for:

 - include_directories() definition (this is not supported by CMake
   directly, it passes it back up via PARENT_SCOPE vars in helper
   macros)

 - Addition child CMakeLists.txt inclusion, for example toplevel ->
   role -> role subdir

 - Source file addition to the build

 - Dependent library path resolution... this is now a private thing
   in the child CMakeLists.txt, it just passes back any adaptations
   to include_directories() and the LIB_LIST without filling the
   parent namespace with the details
2020-05-27 08:40:12 +01:00
..
audio.c minimal-raw-audio 2019-10-14 16:46:48 +01:00
CMakeLists.txt cmakelist: Augean Stables refactor 2020-05-27 08:40:12 +01:00
README.md minimal-raw-audio 2019-10-14 16:46:48 +01:00

lws minimal raw audio

This demonstrates operating ALSA playback and capture using the lws event loop via raw file descriptors.

You need the lws cmake option -DLWS_WITH_ALSA=1

This example opens the default ALSA playback and capture devices and pipes the capture data into the playback with something over 1s delay via a ringbuffer.

ALSA doesn't really lend itself to direct use with event loops... this example uses the capture channel which does create POLLIN normally as the timesource for the playback as well; they're both set to 16000Hz sample rate.

build

 $ cmake . && make

usage

 $ ./lws-minimal-raw-audio
[2019/10/14 18:58:49:3288] U: LWS minimal raw audio
[2019/10/14 18:58:50:3438] N: LWS_CALLBACK_RAW_ADOPT_FILE
[2019/10/14 18:58:50:3455] N: LWS_CALLBACK_RAW_ADOPT_FILE
[2019/10/14 18:58:50:4764] N: LWS_CALLBACK_RAW_RX_FILE: 2062 samples
[2019/10/14 18:58:50:6132] N: LWS_CALLBACK_RAW_RX_FILE: 2205 samples
[2019/10/14 18:58:50:7592] N: LWS_CALLBACK_RAW_RX_FILE: 2328 samples
...
^C[2019/10/14 18:58:56:8460] N: LWS_CALLBACK_RAW_CLOSE_FILE
[2019/10/14 18:58:56:8461] N: LWS_CALLBACK_RAW_CLOSE_FILE
[2019/10/14 18:58:56:8461] N: LWS_CALLBACK_PROTOCOL_DESTROY
$