audiod: Don't unregister tasks, just set the error value.
[paraslash.git] / recv.h
1 /*
2  * Copyright (C) 2005-2008 Andre Noll <maan@systemlinux.org>
3  *
4  * Licensed under the GPL v2. For licencing details see COPYING.
5  */
6
7 /** \file recv.h receiver-related structures and exported symbols of recv_common.c */
8
9 /**
10  * describes one instance of a receiver
11  */
12 struct receiver_node {
13         /** points to the corresponding receiver */
14         struct receiver *receiver;
15         /** the output buffer */
16         char *buf;
17         /** the amount of bytes in \a buf */
18         size_t loaded;
19         /** receiver-specific data */
20         void *private_data;
21         /** Pointer to the error member of the consumer. */
22         int *output_error;
23         /** pointer to the configuration data for this instance */
24         void *conf;
25         /** the task associated with this instance */
26         struct task task;
27 };
28
29 /**
30  * describes one supported paraslash receiver
31  *
32  * \sa http_recv.c, ortp_recv.c
33  */
34 struct receiver {
35 /**
36  * the name of the receiver
37  */
38         const char *name;
39 /**
40  * the receiver init function
41  *
42  * It must fill in all other function pointers and is assumed to succeed.
43  *
44  * \sa http_recv_init ortp_recv_init
45  */
46         void (*init)(struct receiver *r);
47 /**
48  * the command line parser of the receiver
49  *
50  * It should check whether the command line options given by \a argc and \a
51  * argv are valid.  On success, it should return a pointer to the
52  * receiver-specific configuration data determined by \a argc and \a argv.
53  * Note that this might be called more than once with different values of
54  * \a argc and \a argv.
55  */
56         void * (*parse_config)(int argc, char **argv);
57 /**
58  * open one instance of the receiver
59  *
60  * This should allocate the output buffer of \a rn. and may also perform any
61  * other work necessary for retrieving the stream according to the
62  * configuration stored in the \a conf member of \a rn which is guaranteed to
63  * point to valid configuration data (as previously obtained from the config
64  * parser).
65  *
66  * \sa receiver_node::conf, receiver_node::buf
67  */
68         int (*open)(struct receiver_node *rn);
69 /**
70  * close this instance of the receiver
71  *
72  * It should free all resources associated with given receiver node that were
73  * allocated during the corresponding open call.
74  *
75  * \sa receiver_node
76  */
77         void (*close)(struct receiver_node *rn);
78 /**
79  * deactivate the receiver
80  *
81  * Clean up what init has allocated.
82  */
83         void (*shutdown)(void);
84 /**
85  * add file descriptors to fd_sets and compute timeout for select(2)
86  *
87  * The pre_select function gets called from the driving application before
88  * entering its select loop. The receiver may use this hook to add any file
89  * descriptors to the sets of file descriptors given by \a s.
90  *
91  * \sa select(2), time.c struct task, struct sched
92  */
93         void (*pre_select)(struct sched *s, struct task *t);
94 /**
95  * evaluate the result from select()
96  *
97  * This hook gets called after the call to select(). It should check all file
98  * descriptors which were added to any of the the fd sets during the previous
99  * call to pre_select. According to the result, it may then use any
100  * non-blocking I/O to establish a connection or to receive the audio data.
101  *
102  * \sa select(2), struct receiver
103  */
104         void (*post_select)(struct sched *s, struct task *t);
105 };
106
107
108 /** \cond */
109 extern void http_recv_init(struct receiver *r);
110 #define HTTP_RECEIVER {.name = "http", .init = http_recv_init},
111 extern void dccp_recv_init(struct receiver *r);
112 #define DCCP_RECEIVER {.name = "dccp", .init = dccp_recv_init},
113
114 #ifdef HAVE_ORTP
115 extern void ortp_recv_init(struct receiver *r);
116 #define ORTP_RECEIVER {.name = "ortp", .init = ortp_recv_init},
117 #else
118 #define ORTP_RECEIVER
119 #endif
120
121 extern struct receiver receivers[];
122 /** \endcond */
123
124 /** define an array of all available receivers */
125 #define DEFINE_RECEIVER_ARRAY struct receiver receivers[] = { \
126         HTTP_RECEIVER \
127         DCCP_RECEIVER \
128         ORTP_RECEIVER \
129         {.name = NULL}};
130
131 void *check_receiver_arg(char *ra, int *receiver_num);