Raw ↗
+ +
2da5fe7 OpenAVX v0.2.0 - High-performance open-standard IP audio and video transport suite
saifmukhtar · 2026-11-24
1 /*
2 * SPDX-License-Identifier: AGPL-3.0-or-later WITH Classpath-exception-2.0
3 * Copyright (c) 2026 Saif Mukhtar
4 *
5 * OpenAVX - Open Audio-Video eXchange
6 * tools/avx_audio_output.h - Audio playback backend interface
7 */
8  
9 #ifndef AVX_AUDIO_OUTPUT_H
10 #define AVX_AUDIO_OUTPUT_H
11  
12 #include <stdint.h>
13 #include <stdbool.h>
14 #include <stddef.h>
15 #include "openavx.h"
16  
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20  
21 typedef enum avx_audio_backend_e {
22 AVX_AUDIO_BACKEND_AUTO = 0,
23 AVX_AUDIO_BACKEND_PULSE,
24 AVX_AUDIO_BACKEND_ALSA,
25 AVX_AUDIO_BACKEND_PIPE,
26 AVX_AUDIO_BACKEND_NONE
27 } avx_audio_backend_e;
28  
29 typedef struct avx_audio_output_t avx_audio_output_t;
30  
31 /**
32 * Creates an audio output sink for the given backend, sample rate, and channels.
33 * Passing NULL or "auto" selects the best available backend (Pulse -> ALSA -> Pipe -> None).
34 */
35 avx_audio_output_t* avx_audio_output_create(const char* backend_name, int sample_rate, int channels);
36  
37 /**
38 * Writes an audio frame to the active audio device/stream.
39 * Automatically handles planar-to-interleaved float conversion.
40 */
41 bool avx_audio_output_write(avx_audio_output_t* ao, const oavx_audio_frame_t* aframe);
42  
43 /**
44 * Returns the name of the active audio backend.
45 */
46 const char* avx_audio_output_get_backend_name(const avx_audio_output_t* ao);
47  
48 /**
49 * Closes the audio output device and frees resources.
50 */
51 void avx_audio_output_destroy(avx_audio_output_t* ao);
52  
53 #ifdef __cplusplus
54 }
55 #endif
56  
57 #endif /* AVX_AUDIO_OUTPUT_H */