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_status_info {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 task for obtaining para_server's status (para_client stat)
85 * \sa struct task, struct sched
88 /** the associated task structure of audiod */
90 /** client data associated with the stat task */
91 struct private_client_data *pcd;
92 /** the array of status items sent by para_server */
93 char *stat_item_values[NUM_STAT_ITEMS];
94 /** do not restart client command until this time */
95 struct timeval restart_barrier;
96 /** last time we received status data from para_server */
97 struct timeval last_status_read;
98 /** the offset value announced by para_server */
100 /** the length of the current audio file as announced by para_server */
102 /** the start of the current stream from the view of para_server */
103 struct timeval server_stream_start;
104 /** the average time deviation between para_server and para_audiod */
105 struct timeval sa_time_diff;
106 /** whether client time is ahead of server time */
107 int sa_time_diff_sign;
108 /** non-zero if para_server's status is "playing" */
110 /** number of times the clock difference is to be checked */
111 unsigned clock_diff_count;
112 /** when to start the next check for clock difference */
113 struct timeval clock_diff_barrier;
116 extern struct status_task *stat_task;
117 extern struct slot_info slot[MAX_STREAM_SLOTS];
118 extern struct audiod_args_info conf;
119 extern int audiod_status;
120 extern const char *status_item_list[NUM_STAT_ITEMS];
122 void __noreturn clean_exit(int status, const char *msg);
123 int handle_connect(int accept_fd);
124 void audiod_status_dump(void);
125 void dump_empty_status(void);
127 /** iterate over all slots */
128 #define FOR_EACH_SLOT(_slot) for (_slot = 0; _slot < MAX_STREAM_SLOTS; _slot++)