Commit e41be362 authored by Max Kellermann's avatar Max Kellermann

renamed InputPlugin to struct decoder_plugin

"decoder plugin" is a better name than "input plugin", since the plugin does not actually do the input - InputStream does. Also don't use typedef, so we can forward-declare it if required.
parent cdaa26c8
...@@ -209,7 +209,7 @@ static void decodeStart(void) ...@@ -209,7 +209,7 @@ static void decodeStart(void)
int ret; int ret;
int close_instream = 1; int close_instream = 1;
InputStream inStream; InputStream inStream;
InputPlugin *plugin = NULL; struct decoder_plugin *plugin = NULL;
char path_max_fs[MPD_PATH_MAX]; char path_max_fs[MPD_PATH_MAX];
char path_max_utf8[MPD_PATH_MAX]; char path_max_utf8[MPD_PATH_MAX];
......
...@@ -70,7 +70,7 @@ typedef int (*InputPlugin_fileDecodeFunc) (struct decoder *, ...@@ -70,7 +70,7 @@ typedef int (*InputPlugin_fileDecodeFunc) (struct decoder *,
* or read */ * or read */
typedef MpdTag *(*InputPlugin_tagDupFunc) (char *file); typedef MpdTag *(*InputPlugin_tagDupFunc) (char *file);
typedef struct _InputPlugin { struct decoder_plugin {
const char *name; const char *name;
InputPlugin_initFunc initFunc; InputPlugin_initFunc initFunc;
InputPlugin_finishFunc finishFunc; InputPlugin_finishFunc finishFunc;
...@@ -85,7 +85,7 @@ typedef struct _InputPlugin { ...@@ -85,7 +85,7 @@ typedef struct _InputPlugin {
/* last element in these arrays must always be a NULL: */ /* last element in these arrays must always be a NULL: */
const char *const*suffixes; const char *const*suffixes;
const char *const*mimeTypes; const char *const*mimeTypes;
} InputPlugin; };
/** /**
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "pcm_utils.h" #include "pcm_utils.h"
struct decoder { struct decoder {
InputPlugin *plugin; struct decoder_plugin *plugin;
ConvState conv_state; ConvState conv_state;
}; };
......
...@@ -17,10 +17,11 @@ ...@@ -17,10 +17,11 @@
*/ */
#include "inputPlugin.h" #include "inputPlugin.h"
#include "decoder_api.h"
static List *inputPlugin_list; static List *inputPlugin_list;
void loadInputPlugin(InputPlugin * inputPlugin) void loadInputPlugin(struct decoder_plugin * inputPlugin)
{ {
if (!inputPlugin) if (!inputPlugin)
return; return;
...@@ -33,7 +34,7 @@ void loadInputPlugin(InputPlugin * inputPlugin) ...@@ -33,7 +34,7 @@ void loadInputPlugin(InputPlugin * inputPlugin)
insertInList(inputPlugin_list, inputPlugin->name, (void *)inputPlugin); insertInList(inputPlugin_list, inputPlugin->name, (void *)inputPlugin);
} }
void unloadInputPlugin(InputPlugin * inputPlugin) void unloadInputPlugin(struct decoder_plugin * inputPlugin)
{ {
if (inputPlugin->finishFunc) if (inputPlugin->finishFunc)
inputPlugin->finishFunc(); inputPlugin->finishFunc();
...@@ -51,11 +52,11 @@ static int stringFoundInStringArray(const char *const*array, const char *suffix) ...@@ -51,11 +52,11 @@ static int stringFoundInStringArray(const char *const*array, const char *suffix)
return 0; return 0;
} }
InputPlugin *getInputPluginFromSuffix(const char *suffix, unsigned int next) struct decoder_plugin *getInputPluginFromSuffix(const char *suffix, unsigned int next)
{ {
static ListNode *pos; static ListNode *pos;
ListNode *node; ListNode *node;
InputPlugin *plugin; struct decoder_plugin *plugin;
if (suffix == NULL) if (suffix == NULL)
return NULL; return NULL;
...@@ -80,11 +81,11 @@ InputPlugin *getInputPluginFromSuffix(const char *suffix, unsigned int next) ...@@ -80,11 +81,11 @@ InputPlugin *getInputPluginFromSuffix(const char *suffix, unsigned int next)
return NULL; return NULL;
} }
InputPlugin *getInputPluginFromMimeType(const char *mimeType, unsigned int next) struct decoder_plugin *getInputPluginFromMimeType(const char *mimeType, unsigned int next)
{ {
static ListNode *pos; static ListNode *pos;
ListNode *node; ListNode *node;
InputPlugin *plugin; struct decoder_plugin *plugin;
if (mimeType == NULL) if (mimeType == NULL)
return NULL; return NULL;
...@@ -103,23 +104,23 @@ InputPlugin *getInputPluginFromMimeType(const char *mimeType, unsigned int next) ...@@ -103,23 +104,23 @@ InputPlugin *getInputPluginFromMimeType(const char *mimeType, unsigned int next)
return NULL; return NULL;
} }
InputPlugin *getInputPluginFromName(const char *name) struct decoder_plugin *getInputPluginFromName(const char *name)
{ {
void *plugin = NULL; void *plugin = NULL;
findInList(inputPlugin_list, name, &plugin); findInList(inputPlugin_list, name, &plugin);
return (InputPlugin *) plugin; return (struct decoder_plugin *) plugin;
} }
void printAllInputPluginSuffixes(FILE * fp) void printAllInputPluginSuffixes(FILE * fp)
{ {
ListNode *node = inputPlugin_list->firstNode; ListNode *node = inputPlugin_list->firstNode;
InputPlugin *plugin; struct decoder_plugin *plugin;
const char *const*suffixes; const char *const*suffixes;
while (node) { while (node) {
plugin = (InputPlugin *) node->data; plugin = (struct decoder_plugin *) node->data;
suffixes = plugin->suffixes; suffixes = plugin->suffixes;
while (suffixes && *suffixes) { while (suffixes && *suffixes) {
fprintf(fp, "%s ", *suffixes); fprintf(fp, "%s ", *suffixes);
......
...@@ -19,19 +19,21 @@ ...@@ -19,19 +19,21 @@
#ifndef INPUT_PLUGIN_H #ifndef INPUT_PLUGIN_H
#define INPUT_PLUGIN_H #define INPUT_PLUGIN_H
#include "decoder_api.h" #include "os_compat.h"
struct decoder_plugin;
/* individual functions to load/unload plugins */ /* individual functions to load/unload plugins */
void loadInputPlugin(InputPlugin * inputPlugin); void loadInputPlugin(struct decoder_plugin * inputPlugin);
void unloadInputPlugin(InputPlugin * inputPlugin); void unloadInputPlugin(struct decoder_plugin * inputPlugin);
/* interface for using plugins */ /* interface for using plugins */
InputPlugin *getInputPluginFromSuffix(const char *suffix, unsigned int next); struct decoder_plugin *getInputPluginFromSuffix(const char *suffix, unsigned int next);
InputPlugin *getInputPluginFromMimeType(const char *mimeType, unsigned int next); struct decoder_plugin *getInputPluginFromMimeType(const char *mimeType, unsigned int next);
InputPlugin *getInputPluginFromName(const char *name); struct decoder_plugin *getInputPluginFromName(const char *name);
void printAllInputPluginSuffixes(FILE * fp); void printAllInputPluginSuffixes(FILE * fp);
...@@ -41,15 +43,15 @@ void initInputPlugins(void); ...@@ -41,15 +43,15 @@ void initInputPlugins(void);
/* this is where we "unload" all the "plugins" */ /* this is where we "unload" all the "plugins" */
void finishInputPlugins(void); void finishInputPlugins(void);
extern InputPlugin mp3Plugin; extern struct decoder_plugin mp3Plugin;
extern InputPlugin oggvorbisPlugin; extern struct decoder_plugin oggvorbisPlugin;
extern InputPlugin flacPlugin; extern struct decoder_plugin flacPlugin;
extern InputPlugin oggflacPlugin; extern struct decoder_plugin oggflacPlugin;
extern InputPlugin audiofilePlugin; extern struct decoder_plugin audiofilePlugin;
extern InputPlugin mp4Plugin; extern struct decoder_plugin mp4Plugin;
extern InputPlugin aacPlugin; extern struct decoder_plugin aacPlugin;
extern InputPlugin mpcPlugin; extern struct decoder_plugin mpcPlugin;
extern InputPlugin wavpackPlugin; extern struct decoder_plugin wavpackPlugin;
extern InputPlugin modPlugin; extern struct decoder_plugin modPlugin;
#endif #endif
...@@ -433,7 +433,7 @@ static MpdTag *aacTagDup(char *file) ...@@ -433,7 +433,7 @@ static MpdTag *aacTagDup(char *file)
static const char *aac_suffixes[] = { "aac", NULL }; static const char *aac_suffixes[] = { "aac", NULL };
static const char *aac_mimeTypes[] = { "audio/aac", "audio/aacp", NULL }; static const char *aac_mimeTypes[] = { "audio/aac", "audio/aacp", NULL };
InputPlugin aacPlugin = { struct decoder_plugin aacPlugin = {
"aac", "aac",
NULL, NULL,
NULL, NULL,
...@@ -448,6 +448,6 @@ InputPlugin aacPlugin = { ...@@ -448,6 +448,6 @@ InputPlugin aacPlugin = {
#else #else
InputPlugin aacPlugin; struct decoder_plugin aacPlugin;
#endif /* HAVE_FAAD */ #endif /* HAVE_FAAD */
...@@ -137,7 +137,7 @@ static MpdTag *audiofileTagDup(char *file) ...@@ -137,7 +137,7 @@ static MpdTag *audiofileTagDup(char *file)
static const char *audiofileSuffixes[] = { "wav", "au", "aiff", "aif", NULL }; static const char *audiofileSuffixes[] = { "wav", "au", "aiff", "aif", NULL };
InputPlugin audiofilePlugin = { struct decoder_plugin audiofilePlugin = {
"audiofile", "audiofile",
NULL, NULL,
NULL, NULL,
...@@ -152,6 +152,6 @@ InputPlugin audiofilePlugin = { ...@@ -152,6 +152,6 @@ InputPlugin audiofilePlugin = {
#else #else
InputPlugin audiofilePlugin; struct decoder_plugin audiofilePlugin;
#endif /* HAVE_AUDIOFILE */ #endif /* HAVE_AUDIOFILE */
...@@ -469,7 +469,7 @@ static int flac_decode(struct decoder * decoder, InputStream * inStream) ...@@ -469,7 +469,7 @@ static int flac_decode(struct decoder * decoder, InputStream * inStream)
# define flac_plugin_init NULL # define flac_plugin_init NULL
#else /* FLAC_API_VERSION_CURRENT >= 7 */ #else /* FLAC_API_VERSION_CURRENT >= 7 */
/* some of this stuff is duplicated from oggflac_plugin.c */ /* some of this stuff is duplicated from oggflac_plugin.c */
extern InputPlugin oggflacPlugin; extern struct decoder_plugin oggflacPlugin;
static MpdTag *oggflac_tag_dup(char *file) static MpdTag *oggflac_tag_dup(char *file)
{ {
...@@ -544,7 +544,7 @@ static const char *flac_mime_types[] = { "audio/x-flac", ...@@ -544,7 +544,7 @@ static const char *flac_mime_types[] = { "audio/x-flac",
"application/x-flac", "application/x-flac",
NULL }; NULL };
InputPlugin flacPlugin = { struct decoder_plugin flacPlugin = {
"flac", "flac",
flac_plugin_init, flac_plugin_init,
NULL, NULL,
...@@ -559,6 +559,6 @@ InputPlugin flacPlugin = { ...@@ -559,6 +559,6 @@ InputPlugin flacPlugin = {
#else /* !HAVE_FLAC */ #else /* !HAVE_FLAC */
InputPlugin flacPlugin; struct decoder_plugin flacPlugin;
#endif /* HAVE_FLAC */ #endif /* HAVE_FLAC */
...@@ -262,7 +262,7 @@ static const char *modSuffixes[] = { "amf", ...@@ -262,7 +262,7 @@ static const char *modSuffixes[] = { "amf",
NULL NULL
}; };
InputPlugin modPlugin = { struct decoder_plugin modPlugin = {
"mod", "mod",
NULL, NULL,
mod_finishMikMod, mod_finishMikMod,
...@@ -277,6 +277,6 @@ InputPlugin modPlugin = { ...@@ -277,6 +277,6 @@ InputPlugin modPlugin = {
#else #else
InputPlugin modPlugin; struct decoder_plugin modPlugin;
#endif /* HAVE_MIKMOD */ #endif /* HAVE_MIKMOD */
...@@ -1110,7 +1110,7 @@ static MpdTag *mp3_tagDup(char *file) ...@@ -1110,7 +1110,7 @@ static MpdTag *mp3_tagDup(char *file)
static const char *mp3_suffixes[] = { "mp3", "mp2", NULL }; static const char *mp3_suffixes[] = { "mp3", "mp2", NULL };
static const char *mp3_mimeTypes[] = { "audio/mpeg", NULL }; static const char *mp3_mimeTypes[] = { "audio/mpeg", NULL };
InputPlugin mp3Plugin = { struct decoder_plugin mp3Plugin = {
"mp3", "mp3",
mp3_plugin_init, mp3_plugin_init,
NULL, NULL,
...@@ -1124,6 +1124,6 @@ InputPlugin mp3Plugin = { ...@@ -1124,6 +1124,6 @@ InputPlugin mp3Plugin = {
}; };
#else #else
InputPlugin mp3Plugin; struct decoder_plugin mp3Plugin;
#endif /* HAVE_MAD */ #endif /* HAVE_MAD */
...@@ -408,7 +408,7 @@ static MpdTag *mp4TagDup(char *file) ...@@ -408,7 +408,7 @@ static MpdTag *mp4TagDup(char *file)
static const char *mp4_suffixes[] = { "m4a", "mp4", NULL }; static const char *mp4_suffixes[] = { "m4a", "mp4", NULL };
static const char *mp4_mimeTypes[] = { "audio/mp4", "audio/m4a", NULL }; static const char *mp4_mimeTypes[] = { "audio/mp4", "audio/m4a", NULL };
InputPlugin mp4Plugin = { struct decoder_plugin mp4Plugin = {
"mp4", "mp4",
NULL, NULL,
NULL, NULL,
...@@ -423,6 +423,6 @@ InputPlugin mp4Plugin = { ...@@ -423,6 +423,6 @@ InputPlugin mp4Plugin = {
#else #else
InputPlugin mp4Plugin; struct decoder_plugin mp4Plugin;
#endif /* HAVE_FAAD */ #endif /* HAVE_FAAD */
...@@ -313,7 +313,7 @@ static MpdTag *mpcTagDup(char *file) ...@@ -313,7 +313,7 @@ static MpdTag *mpcTagDup(char *file)
static const char *mpcSuffixes[] = { "mpc", NULL }; static const char *mpcSuffixes[] = { "mpc", NULL };
InputPlugin mpcPlugin = { struct decoder_plugin mpcPlugin = {
"mpc", "mpc",
NULL, NULL,
NULL, NULL,
...@@ -328,6 +328,6 @@ InputPlugin mpcPlugin = { ...@@ -328,6 +328,6 @@ InputPlugin mpcPlugin = {
#else #else
InputPlugin mpcPlugin; struct decoder_plugin mpcPlugin;
#endif /* HAVE_MPCDEC */ #endif /* HAVE_MPCDEC */
...@@ -391,7 +391,7 @@ static const char *oggflac_mime_types[] = { "audio/x-flac+ogg", ...@@ -391,7 +391,7 @@ static const char *oggflac_mime_types[] = { "audio/x-flac+ogg",
"application/x-ogg", "application/x-ogg",
NULL }; NULL };
InputPlugin oggflacPlugin = { struct decoder_plugin oggflacPlugin = {
"oggflac", "oggflac",
NULL, NULL,
NULL, NULL,
...@@ -406,6 +406,6 @@ InputPlugin oggflacPlugin = { ...@@ -406,6 +406,6 @@ InputPlugin oggflacPlugin = {
#else /* !HAVE_FLAC */ #else /* !HAVE_FLAC */
InputPlugin oggflacPlugin; struct decoder_plugin oggflacPlugin;
#endif /* HAVE_OGGFLAC */ #endif /* HAVE_OGGFLAC */
...@@ -381,7 +381,7 @@ static const char *oggvorbis_MimeTypes[] = { "application/ogg", ...@@ -381,7 +381,7 @@ static const char *oggvorbis_MimeTypes[] = { "application/ogg",
"application/x-ogg", "application/x-ogg",
NULL }; NULL };
InputPlugin oggvorbisPlugin = { struct decoder_plugin oggvorbisPlugin = {
"oggvorbis", "oggvorbis",
NULL, NULL,
NULL, NULL,
...@@ -396,6 +396,6 @@ InputPlugin oggvorbisPlugin = { ...@@ -396,6 +396,6 @@ InputPlugin oggvorbisPlugin = {
#else /* !HAVE_OGGVORBIS */ #else /* !HAVE_OGGVORBIS */
InputPlugin oggvorbisPlugin; struct decoder_plugin oggvorbisPlugin;
#endif /* HAVE_OGGVORBIS */ #endif /* HAVE_OGGVORBIS */
...@@ -577,7 +577,7 @@ static int wavpack_filedecode(struct decoder * decoder, char *fname) ...@@ -577,7 +577,7 @@ static int wavpack_filedecode(struct decoder * decoder, char *fname)
static char const *wavpackSuffixes[] = { "wv", NULL }; static char const *wavpackSuffixes[] = { "wv", NULL };
static char const *wavpackMimeTypes[] = { "audio/x-wavpack", NULL }; static char const *wavpackMimeTypes[] = { "audio/x-wavpack", NULL };
InputPlugin wavpackPlugin = { struct decoder_plugin wavpackPlugin = {
"wavpack", "wavpack",
NULL, NULL,
NULL, NULL,
...@@ -592,6 +592,6 @@ InputPlugin wavpackPlugin = { ...@@ -592,6 +592,6 @@ InputPlugin wavpackPlugin = {
#else /* !HAVE_WAVPACK */ #else /* !HAVE_WAVPACK */
InputPlugin wavpackPlugin; struct decoder_plugin wavpackPlugin;
#endif /* !HAVE_WAVPACK */ #endif /* !HAVE_WAVPACK */
...@@ -257,9 +257,9 @@ int isDir(const char *utf8name) ...@@ -257,9 +257,9 @@ int isDir(const char *utf8name)
return 0; return 0;
} }
InputPlugin *hasMusicSuffix(const char *utf8file, unsigned int next) struct decoder_plugin *hasMusicSuffix(const char *utf8file, unsigned int next)
{ {
InputPlugin *ret = NULL; struct decoder_plugin *ret = NULL;
const char *s = getSuffix(utf8file); const char *s = getSuffix(utf8file);
if (s) { if (s) {
...@@ -272,10 +272,11 @@ InputPlugin *hasMusicSuffix(const char *utf8file, unsigned int next) ...@@ -272,10 +272,11 @@ InputPlugin *hasMusicSuffix(const char *utf8file, unsigned int next)
return ret; return ret;
} }
InputPlugin *isMusic(const char *utf8file, time_t * mtime, unsigned int next) struct decoder_plugin *isMusic(const char *utf8file, time_t * mtime,
unsigned int next)
{ {
if (isFile(utf8file, mtime)) { if (isFile(utf8file, mtime)) {
InputPlugin *plugin = hasMusicSuffix(utf8file, next); struct decoder_plugin *plugin = hasMusicSuffix(utf8file, next);
if (plugin != NULL) if (plugin != NULL)
return plugin; return plugin;
} }
......
...@@ -35,9 +35,10 @@ int isDir(const char *utf8name); ...@@ -35,9 +35,10 @@ int isDir(const char *utf8name);
int isPlaylist(const char *utf8file); int isPlaylist(const char *utf8file);
InputPlugin *hasMusicSuffix(const char *utf8file, unsigned int next); struct decoder_plugin *hasMusicSuffix(const char *utf8file, unsigned int next);
InputPlugin *isMusic(const char *utf8file, time_t * mtime, unsigned int next); struct decoder_plugin *isMusic(const char *utf8file, time_t * mtime,
unsigned int next);
int printRemoteUrlHandlers(int fd); int printRemoteUrlHandlers(int fd);
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "path.h" #include "path.h"
#include "playlist.h" #include "playlist.h"
#include "inputPlugin.h" #include "inputPlugin.h"
#include "decoder_api.h"
#include "myfprintf.h" #include "myfprintf.h"
#define SONG_KEY "key: " #define SONG_KEY "key: "
...@@ -62,7 +63,7 @@ Song *newSong(const char *url, int type, Directory * parentDir) ...@@ -62,7 +63,7 @@ Song *newSong(const char *url, int type, Directory * parentDir)
assert(type == SONG_TYPE_URL || parentDir); assert(type == SONG_TYPE_URL || parentDir);
if (song->type == SONG_TYPE_FILE) { if (song->type == SONG_TYPE_FILE) {
InputPlugin *plugin; struct decoder_plugin *plugin;
unsigned int next = 0; unsigned int next = 0;
char path_max_tmp[MPD_PATH_MAX]; char path_max_tmp[MPD_PATH_MAX];
char *abs_path = rmp2amp_r(path_max_tmp, char *abs_path = rmp2amp_r(path_max_tmp,
...@@ -286,7 +287,7 @@ void readSongInfoIntoList(FILE * fp, SongList * list, Directory * parentDir) ...@@ -286,7 +287,7 @@ void readSongInfoIntoList(FILE * fp, SongList * list, Directory * parentDir)
int updateSongInfo(Song * song) int updateSongInfo(Song * song)
{ {
if (song->type == SONG_TYPE_FILE) { if (song->type == SONG_TYPE_FILE) {
InputPlugin *plugin; struct decoder_plugin *plugin;
unsigned int next = 0; unsigned int next = 0;
char path_max_tmp[MPD_PATH_MAX]; char path_max_tmp[MPD_PATH_MAX];
char abs_path[MPD_PATH_MAX]; char abs_path[MPD_PATH_MAX];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment