1 /* the Music Player Daemon (MPD)
2 * Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com)
3 * This project's homepage is: http://www.musicpd.org
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.
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 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "inputPlugin.h"
22 #include "myfprintf.h"
27 static List
*inputPlugin_list
;
29 void loadInputPlugin(InputPlugin
* inputPlugin
)
33 if (!inputPlugin
->name
)
36 if (inputPlugin
->initFunc
&& inputPlugin
->initFunc() < 0)
39 insertInList(inputPlugin_list
, inputPlugin
->name
, (void *)inputPlugin
);
42 void unloadInputPlugin(InputPlugin
* inputPlugin
)
44 if (inputPlugin
->finishFunc
)
45 inputPlugin
->finishFunc();
46 deleteFromList(inputPlugin_list
, inputPlugin
->name
);
49 static int stringFoundInStringArray(char **array
, char *suffix
)
51 while (array
&& *array
) {
52 if (strcasecmp(*array
, suffix
) == 0)
60 InputPlugin
*getInputPluginFromSuffix(char *suffix
, unsigned int next
)
75 node
= inputPlugin_list
->firstNode
;
77 while (node
!= NULL
) {
79 if (stringFoundInStringArray(plugin
->suffixes
, suffix
)) {
83 node
= node
->nextNode
;
89 InputPlugin
*getInputPluginFromMimeType(char *mimeType
, unsigned int next
)
98 node
= (next
&& pos
) ? pos
: inputPlugin_list
->firstNode
;
100 while (node
!= NULL
) {
102 if (stringFoundInStringArray(plugin
->mimeTypes
, mimeType
)) {
103 pos
= node
->nextNode
;
106 node
= node
->nextNode
;
112 InputPlugin
*getInputPluginFromName(char *name
)
116 findInList(inputPlugin_list
, name
, &plugin
);
118 return (InputPlugin
*) plugin
;
121 void printAllInputPluginSuffixes(FILE * fp
)
123 ListNode
*node
= inputPlugin_list
->firstNode
;
128 plugin
= (InputPlugin
*) node
->data
;
129 suffixes
= plugin
->suffixes
;
130 while (suffixes
&& *suffixes
) {
131 fprintf(fp
, "%s ", *suffixes
);
134 node
= node
->nextNode
;
140 void initInputPlugins(void)
142 inputPlugin_list
= makeList(NULL
, 1);
144 /* load plugins here */
145 loadInputPlugin(&mp3Plugin
);
146 loadInputPlugin(&oggvorbisPlugin
);
147 loadInputPlugin(&oggflacPlugin
);
148 loadInputPlugin(&flacPlugin
);
149 loadInputPlugin(&audiofilePlugin
);
150 loadInputPlugin(&mp4Plugin
);
151 loadInputPlugin(&aacPlugin
);
152 loadInputPlugin(&mpcPlugin
);
153 loadInputPlugin(&wavpackPlugin
);
154 loadInputPlugin(&modPlugin
);
157 void finishInputPlugins(void)
159 freeList(inputPlugin_list
);