]> git.ipfire.org Git - thirdparty/shairport-sync.git/blame - audio.h
Stability improvements -- take more care when the fifi is full, fix a logical error...
[thirdparty/shairport-sync.git] / audio.h
CommitLineData
a2fb5d21
JL
1#ifndef _AUDIO_H
2#define _AUDIO_H
3
9cfc6179 4#include <libconfig.h>
064bd293 5#include <stdint.h>
459cdd94 6
fd880056
MB
7// clang-format off
8// Play samples provided may be from the source, in which case they will be timed
9// or they may be generated by Shairport Sync, in which case they will not be timed.
10
11// Typically these would be samples of silence, which may be dithered, sent during the lead-in to
12// the start of the material, or inserted instead of a missing frame, or after a flush.
13// clang-format on
14
15typedef enum {
16 play_samples_are_untimed = 0, // typically the samples are (possibly dithered) silence
17 play_samples_are_timed, // timed and numbered.
18} play_samples_type;
19
a2790fc1 20typedef struct {
a2790fc1 21 double current_volume_dB;
4c70223f
MB
22 int32_t minimum_volume_dB;
23 int32_t maximum_volume_dB;
a2790fc1
MB
24} audio_parameters;
25
a2fb5d21 26typedef struct {
87a0475c
MB
27 void (*help)(void);
28 char *name;
29
30 // start of program
31 int (*init)(int argc, char **argv);
32 // at end of program
33 void (*deinit)(void);
c8b0be30 34
83c0405d 35 int (*prepare)(void); // looks and sets stuff in the config data structure
87a0475c 36
01e51285 37 void (*start)(int sample_rate, int sample_format);
87a0475c
MB
38
39 // block of samples
fd880056 40 int (*play)(void *buf, int samples, int sample_type, uint32_t timestamp, uint64_t playtime);
87a0475c 41 void (*stop)(void);
1b18f45f 42
8cabb16f 43 // may be null if no implemented
1b18f45f
MB
44 int (*is_running)(
45 void); // if implemented, will return 0 if everything is okay, non-zero otherwise
87a0475c
MB
46
47 // may be null if not implemented
48 void (*flush)(void);
49
50 // returns the delay before the next frame to be sent to the device would actually be audible.
51 // almost certainly wrong if the buffer is empty, so put silent buffers into it to make it busy.
52 // will change dynamically, so keep watching it. Implemented in ALSA only.
1e408d1b 53 // returns a negative error code if there's a problem
064bd293 54 int (*delay)(long *the_delay); // snd_pcm_sframes_t is a signed long
56bef8e7
MB
55 int (*stats)(uint64_t *raw_measurement_time, uint64_t *corrected_measurement_time,
56 uint64_t *delay,
14bfba27 57 uint64_t *frames_sent_to_dac); // use this to get the true rate of the DAC
87a0475c
MB
58
59 // may be NULL, in which case soft volume is applied
60 void (*volume)(double vol);
61
62 // may be NULL, in which case soft volume parameters are used
63 void (*parameters)(audio_parameters *info);
064bd293 64
4c70223f 65 // may be NULL, in which case software muting is used.
c5ff0dfe
MB
66 // also, will return a 1 if it is actually using the mute facility, 0 otherwise
67 int (*mute)(int do_mute);
064bd293 68
9b33878c 69} audio_output;
a2fb5d21 70
ca562872 71audio_output *audio_get_output(const char *name);
9b33878c 72void audio_ls_outputs(void);
b7864b4e 73void parse_general_audio_options(void);
a2fb5d21
JL
74
75#endif //_AUDIO_H