gui: Combine open_stat_pipe() and para_open_stat_pipe().
[paraslash.git] / audiod.h
1 /*
2 * Copyright (C) 2006-2010 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(const 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 /** one-line description of the command */
38 const char *description;
39 /** summary of the command line options */
40 const char *usage;
41 /** the long help text */
42 const char *help;
43 };
44
45 /**
46 * Describes one instance of a receiver-filter-writer chain.
47 *
48 * \sa receiver_node, receiver, filter, filter_node, writer, writer_node,
49 * writer_node_group.
50 */
51 struct slot_info {
52 /** Number of the audio format in this slot. */
53 int format;
54 /** The stream_start status item announced by para_server. */
55 struct timeval server_stream_start;
56 /** The offset status item announced by para_server. */
57 unsigned offset_seconds;
58 /** The seconds_total status item announced by para_server. */
59 unsigned seconds_total;
60 /** The receiver info associated with this slot. */
61 struct receiver_node *receiver_node;
62 /** The array of filter nodes. */
63 struct filter_node *fns;
64 /** The array of writers attached to the last filter. */
65 struct writer_node *wns;
66 };
67
68 extern struct slot_info slot[MAX_STREAM_SLOTS];
69 extern struct audiod_args_info conf;
70 extern int audiod_status;
71
72 void __noreturn clean_exit(int status, const char *msg);
73 int handle_connect(int accept_fd, fd_set *rfds);
74 void audiod_status_dump(void);
75 char *get_time_string(int slot_num);
76 struct btr_node *audiod_get_btr_root(void);
77
78 void stat_client_write_item(int item_num);
79 void clear_and_dump_items(void);
80
81 /** iterate over all slots */
82 #define FOR_EACH_SLOT(_slot) for (_slot = 0; _slot < MAX_STREAM_SLOTS; _slot++)