]> git.ipfire.org Git - thirdparty/shairport-sync.git/blob - audio.h
Merge branch 'master' of https://github.com/mikebrady/shairport-sync
[thirdparty/shairport-sync.git] / audio.h
1 #ifndef _AUDIO_H
2 #define _AUDIO_H
3
4 #include <libconfig.h>
5 #include <stdint.h>
6
7 typedef struct {
8 double current_volume_dB;
9 int32_t minimum_volume_dB;
10 int32_t maximum_volume_dB;
11 } audio_parameters;
12
13 typedef struct {
14 void (*help)(void);
15 char *name;
16
17 // start of program
18 int (*init)(int argc, char **argv);
19 // at end of program
20 void (*deinit)(void);
21
22 void (*start)(int sample_rate, int sample_format);
23
24 // block of samples
25 void (*play)(void *buf, int samples);
26 void (*stop)(void);
27
28 // may be null if not implemented
29 void (*flush)(void);
30
31 // returns the delay before the next frame to be sent to the device would actually be audible.
32 // almost certainly wrong if the buffer is empty, so put silent buffers into it to make it busy.
33 // will change dynamically, so keep watching it. Implemented in ALSA only.
34 // returns a negative error code if there's a problem
35 int (*delay)(long *the_delay); // snd_pcm_sframes_t is a signed long
36
37 // may be NULL, in which case soft volume is applied
38 void (*volume)(double vol);
39
40 // may be NULL, in which case soft volume parameters are used
41 void (*parameters)(audio_parameters *info);
42
43 // may be NULL, in which case software muting is used.
44 void (*mute)(int do_mute);
45
46 } audio_output;
47
48 audio_output *audio_get_output(char *name);
49 void audio_ls_outputs(void);
50 void parse_general_audio_options(void);
51
52 #endif //_AUDIO_H