Mercurial > audlegacy
annotate src/audacious/playlist_container.c @ 3468:440877c9360e trunk
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
the mutex.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 09 Sep 2007 22:05:24 +0300 |
parents | f1c756f39e6c |
children | 1f7c00c1de22 |
rev | line source |
---|---|
2313 | 1 /* |
2 * Audacious: A cross-platform multimedia player | |
3 * Copyright (c) 2006-2007 William Pitcock, Tony Vroon, George Averill, | |
4 * Giacomo Lozito, Derek Pomery and Yoshiki Yazawa. | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2313
diff
changeset
|
8 * the Free Software Foundation; under version 3 of the License. |
2313 | 9 * |
10 * This program is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 * GNU General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU General Public License | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2313
diff
changeset
|
16 * along with this program. If not, see <http://www.gnu.org/licenses>. |
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
17 * |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
18 * The Audacious team does not consider modular code linking to |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
19 * Audacious or using our public API to be a derived work. |
2313 | 20 */ |
21 | |
22 #include <glib.h> | |
23 #include <string.h> | |
24 #include "playlist_container.h" | |
25 | |
26 /* | |
27 * PlaylistContainer objects handle the import and export of Playlist | |
28 * data. Basically, a PlaylistContainer acts as a filter for a PlaylistEntry. | |
29 */ | |
30 | |
31 static GList *registered_plcs = NULL; | |
32 | |
33 void playlist_container_register(PlaylistContainer *plc) | |
34 { | |
35 registered_plcs = g_list_append(registered_plcs, plc); | |
36 } | |
37 | |
38 void playlist_container_unregister(PlaylistContainer *plc) | |
39 { | |
40 registered_plcs = g_list_remove(registered_plcs, plc); | |
41 } | |
42 | |
43 PlaylistContainer *playlist_container_find(char *ext) | |
44 { | |
45 GList *node; | |
46 PlaylistContainer *plc; | |
47 | |
48 /* check ext neither is NULL nor 1 (in a consequence of optimization). */ | |
49 g_return_val_if_fail(ext != NULL && ext != (void *)1, NULL); | |
50 | |
51 for (node = registered_plcs; node != NULL; node = g_list_next(node)) { | |
52 plc = PLAYLIST_CONTAINER(node->data); | |
53 | |
54 if (!g_strcasecmp(plc->ext, ext)) | |
55 return plc; | |
56 } | |
57 | |
58 return NULL; | |
59 } | |
60 | |
61 void playlist_container_read(char *filename, gint pos) | |
62 { | |
63 char *ext = strrchr(filename, '.') + 1; /* optimization: skip past the dot -nenolod */ | |
64 PlaylistContainer *plc = playlist_container_find(ext); | |
65 | |
66 if (plc->plc_read == NULL) | |
67 return; | |
68 | |
69 plc->plc_read(filename, pos); | |
70 } | |
71 | |
72 void playlist_container_write(char *filename, gint pos) | |
73 { | |
74 char *ext = strrchr(filename, '.') + 1; /* optimization: skip past the dot -nenolod */ | |
75 PlaylistContainer *plc = playlist_container_find(ext); | |
76 | |
77 if (plc->plc_write == NULL) | |
78 return; | |
79 | |
80 plc->plc_write(filename, pos); | |
81 } | |
82 | |
83 gboolean is_playlist_name(char *filename) | |
84 { | |
85 char *ext = strrchr(filename, '.') + 1; /* optimization: skip past the dot -nenolod */ | |
86 PlaylistContainer *plc = playlist_container_find(ext); | |
87 | |
88 if (plc != NULL) | |
89 return TRUE; | |
90 | |
91 return FALSE; | |
92 } |