2 * Copyright (C) 2005-2007 Andre Noll <maan@systemlinux.org>
4 * Licensed under the GPL v2. For licencing details see COPYING.
7 /** \file afs_common.h data structures common to all audio file selectors */
9 #include <sys/select.h>
12 int find_audio_files(const char *dirname
, int (*f
)(const char *, const char *));
15 * describes one supported audio file selector
17 * There is one such struct for each supported selector. During the startup
18 * part of para_server the \a init() function of the activated selector gets
19 * called which fills in all other function pointers.
22 struct audio_file_selector
{
24 * name name of this selector
28 * the init routine of the selector
30 * It should check its command line options and do all necessary initialization
31 * like connecting to a database server.
33 * A negative return value indicates an initialization error and means that
34 * this selector should be ignored for now (it may later be activated again via
37 * If \a init() returns success (non-negative return value), it must have
38 * initialized in all non-optional function pointers of the given selector
39 * struct. Moreover, \a cmd_list must point to a NULL-terminated array which
40 * holds the list of all commands that are supported by this selector.
42 int (*init
)(struct audio_file_selector
*self
);
44 * list of commands supported by this selector
46 struct server_command
*cmd_list
;
48 * pointer to function returning list of at most \a num audio files to be
51 * \a get_audio_file_list() must return a pointer to a array of at most \a num
52 * char* pointers (terminated by a NULL pointer), or NULL on errors. Both the
53 * array and its contents must be dynamically allocated and are freed by the
57 char **(*get_audio_file_list
)(unsigned int num
);
62 * The \a update_audio_file pointer is optional and need not be supplied. In this
63 * case it is not necessary to init this pointer from within init(). If
64 * \a update_audio_file is non-NULL, the function it points to gets called
65 * whenever a new audio file was successfully loaded and is going to be
66 * streamed by any of paraslash's senders. The full path of the audio file is
67 * passed \a update_audio_file().
70 void (*update_audio_file
)(char *audio_file
);
73 * shutdown this selector and free all resources
75 * This gets called whenever the audio file selector changes. The reason for
76 * this change might be that some user sent the chs command, that para_server
77 * receives the HUP signal, or that para_server shuts down. It is assumed to
80 void (*shutdown
)(void);
83 * add file descriptors to fd_sets
85 * The pre_select function of the activated selector gets called just before
86 * para_server enters its main select loop. The selector may add its own file
87 * descriptors to the \a rfds or the \a wfds set.
89 * \return The highest-numbered file descriptor which was added to either of
90 * the two fd sets (or -1 if no file descriptors were added).
94 int (*pre_select
)(fd_set
*rfds
, fd_set
*wfds
);
96 * handle the file descriptors which are ready for I/O
98 * If the pre_select hook added one ore more file descriptors to the read or write
99 * set, this is the hook to check the result and do any I/O on those descriptors
100 * which are ready for reading/writing.
102 void (*post_select
)(fd_set
*rfds
, fd_set
*wfds
);
104 * each selector has its private data pointer */
108 int mysql_selector_init(struct audio_file_selector
*);
109 int playlist_selector_init(struct audio_file_selector
*);
110 int random_selector_init(struct audio_file_selector
*);