chiark / gitweb /
hash.c tests
[disorder] / lib / plugin.h
1 /*
2  * This file is part of DisOrder.
3  * Copyright (C) 2004, 2005, 2006 Richard Kettlewell
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA
19  */
20
21 #ifndef PLUGIN_H
22 #define PLUGIN_H
23
24 /* general ********************************************************************/
25
26 struct plugin;
27
28 typedef void *plugin_handle;
29 typedef void function_t(void);
30
31 const struct plugin *open_plugin(const char *name,
32                                  unsigned flags);
33 #define PLUGIN_FATAL 0x0001             /* fatal() on error */
34 /* Open a plugin.  Returns a null pointer on error or a handle to it
35  * on success. */
36
37 function_t *get_plugin_function(const struct plugin *handle,
38                                 const char *symbol);
39 const void *get_plugin_object(const struct plugin *handle,
40                               const char *symbol);
41 /* Look up a function or an object in a plugin */
42
43 /* track length computation ***************************************************/
44
45 long tracklength(const char *plugin, const char *track, const char *path);
46
47 /* collection interface *******************************************************/
48
49 void scan(const char *module, const char *root);
50 /* write a list of path names below @root@ to standard output. */
51   
52 int check(const char *module, const char *root, const char *path);
53 /* Recheck a track, given its root and path name.  Return 1 if it
54  * exists, 0 if it does not exist and -1 if an error occurred. */
55
56 /* notification interface *****************************************************/
57
58 void notify_play(const char *track,
59                  const char *submitter);
60 /* we're going to play @track@.  It was submitted by @submitter@
61  * (might be a null pointer) */
62
63 void notify_scratch(const char *track,
64                     const char *submitter,
65                     const char *scratcher,
66                     int seconds);
67 /* @scratcher@ scratched @track@ after @seconds@.  It was submitted by
68  * @submitter@ (might be a null pointer) */
69
70 void notify_not_scratched(const char *track,
71                           const char *submitter);
72 /* @track@ (submitted by @submitter@, which might be a null pointer)
73  * was not scratched. */
74
75 void notify_queue(const char *track,
76                   const char *submitter);
77 /* @track@ was queued by @submitter@ */
78
79 void notify_queue_remove(const char *track,
80                          const char *remover);
81 /* @track@ removed from the queue by @remover@ (never a null pointer) */
82
83 void notify_queue_move(const char *track,
84                        const char *mover);
85 /* @track@ moved in the queue by @mover@ (never a null pointer) */
86
87 void notify_pause(const char *track,
88                   const char *pauser);
89 /* TRACK was paused by PAUSER (might be a null pointer) */
90
91 void notify_resume(const char *track,
92                    const char *resumer);
93 /* TRACK was resumed by PAUSER (might be a null pointer) */
94
95 /* track playing **************************************************************/
96
97 unsigned long play_get_type(const struct plugin *pl);
98 /* Get the type word for this plugin */
99
100 void *play_prefork(const struct plugin *pl,
101                    const char *track);
102 /* Call the prefork function for PL and return the user data */
103
104 void play_track(const struct plugin *pl,
105                 const char *const *parameters,
106                 int nparameters,
107                 const char *path,
108                 const char *track);
109 /* play a track.  Called inside a fork. */
110
111 void play_cleanup(const struct plugin *pl, void *data);
112 /* Call the cleanup function for PL if necessary */
113
114 int play_pause(const struct plugin *pl, long *playedp, void *data);
115 /* Pause track. */
116
117 void play_resume(const struct plugin *pl, void *data);
118 /* Resume track. */
119
120 #endif /* PLUGIN_H */
121
122 /*
123 Local Variables:
124 c-basic-offset:2
125 comment-column:40
126 End:
127 */