Commit 5036368f authored by Max Kellermann's avatar Max Kellermann

decoder: return const decoder_plugin structs

The decoder_plugin structs must never change. Don't work with non-const pointers.
parent 83f6222a
......@@ -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;
......
......@@ -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)
......
......@@ -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);
......
......@@ -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);
......
......@@ -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) {
......
......@@ -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);
......
......@@ -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;
......
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