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.
This commit is contained in:
parent
cdaa26c81d
commit
e41be362a1
|
@ -209,7 +209,7 @@ static void decodeStart(void)
|
|||
int ret;
|
||||
int close_instream = 1;
|
||||
InputStream inStream;
|
||||
InputPlugin *plugin = NULL;
|
||||
struct decoder_plugin *plugin = NULL;
|
||||
char path_max_fs[MPD_PATH_MAX];
|
||||
char path_max_utf8[MPD_PATH_MAX];
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ typedef int (*InputPlugin_fileDecodeFunc) (struct decoder *,
|
|||
* or read */
|
||||
typedef MpdTag *(*InputPlugin_tagDupFunc) (char *file);
|
||||
|
||||
typedef struct _InputPlugin {
|
||||
struct decoder_plugin {
|
||||
const char *name;
|
||||
InputPlugin_initFunc initFunc;
|
||||
InputPlugin_finishFunc finishFunc;
|
||||
|
@ -85,7 +85,7 @@ typedef struct _InputPlugin {
|
|||
/* last element in these arrays must always be a NULL: */
|
||||
const char *const*suffixes;
|
||||
const char *const*mimeTypes;
|
||||
} InputPlugin;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "pcm_utils.h"
|
||||
|
||||
struct decoder {
|
||||
InputPlugin *plugin;
|
||||
struct decoder_plugin *plugin;
|
||||
|
||||
ConvState conv_state;
|
||||
};
|
||||
|
|
|
@ -17,10 +17,11 @@
|
|||
*/
|
||||
|
||||
#include "inputPlugin.h"
|
||||
#include "decoder_api.h"
|
||||
|
||||
static List *inputPlugin_list;
|
||||
|
||||
void loadInputPlugin(InputPlugin * inputPlugin)
|
||||
void loadInputPlugin(struct decoder_plugin * inputPlugin)
|
||||
{
|
||||
if (!inputPlugin)
|
||||
return;
|
||||
|
@ -33,7 +34,7 @@ void loadInputPlugin(InputPlugin * inputPlugin)
|
|||
insertInList(inputPlugin_list, inputPlugin->name, (void *)inputPlugin);
|
||||
}
|
||||
|
||||
void unloadInputPlugin(InputPlugin * inputPlugin)
|
||||
void unloadInputPlugin(struct decoder_plugin * inputPlugin)
|
||||
{
|
||||
if (inputPlugin->finishFunc)
|
||||
inputPlugin->finishFunc();
|
||||
|
@ -51,11 +52,11 @@ static int stringFoundInStringArray(const char *const*array, const char *suffix)
|
|||
return 0;
|
||||
}
|
||||
|
||||
InputPlugin *getInputPluginFromSuffix(const char *suffix, unsigned int next)
|
||||
struct decoder_plugin *getInputPluginFromSuffix(const char *suffix, unsigned int next)
|
||||
{
|
||||
static ListNode *pos;
|
||||
ListNode *node;
|
||||
InputPlugin *plugin;
|
||||
struct decoder_plugin *plugin;
|
||||
|
||||
if (suffix == NULL)
|
||||
return NULL;
|
||||
|
@ -80,11 +81,11 @@ InputPlugin *getInputPluginFromSuffix(const char *suffix, unsigned int next)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
InputPlugin *getInputPluginFromMimeType(const char *mimeType, unsigned int next)
|
||||
struct decoder_plugin *getInputPluginFromMimeType(const char *mimeType, unsigned int next)
|
||||
{
|
||||
static ListNode *pos;
|
||||
ListNode *node;
|
||||
InputPlugin *plugin;
|
||||
struct decoder_plugin *plugin;
|
||||
|
||||
if (mimeType == NULL)
|
||||
return NULL;
|
||||
|
@ -103,23 +104,23 @@ InputPlugin *getInputPluginFromMimeType(const char *mimeType, unsigned int next)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
InputPlugin *getInputPluginFromName(const char *name)
|
||||
struct decoder_plugin *getInputPluginFromName(const char *name)
|
||||
{
|
||||
void *plugin = NULL;
|
||||
|
||||
findInList(inputPlugin_list, name, &plugin);
|
||||
|
||||
return (InputPlugin *) plugin;
|
||||
return (struct decoder_plugin *) plugin;
|
||||
}
|
||||
|
||||
void printAllInputPluginSuffixes(FILE * fp)
|
||||
{
|
||||
ListNode *node = inputPlugin_list->firstNode;
|
||||
InputPlugin *plugin;
|
||||
struct decoder_plugin *plugin;
|
||||
const char *const*suffixes;
|
||||
|
||||
while (node) {
|
||||
plugin = (InputPlugin *) node->data;
|
||||
plugin = (struct decoder_plugin *) node->data;
|
||||
suffixes = plugin->suffixes;
|
||||
while (suffixes && *suffixes) {
|
||||
fprintf(fp, "%s ", *suffixes);
|
||||
|
|
|
@ -19,19 +19,21 @@
|
|||
#ifndef INPUT_PLUGIN_H
|
||||
#define INPUT_PLUGIN_H
|
||||
|
||||
#include "decoder_api.h"
|
||||
#include "os_compat.h"
|
||||
|
||||
struct decoder_plugin;
|
||||
|
||||
/* individual functions to load/unload plugins */
|
||||
void loadInputPlugin(InputPlugin * inputPlugin);
|
||||
void unloadInputPlugin(InputPlugin * inputPlugin);
|
||||
void loadInputPlugin(struct decoder_plugin * inputPlugin);
|
||||
void unloadInputPlugin(struct decoder_plugin * inputPlugin);
|
||||
|
||||
/* 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);
|
||||
|
||||
|
@ -41,15 +43,15 @@ void initInputPlugins(void);
|
|||
/* this is where we "unload" all the "plugins" */
|
||||
void finishInputPlugins(void);
|
||||
|
||||
extern InputPlugin mp3Plugin;
|
||||
extern InputPlugin oggvorbisPlugin;
|
||||
extern InputPlugin flacPlugin;
|
||||
extern InputPlugin oggflacPlugin;
|
||||
extern InputPlugin audiofilePlugin;
|
||||
extern InputPlugin mp4Plugin;
|
||||
extern InputPlugin aacPlugin;
|
||||
extern InputPlugin mpcPlugin;
|
||||
extern InputPlugin wavpackPlugin;
|
||||
extern InputPlugin modPlugin;
|
||||
extern struct decoder_plugin mp3Plugin;
|
||||
extern struct decoder_plugin oggvorbisPlugin;
|
||||
extern struct decoder_plugin flacPlugin;
|
||||
extern struct decoder_plugin oggflacPlugin;
|
||||
extern struct decoder_plugin audiofilePlugin;
|
||||
extern struct decoder_plugin mp4Plugin;
|
||||
extern struct decoder_plugin aacPlugin;
|
||||
extern struct decoder_plugin mpcPlugin;
|
||||
extern struct decoder_plugin wavpackPlugin;
|
||||
extern struct decoder_plugin modPlugin;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -433,7 +433,7 @@ static MpdTag *aacTagDup(char *file)
|
|||
static const char *aac_suffixes[] = { "aac", NULL };
|
||||
static const char *aac_mimeTypes[] = { "audio/aac", "audio/aacp", NULL };
|
||||
|
||||
InputPlugin aacPlugin = {
|
||||
struct decoder_plugin aacPlugin = {
|
||||
"aac",
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -448,6 +448,6 @@ InputPlugin aacPlugin = {
|
|||
|
||||
#else
|
||||
|
||||
InputPlugin aacPlugin;
|
||||
struct decoder_plugin aacPlugin;
|
||||
|
||||
#endif /* HAVE_FAAD */
|
||||
|
|
|
@ -137,7 +137,7 @@ static MpdTag *audiofileTagDup(char *file)
|
|||
|
||||
static const char *audiofileSuffixes[] = { "wav", "au", "aiff", "aif", NULL };
|
||||
|
||||
InputPlugin audiofilePlugin = {
|
||||
struct decoder_plugin audiofilePlugin = {
|
||||
"audiofile",
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -152,6 +152,6 @@ InputPlugin audiofilePlugin = {
|
|||
|
||||
#else
|
||||
|
||||
InputPlugin audiofilePlugin;
|
||||
struct decoder_plugin audiofilePlugin;
|
||||
|
||||
#endif /* HAVE_AUDIOFILE */
|
||||
|
|
|
@ -469,7 +469,7 @@ static int flac_decode(struct decoder * decoder, InputStream * inStream)
|
|||
# define flac_plugin_init NULL
|
||||
#else /* FLAC_API_VERSION_CURRENT >= 7 */
|
||||
/* 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)
|
||||
{
|
||||
|
@ -544,7 +544,7 @@ static const char *flac_mime_types[] = { "audio/x-flac",
|
|||
"application/x-flac",
|
||||
NULL };
|
||||
|
||||
InputPlugin flacPlugin = {
|
||||
struct decoder_plugin flacPlugin = {
|
||||
"flac",
|
||||
flac_plugin_init,
|
||||
NULL,
|
||||
|
@ -559,6 +559,6 @@ InputPlugin flacPlugin = {
|
|||
|
||||
#else /* !HAVE_FLAC */
|
||||
|
||||
InputPlugin flacPlugin;
|
||||
struct decoder_plugin flacPlugin;
|
||||
|
||||
#endif /* HAVE_FLAC */
|
||||
|
|
|
@ -262,7 +262,7 @@ static const char *modSuffixes[] = { "amf",
|
|||
NULL
|
||||
};
|
||||
|
||||
InputPlugin modPlugin = {
|
||||
struct decoder_plugin modPlugin = {
|
||||
"mod",
|
||||
NULL,
|
||||
mod_finishMikMod,
|
||||
|
@ -277,6 +277,6 @@ InputPlugin modPlugin = {
|
|||
|
||||
#else
|
||||
|
||||
InputPlugin modPlugin;
|
||||
struct decoder_plugin modPlugin;
|
||||
|
||||
#endif /* HAVE_MIKMOD */
|
||||
|
|
|
@ -1110,7 +1110,7 @@ static MpdTag *mp3_tagDup(char *file)
|
|||
static const char *mp3_suffixes[] = { "mp3", "mp2", NULL };
|
||||
static const char *mp3_mimeTypes[] = { "audio/mpeg", NULL };
|
||||
|
||||
InputPlugin mp3Plugin = {
|
||||
struct decoder_plugin mp3Plugin = {
|
||||
"mp3",
|
||||
mp3_plugin_init,
|
||||
NULL,
|
||||
|
@ -1124,6 +1124,6 @@ InputPlugin mp3Plugin = {
|
|||
};
|
||||
#else
|
||||
|
||||
InputPlugin mp3Plugin;
|
||||
struct decoder_plugin mp3Plugin;
|
||||
|
||||
#endif /* HAVE_MAD */
|
||||
|
|
|
@ -408,7 +408,7 @@ static MpdTag *mp4TagDup(char *file)
|
|||
static const char *mp4_suffixes[] = { "m4a", "mp4", NULL };
|
||||
static const char *mp4_mimeTypes[] = { "audio/mp4", "audio/m4a", NULL };
|
||||
|
||||
InputPlugin mp4Plugin = {
|
||||
struct decoder_plugin mp4Plugin = {
|
||||
"mp4",
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -423,6 +423,6 @@ InputPlugin mp4Plugin = {
|
|||
|
||||
#else
|
||||
|
||||
InputPlugin mp4Plugin;
|
||||
struct decoder_plugin mp4Plugin;
|
||||
|
||||
#endif /* HAVE_FAAD */
|
||||
|
|
|
@ -313,7 +313,7 @@ static MpdTag *mpcTagDup(char *file)
|
|||
|
||||
static const char *mpcSuffixes[] = { "mpc", NULL };
|
||||
|
||||
InputPlugin mpcPlugin = {
|
||||
struct decoder_plugin mpcPlugin = {
|
||||
"mpc",
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -328,6 +328,6 @@ InputPlugin mpcPlugin = {
|
|||
|
||||
#else
|
||||
|
||||
InputPlugin mpcPlugin;
|
||||
struct decoder_plugin mpcPlugin;
|
||||
|
||||
#endif /* HAVE_MPCDEC */
|
||||
|
|
|
@ -391,7 +391,7 @@ static const char *oggflac_mime_types[] = { "audio/x-flac+ogg",
|
|||
"application/x-ogg",
|
||||
NULL };
|
||||
|
||||
InputPlugin oggflacPlugin = {
|
||||
struct decoder_plugin oggflacPlugin = {
|
||||
"oggflac",
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -406,6 +406,6 @@ InputPlugin oggflacPlugin = {
|
|||
|
||||
#else /* !HAVE_FLAC */
|
||||
|
||||
InputPlugin oggflacPlugin;
|
||||
struct decoder_plugin oggflacPlugin;
|
||||
|
||||
#endif /* HAVE_OGGFLAC */
|
||||
|
|
|
@ -381,7 +381,7 @@ static const char *oggvorbis_MimeTypes[] = { "application/ogg",
|
|||
"application/x-ogg",
|
||||
NULL };
|
||||
|
||||
InputPlugin oggvorbisPlugin = {
|
||||
struct decoder_plugin oggvorbisPlugin = {
|
||||
"oggvorbis",
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -396,6 +396,6 @@ InputPlugin oggvorbisPlugin = {
|
|||
|
||||
#else /* !HAVE_OGGVORBIS */
|
||||
|
||||
InputPlugin oggvorbisPlugin;
|
||||
struct decoder_plugin oggvorbisPlugin;
|
||||
|
||||
#endif /* HAVE_OGGVORBIS */
|
||||
|
|
|
@ -577,7 +577,7 @@ static int wavpack_filedecode(struct decoder * decoder, char *fname)
|
|||
static char const *wavpackSuffixes[] = { "wv", NULL };
|
||||
static char const *wavpackMimeTypes[] = { "audio/x-wavpack", NULL };
|
||||
|
||||
InputPlugin wavpackPlugin = {
|
||||
struct decoder_plugin wavpackPlugin = {
|
||||
"wavpack",
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -592,6 +592,6 @@ InputPlugin wavpackPlugin = {
|
|||
|
||||
#else /* !HAVE_WAVPACK */
|
||||
|
||||
InputPlugin wavpackPlugin;
|
||||
struct decoder_plugin wavpackPlugin;
|
||||
|
||||
#endif /* !HAVE_WAVPACK */
|
||||
|
|
9
src/ls.c
9
src/ls.c
|
@ -257,9 +257,9 @@ int isDir(const char *utf8name)
|
|||
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);
|
||||
if (s) {
|
||||
|
@ -272,10 +272,11 @@ InputPlugin *hasMusicSuffix(const char *utf8file, unsigned int next)
|
|||
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)) {
|
||||
InputPlugin *plugin = hasMusicSuffix(utf8file, next);
|
||||
struct decoder_plugin *plugin = hasMusicSuffix(utf8file, next);
|
||||
if (plugin != NULL)
|
||||
return plugin;
|
||||
}
|
||||
|
|
5
src/ls.h
5
src/ls.h
|
@ -35,9 +35,10 @@ int isDir(const char *utf8name);
|
|||
|
||||
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);
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "path.h"
|
||||
#include "playlist.h"
|
||||
#include "inputPlugin.h"
|
||||
#include "decoder_api.h"
|
||||
#include "myfprintf.h"
|
||||
|
||||
#define SONG_KEY "key: "
|
||||
|
@ -62,7 +63,7 @@ Song *newSong(const char *url, int type, Directory * parentDir)
|
|||
assert(type == SONG_TYPE_URL || parentDir);
|
||||
|
||||
if (song->type == SONG_TYPE_FILE) {
|
||||
InputPlugin *plugin;
|
||||
struct decoder_plugin *plugin;
|
||||
unsigned int next = 0;
|
||||
char path_max_tmp[MPD_PATH_MAX];
|
||||
char *abs_path = rmp2amp_r(path_max_tmp,
|
||||
|
@ -286,7 +287,7 @@ void readSongInfoIntoList(FILE * fp, SongList * list, Directory * parentDir)
|
|||
int updateSongInfo(Song * song)
|
||||
{
|
||||
if (song->type == SONG_TYPE_FILE) {
|
||||
InputPlugin *plugin;
|
||||
struct decoder_plugin *plugin;
|
||||
unsigned int next = 0;
|
||||
char path_max_tmp[MPD_PATH_MAX];
|
||||
char abs_path[MPD_PATH_MAX];
|
||||
|
|
Loading…
Reference in New Issue