audiod: fix enum of supported audio formats
[paraslash.git] / audiod.h
1 /** \file audiod.h symbols exported from audiod.c */
2 int num_filters(int audio_format_num);
3 int get_audio_format_num(char *name);
4
5 /* audio formats supportedby para_audiod */
6 enum { AUDIOD_AUDIO_FORMATS_ENUM};
7
8 extern const char *audio_formats[];
9 #define DEFINE_AUDIO_FORMAT_ARRAY const char *audio_formats[] = {"mp3", "ogg", "aac", NULL}
10 #define MAX_STREAM_SLOTS 5
11 /**
12 * the possible modes of operation
13 *
14 * - off: disconnect from para_server
15 * - on: receive status information from para_server and play the audio stream
16 * - sb: only receive status information but not the audio stream
17 */
18 enum {AUDIOD_OFF, AUDIOD_ON, AUDIOD_STANDBY};
19
20 /**
21 * describes one instance of a receiver-filter-writer chain
22 *
23 * \sa receier_node, receiver, filter, filter_node, filter_chain, writer,
24 * writer_node, writer_node_group.
25 */
26 struct slot_info {
27 /** number of the audio format in this slot */
28 int format;
29 /** writer start time */
30 struct timeval wstime;
31 /** the receiver info associated with this slot */
32 struct receiver_node *receiver_node;
33 /** the active filter chain */
34 struct filter_chain *fc;
35 /** the active writer node group */
36 struct writer_node_group *wng;
37 };
38
39 /**
40 * the main task of audiod
41 *
42 * \sa struct task, struct sched
43 */
44 struct audiod_task {
45 struct timeval *now;
46 struct task task;
47 };
48
49 /**
50 * the task for audiod's child (para_client stat)
51 *
52 * \sa struct task, struct sched
53 */
54 struct status_task {
55 /** the associated task structure of audiod */
56 struct task task;
57 struct private_client_data *pcd;
58 /** the array of status items sent by para_server */
59 char *stat_item_values[NUM_STAT_ITEMS];
60 /** do not restart client command until this time */
61 struct timeval restart_barrier;
62 /** last time we received status data from para_server */
63 struct timeval last_status_read;
64 /** the offset value announced by para_server */
65 int offset_seconds;
66 /** the length of the current audio file as announced by para_server */
67 int length_seconds;
68 /** the start of the current stream from the view of para_server */
69 struct timeval server_stream_start;
70 /** the averaged time deviation between para_server and para_audiod */
71 struct timeval sa_time_diff;
72 /** whether client time is ahead of server time */
73 int sa_time_diff_sign;
74 /** non-zero if \a af_status is "playing" */
75 int playing;
76 };
77
78 extern struct status_task *stat_task;
79 extern struct slot_info slot[MAX_STREAM_SLOTS];
80 extern struct audiod_args_info conf;
81 extern int audiod_status;
82 extern const char *status_item_list[NUM_STAT_ITEMS];
83
84 void __noreturn clean_exit(int status, const char *msg);
85 int handle_connect(int accept_fd);
86 void audiod_status_dump(void);
87 void dump_empty_status(void);
88
89 /** iterate over all slots */
90 #define FOR_EACH_SLOT(_slot) for (_slot = 0; _slot < MAX_STREAM_SLOTS; _slot++)