Make the status item list globally visible.
[paraslash.git] / audiod.h
1 /*
2 * Copyright (C) 2006-2007 Andre Noll <maan@systemlinux.org>
3 *
4 * Licensed under the GPL v2. For licencing details see COPYING.
5 */
6
7 /** \file audiod.h symbols exported from audiod.c */
8
9
10 int num_filters(int audio_format_num);
11 int get_audio_format_num(char *name);
12
13 /** enum of audio formats supported by para_audiod */
14 enum {AUDIOD_AUDIO_FORMATS_ENUM};
15
16 /** array of audio format names supported by para_audiod */
17 extern const char *audio_formats[];
18
19 /** maximal number of simultaneous instances */
20 #define MAX_STREAM_SLOTS 5
21
22 /**
23 * the possible modes of operation
24 *
25 * - off: disconnect from para_server
26 * - on: receive status information from para_server and play the audio stream
27 * - sb: only receive status information but not the audio stream
28 */
29 enum audiod_status_info {AUDIOD_OFF, AUDIOD_ON, AUDIOD_STANDBY};
30
31 /** defines one command of para_audiod */
32 struct audiod_command {
33 /** the name of the command */
34 const char *name;
35 /** pointer to the function that handles the command */
36 int (*handler)(int, int, char**);
37 /**
38 * if the command prefers to handle the full line (rather than the usual
39 * argv[] array), it stores a pointer to the corresponding line handling
40 * function here. In this case, the above \a handler pointer must be NULL.
41 */
42 int (*line_handler)(int, char*);
43 /** one-line description of the command */
44 const char *description;
45 /** summary of the command line options */
46 const char *usage;
47 /** the long help text */
48 const char *help;
49 };
50
51 /**
52 * describes one instance of a receiver-filter-writer chain
53 *
54 * \sa receiver_node, receiver, filter, filter_node, filter_chain, writer,
55 * writer_node, writer_node_group.
56 */
57 struct slot_info {
58 /** number of the audio format in this slot */
59 int format;
60 /** writer start time */
61 struct timeval wstime;
62 /** the receiver info associated with this slot */
63 struct receiver_node *receiver_node;
64 /** the active filter chain */
65 struct filter_chain *fc;
66 /** the active writer node group */
67 struct writer_node_group *wng;
68 };
69
70 /**
71 * the task for obtaining para_server's status (para_client stat)
72 *
73 * \sa struct task, struct sched
74 */
75 struct status_task {
76 /** the associated task structure of audiod */
77 struct task task;
78 /** client data associated with the stat task */
79 struct private_client_data *pcd;
80 /** the array of status items sent by para_server */
81 char *stat_item_values[NUM_STAT_ITEMS];
82 /** do not restart client command until this time */
83 struct timeval restart_barrier;
84 /** last time we received status data from para_server */
85 struct timeval last_status_read;
86 /** the offset value announced by para_server */
87 int offset_seconds;
88 /** the length of the current audio file as announced by para_server */
89 int length_seconds;
90 /** the start of the current stream from the view of para_server */
91 struct timeval server_stream_start;
92 /** the average time deviation between para_server and para_audiod */
93 struct timeval sa_time_diff;
94 /** whether client time is ahead of server time */
95 int sa_time_diff_sign;
96 /** non-zero if para_server's status is "playing" */
97 int playing;
98 /** number of times the clock difference is to be checked */
99 unsigned clock_diff_count;
100 /** when to start the next check for clock difference */
101 struct timeval clock_diff_barrier;
102 };
103
104 extern struct status_task *stat_task;
105 extern struct slot_info slot[MAX_STREAM_SLOTS];
106 extern struct audiod_args_info conf;
107 extern int audiod_status;
108
109 void __noreturn clean_exit(int status, const char *msg);
110 int handle_connect(int accept_fd);
111 void audiod_status_dump(void);
112 void dump_empty_status(void);
113
114 /** iterate over all slots */
115 #define FOR_EACH_SLOT(_slot) for (_slot = 0; _slot < MAX_STREAM_SLOTS; _slot++)