doc: compile tutorial programs

The programs in `doc/examples` are not compiled currently, so let's
compile them if the `docs` and `examples` options don't disallow it.

`tutorial4.c` needs a small modification to avoid `-Wfloat-conversion`.

Additionally, install them if `installed_tests` is not disabled.
This commit is contained in:
Barnabás Pőcze 2026-05-06 23:41:10 +02:00 committed by Wim Taymans
parent b5d294eab0
commit 8caea521d7
3 changed files with 31 additions and 12 deletions

View file

@ -56,7 +56,7 @@ static void on_process(void *userdata)
* Another common method to convert a double to
* 16 bits is to multiple by 32768.0 and then clamp to
* [-32768 32767] to get the full 16 bits range. */
val = sin(data->accumulator) * DEFAULT_VOLUME * 32767.0;
val = (int16_t) (sin(data->accumulator) * DEFAULT_VOLUME * 32767.0);
for (c = 0; c < DEFAULT_CHANNELS; c++)
*dst++ = val;
}