]> git.ipfire.org Git - thirdparty/shairport-sync.git/blob - audio.h
Initial very rough attempt at a jackaudio backend.
[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 int (*play)(void *buf, int samples);
26 void (*stop)(void);
27
28 // may be null if no implemented
29 int (*is_running)(void); // if implemented, will return 0 if everything is okay, non-zero otherwise
30
31 // may be null if not implemented
32 void (*flush)(void);
33
34 // returns the delay before the next frame to be sent to the device would actually be audible.
35 // almost certainly wrong if the buffer is empty, so put silent buffers into it to make it busy.
36 // will change dynamically, so keep watching it. Implemented in ALSA only.
37 // returns a negative error code if there's a problem
38 int (*delay)(long *the_delay); // snd_pcm_sframes_t is a signed long
39 int (*rate_info)(uint64_t *elapsed_time,
40 uint64_t *frames_played); // use this to get the true rate of the DAC
41
42 // may be NULL, in which case soft volume is applied
43 void (*volume)(double vol);
44
45 // may be NULL, in which case soft volume parameters are used
46 void (*parameters)(audio_parameters *info);
47
48 // may be NULL, in which case software muting is used.
49 void (*mute)(int do_mute);
50
51 } audio_output;
52
53 audio_output *audio_get_output(char *name);
54 void audio_ls_outputs(void);
55 void parse_general_audio_options(void);
56
57 #endif //_AUDIO_H