aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-11-01 14:51:41 +0100
committerMax Kellermann <max@duempel.org>2008-11-01 14:51:41 +0100
commit5036368f540af93372b750fe80e1c191b409a7a9 (patch)
tree38fcbd9a827f1271995e86307db4e80e2c201945
parent83f6222ae74e6601383cf934a1bbf176656bf5c5 (diff)
downloadmpd-5036368f540af93372b750fe80e1c191b409a7a9.tar.gz
mpd-5036368f540af93372b750fe80e1c191b409a7a9.tar.xz
mpd-5036368f540af93372b750fe80e1c191b409a7a9.zip
decoder: return const decoder_plugin structs
The decoder_plugin structs must never change. Don't work with non-const pointers.
Diffstat (limited to '')
-rw-r--r--src/decoder_internal.h2
-rw-r--r--src/decoder_list.c15
-rw-r--r--src/decoder_list.h15
-rw-r--r--src/decoder_thread.c2
-rw-r--r--src/ls.c5
-rw-r--r--src/ls.h3
-rw-r--r--src/song.c2
7 files changed, 24 insertions, 20 deletions
diff --git a/src/decoder_internal.h b/src/decoder_internal.h
index 45c104651..7a36e011c 100644
--- a/src/decoder_internal.h
+++ b/src/decoder_internal.h
@@ -23,7 +23,7 @@
#include "pcm_utils.h"
struct decoder {
- struct decoder_plugin *plugin;
+ const struct decoder_plugin *plugin;
struct pcm_convert_state conv_state;
diff --git a/src/decoder_list.c b/src/decoder_list.c
index 57a013ec9..e99f6a5fd 100644
--- a/src/decoder_list.c
+++ b/src/decoder_list.c
@@ -65,12 +65,12 @@ static int stringFoundInStringArray(const char *const*array, const char *suffix)
return 0;
}
-struct decoder_plugin *decoder_plugin_from_suffix(const char *suffix,
- unsigned int next)
+const struct decoder_plugin *
+decoder_plugin_from_suffix(const char *suffix, unsigned int next)
{
static ListNode *pos;
ListNode *node;
- struct decoder_plugin *plugin;
+ const struct decoder_plugin *plugin;
if (suffix == NULL)
return NULL;
@@ -95,8 +95,8 @@ struct decoder_plugin *decoder_plugin_from_suffix(const char *suffix,
return NULL;
}
-struct decoder_plugin *decoder_plugin_from_mime_type(const char *mimeType,
- unsigned int next)
+const struct decoder_plugin *
+decoder_plugin_from_mime_type(const char *mimeType, unsigned int next)
{
static ListNode *pos;
ListNode *node;
@@ -119,13 +119,14 @@ struct decoder_plugin *decoder_plugin_from_mime_type(const char *mimeType,
return NULL;
}
-struct decoder_plugin *decoder_plugin_from_name(const char *name)
+const struct decoder_plugin *
+decoder_plugin_from_name(const char *name)
{
void *plugin = NULL;
findInList(inputPlugin_list, name, &plugin);
- return (struct decoder_plugin *) plugin;
+ return (const struct decoder_plugin *) plugin;
}
void decoder_plugin_print_all_suffixes(FILE * fp)
diff --git a/src/decoder_list.h b/src/decoder_list.h
index ea3eb7f92..2e18438fb 100644
--- a/src/decoder_list.h
+++ b/src/decoder_list.h
@@ -24,18 +24,19 @@
struct decoder_plugin;
/* individual functions to load/unload plugins */
-void decoder_plugin_load(struct decoder_plugin * inputPlugin);
-void decoder_plugin_unload(struct decoder_plugin * inputPlugin);
+void decoder_plugin_load(struct decoder_plugin *inputPlugin);
+void decoder_plugin_unload(struct decoder_plugin *inputPlugin);
/* interface for using plugins */
-struct decoder_plugin *decoder_plugin_from_suffix(const char *suffix,
- unsigned int next);
+const struct decoder_plugin *
+decoder_plugin_from_suffix(const char *suffix, unsigned int next);
-struct decoder_plugin *decoder_plugin_from_mime_type(const char *mimeType,
- unsigned int next);
+const struct decoder_plugin *
+decoder_plugin_from_mime_type(const char *mimeType, unsigned int next);
-struct decoder_plugin *decoder_plugin_from_name(const char *name);
+const struct decoder_plugin *
+decoder_plugin_from_name(const char *name);
void decoder_plugin_print_all_suffixes(FILE * fp);
diff --git a/src/decoder_thread.c b/src/decoder_thread.c
index 14a1f858f..659d43603 100644
--- a/src/decoder_thread.c
+++ b/src/decoder_thread.c
@@ -37,7 +37,7 @@ static void decodeStart(void)
int ret;
bool close_instream = true;
struct input_stream inStream;
- struct decoder_plugin *plugin = NULL;
+ const struct decoder_plugin *plugin;
if (song_is_file(song))
uri = map_song_fs(song, buffer);
diff --git a/src/ls.c b/src/ls.c
index 2f652658c..7a2eb11f7 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -113,9 +113,10 @@ const char *getSuffix(const char *utf8file)
return ret;
}
-struct decoder_plugin *hasMusicSuffix(const char *utf8file, unsigned int next)
+const struct decoder_plugin *
+hasMusicSuffix(const char *utf8file, unsigned int next)
{
- struct decoder_plugin *ret = NULL;
+ const struct decoder_plugin *ret = NULL;
const char *s = getSuffix(utf8file);
if (s) {
diff --git a/src/ls.h b/src/ls.h
index da79bbbd2..ed0f0677f 100644
--- a/src/ls.h
+++ b/src/ls.h
@@ -32,7 +32,8 @@ int isValidRemoteUtf8Url(const char *utf8url);
int isRemoteUrl(const char *url);
-struct decoder_plugin *hasMusicSuffix(const char *utf8file, unsigned int next);
+const struct decoder_plugin *
+hasMusicSuffix(const char *utf8file, unsigned int next);
int printRemoteUrlHandlers(struct client *client);
diff --git a/src/song.c b/src/song.c
index 4ab0afadf..eafd1fb4a 100644
--- a/src/song.c
+++ b/src/song.c
@@ -96,7 +96,7 @@ song_file_update(struct song *song)
{
char buffer[MPD_PATH_MAX];
const char *path_fs;
- struct decoder_plugin *plugin;
+ const struct decoder_plugin *plugin;
unsigned int next = 0;
struct stat st;