2 * Copyright (C) 2006-2007 Andre Noll <maan@systemlinux.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
19 /** \file audiod.h symbols exported from audiod.c */
22 int num_filters(int audio_format_num);
23 int get_audio_format_num(char *name);
25 /** enum of audio formats supported by para_audiod */
26 enum {AUDIOD_AUDIO_FORMATS_ENUM};
28 /** array of audio format names supported by para_audiod */
29 extern const char *audio_formats[];
31 /** maximal number of simultaneous instances */
32 #define MAX_STREAM_SLOTS 5
35 * the possible modes of operation
37 * - off: disconnect from para_server
38 * - on: receive status information from para_server and play the audio stream
39 * - sb: only receive status information but not the audio stream
41 enum {AUDIOD_OFF, AUDIOD_ON, AUDIOD_STANDBY};
43 /** defines one command of para_audiod */
44 struct audiod_command {
45 /** the name of the command */
47 /** pointer to the function that handles the command */
48 int (*handler)(int, int, char**);
50 * if the command prefers to handle the full line (rather than the usual
51 * argv[] array), it stores a pointer to the corresponding line handling
52 * function here. In this case, the above \a handler pointer must be NULL.
54 int (*line_handler)(int, char*);
55 /** one-line description of the command */
56 const char *description;
57 /** summary of the command line options */
59 /** the long help text */
64 * describes one instance of a receiver-filter-writer chain
66 * \sa receier_node, receiver, filter, filter_node, filter_chain, writer,
67 * writer_node, writer_node_group.
70 /** number of the audio format in this slot */
72 /** writer start time */
73 struct timeval wstime;
74 /** the receiver info associated with this slot */
75 struct receiver_node *receiver_node;
76 /** the active filter chain */
77 struct filter_chain *fc;
78 /** the active writer node group */
79 struct writer_node_group *wng;
83 * the main task of audiod
85 * \sa struct task, struct sched
93 * the task for obtaining para_server's status (para_client stat)
95 * \sa struct task, struct sched
98 /** the associated task structure of audiod */
100 /** client data associated with the stat task */
101 struct private_client_data *pcd;
102 /** the array of status items sent by para_server */
103 char *stat_item_values[NUM_STAT_ITEMS];
104 /** do not restart client command until this time */
105 struct timeval restart_barrier;
106 /** last time we received status data from para_server */
107 struct timeval last_status_read;
108 /** the offset value announced by para_server */
110 /** the length of the current audio file as announced by para_server */
112 /** the start of the current stream from the view of para_server */
113 struct timeval server_stream_start;
114 /** the average time deviation between para_server and para_audiod */
115 struct timeval sa_time_diff;
116 /** whether client time is ahead of server time */
117 int sa_time_diff_sign;
118 /** non-zero if para_server's status is "playing" */
120 /** number of times the clock difference is to be checked */
121 unsigned clock_diff_count;
122 /** when to start the next check for clock difference */
123 struct timeval clock_diff_barrier;
126 extern struct status_task *stat_task;
127 extern struct slot_info slot[MAX_STREAM_SLOTS];
128 extern struct audiod_args_info conf;
129 extern int audiod_status;
130 extern const char *status_item_list[NUM_STAT_ITEMS];
132 void __noreturn clean_exit(int status, const char *msg);
133 int handle_connect(int accept_fd);
134 void audiod_status_dump(void);
135 void dump_empty_status(void);
137 /** iterate over all slots */
138 #define FOR_EACH_SLOT(_slot) for (_slot = 0; _slot < MAX_STREAM_SLOTS; _slot++)