diff options
| author | Namilskyy <alive6863@gmail.com> | 2025-10-29 00:17:37 +0300 |
|---|---|---|
| committer | Namilskyy <alive6863@gmail.com> | 2025-10-29 00:18:11 +0300 |
| commit | 6833ea062f264ff35773f23f6f68b293b4cfec34 (patch) | |
| tree | 94729c4364bc1a304e295b31cae89dca0b845832 /src/non_critical/random_sounds.c | |
| parent | d7c64d28e1bb3a9e8f563704128593da80b9f0a7 (diff) | |
Implemented some not critical functions.
Diffstat (limited to 'src/non_critical/random_sounds.c')
| -rw-r--r-- | src/non_critical/random_sounds.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/non_critical/random_sounds.c b/src/non_critical/random_sounds.c new file mode 100644 index 0000000..315c992 --- /dev/null +++ b/src/non_critical/random_sounds.c @@ -0,0 +1,34 @@ +#include <alsa/asoundlib.h> +#include <stdint.h> +#include <stdlib.h> +#include <pthread.h> + +#define MAX_THREADS 5 + +pthread_t THRS[MAX_THREADS]; + +static void* audio_hell() { + snd_pcm_t *pcm_handle; + snd_pcm_open(&pcm_handle, "default", SND_PCM_STREAM_PLAYBACK, 0); + + int16_t buffer[4410]; + for(int i = 0; i < 4410; i++) { + buffer[i] = rand() % 65536 - 32768; + } + + while(1) { + snd_pcm_writei(pcm_handle, buffer, 4410); + } +} + +int init(int threads, int time) { + for(int i = 0; i < MAX_THREADS; i++) { + pthread_create(&THRS[i], NULL, audio_hell, NULL); + } +} + +void stop() { + for(int i = 0; i < MAX_THREADS; i++) { + pthread_cancel(THRS[i]); + } +}
\ No newline at end of file |
