From 78448fe1a517aa7734ae14a6959d3f7e0182308e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 31 Oct 2008 15:56:43 +0100 Subject: decoder_api: pass constant path pointers --- src/decoder/aac_plugin.c | 8 ++++---- src/decoder/audiofile_plugin.c | 6 +++--- src/decoder/ffmpeg_plugin.c | 2 +- src/decoder/flac_plugin.c | 6 +++--- src/decoder/mod_plugin.c | 26 ++++++++++++++++++++------ src/decoder/mp3_plugin.c | 4 ++-- src/decoder/mp4_plugin.c | 4 ++-- src/decoder/mpc_plugin.c | 4 ++-- src/decoder/oggflac_plugin.c | 2 +- src/decoder/oggvorbis_plugin.c | 2 +- src/decoder/wavpack_plugin.c | 4 ++-- src/decoder_api.h | 4 ++-- 12 files changed, 43 insertions(+), 29 deletions(-) diff --git a/src/decoder/aac_plugin.c b/src/decoder/aac_plugin.c index 8ae061667..7e6b8c916 100644 --- a/src/decoder/aac_plugin.c +++ b/src/decoder/aac_plugin.c @@ -246,7 +246,7 @@ static void aac_parse_header(AacBuffer * b, float *length) } } -static float getAacFloatTotalTime(char *file) +static float getAacFloatTotalTime(const char *file) { AacBuffer b; float length; @@ -290,7 +290,7 @@ static float getAacFloatTotalTime(char *file) return length; } -static int getAacTotalTime(char *file) +static int getAacTotalTime(const char *file) { int file_time = -1; float length; @@ -435,7 +435,7 @@ aac_stream_decode(struct decoder *mpd_decoder, struct input_stream *inStream) static bool -aac_decode(struct decoder *mpd_decoder, char *path) +aac_decode(struct decoder *mpd_decoder, const char *path) { float file_time; float totalTime; @@ -569,7 +569,7 @@ aac_decode(struct decoder *mpd_decoder, char *path) return true; } -static struct tag *aacTagDup(char *file) +static struct tag *aacTagDup(const char *file) { struct tag *ret = NULL; int file_time = getAacTotalTime(file); diff --git a/src/decoder/audiofile_plugin.c b/src/decoder/audiofile_plugin.c index 5c1e0a0d0..8f493d1ed 100644 --- a/src/decoder/audiofile_plugin.c +++ b/src/decoder/audiofile_plugin.c @@ -27,7 +27,7 @@ /* pick 1020 since its devisible for 8,16,24, and 32-bit audio */ #define CHUNK_SIZE 1020 -static int getAudiofileTotalTime(char *file) +static int getAudiofileTotalTime(const char *file) { int total_time; AFfilehandle af_fp = afOpenFile(file, "r", NULL); @@ -42,7 +42,7 @@ static int getAudiofileTotalTime(char *file) } static bool -audiofile_decode(struct decoder *decoder, char *path) +audiofile_decode(struct decoder *decoder, const char *path) { int fs, frame_count; AFfilehandle af_fp; @@ -115,7 +115,7 @@ audiofile_decode(struct decoder *decoder, char *path) return true; } -static struct tag *audiofileTagDup(char *file) +static struct tag *audiofileTagDup(const char *file) { struct tag *ret = NULL; int total_time = getAudiofileTotalTime(file); diff --git a/src/decoder/ffmpeg_plugin.c b/src/decoder/ffmpeg_plugin.c index dde06f4d3..a249bc118 100644 --- a/src/decoder/ffmpeg_plugin.c +++ b/src/decoder/ffmpeg_plugin.c @@ -325,7 +325,7 @@ static bool ffmpeg_tag_internal(BasePtrs *base) } //no tag reading in ffmpeg, check if playable -static struct tag *ffmpeg_tag(char *file) +static struct tag *ffmpeg_tag(const char *file) { struct input_stream input; BasePtrs base; diff --git a/src/decoder/flac_plugin.c b/src/decoder/flac_plugin.c index a4ccd6ebb..0c4869428 100644 --- a/src/decoder/flac_plugin.c +++ b/src/decoder/flac_plugin.c @@ -220,7 +220,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec, } static struct tag * -flacMetadataDup(char *file, bool *vorbisCommentFound) +flacMetadataDup(const char *file, bool *vorbisCommentFound) { struct tag *ret = NULL; FLAC__Metadata_SimpleIterator *it; @@ -278,7 +278,7 @@ flacMetadataDup(char *file, bool *vorbisCommentFound) return ret; } -static struct tag *flacTagDup(char *file) +static struct tag *flacTagDup(const char *file) { struct tag *ret = NULL; bool foundVorbisComment = false; @@ -386,7 +386,7 @@ flac_decode(struct decoder * decoder, struct input_stream *inStream) #if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7 && \ !defined(HAVE_OGGFLAC) -static struct tag *oggflac_tag_dup(char *file) +static struct tag *oggflac_tag_dup(const char *file) { struct tag *ret = NULL; FLAC__Metadata_Iterator *it; diff --git a/src/decoder/mod_plugin.c b/src/decoder/mod_plugin.c index 3f120abf4..8a45db849 100644 --- a/src/decoder/mod_plugin.c +++ b/src/decoder/mod_plugin.c @@ -20,6 +20,7 @@ #include "../utils.h" #include "../log.h" +#include #include /* this is largely copied from alsaplayer */ @@ -136,12 +137,17 @@ typedef struct _mod_Data { SBYTE *audio_buffer; } mod_Data; -static mod_Data *mod_open(char *path) +static mod_Data *mod_open(const char *path) { + char *path2; MODULE *moduleHandle; mod_Data *data; - if (!(moduleHandle = Player_Load(path, 128, 0))) + path2 = g_strdup(path); + moduleHandle = Player_Load(path2, 128, 0); + g_free(path2); + + if (moduleHandle == NULL) return NULL; /* Prevent module from looping forever */ @@ -166,7 +172,7 @@ static void mod_close(mod_Data * data) } static bool -mod_decode(struct decoder *decoder, char *path) +mod_decode(struct decoder *decoder, const char *path) { mod_Data *data; struct audio_format audio_format; @@ -218,8 +224,9 @@ mod_decode(struct decoder *decoder, char *path) return true; } -static struct tag *modTagDup(char *file) +static struct tag *modTagDup(const char *file) { + char *path2; struct tag *ret = NULL; MODULE *moduleHandle; char *title; @@ -229,7 +236,11 @@ static struct tag *modTagDup(char *file) return NULL; } - if (!(moduleHandle = Player_Load(file, 128, 0))) { + path2 = g_strdup(file); + moduleHandle = Player_Load(path2, 128, 0); + g_free(path2); + + if (moduleHandle == NULL) { DEBUG("modTagDup: Failed to open file: %s\n", file); MikMod_Exit(); return NULL; @@ -240,7 +251,10 @@ static struct tag *modTagDup(char *file) ret = tag_new(); ret->time = 0; - title = xstrdup(Player_LoadTitle(file)); + + path2 = g_strdup(file); + title = xstrdup(Player_LoadTitle(path2)); + g_free(path2); if (title) tag_add_item(ret, TAG_ITEM_TITLE, title); diff --git a/src/decoder/mp3_plugin.c b/src/decoder/mp3_plugin.c index d95abc9ca..fe15568f1 100644 --- a/src/decoder/mp3_plugin.c +++ b/src/decoder/mp3_plugin.c @@ -791,7 +791,7 @@ static void mp3_data_finish(struct mp3_data *data) } /* this is primarily used for getting total time for tags */ -static int mp3_total_file_time(char *file) +static int mp3_total_file_time(const char *file) { struct input_stream input_stream; struct mp3_data data; @@ -1123,7 +1123,7 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream) return true; } -static struct tag *mp3_tag_dup(char *file) +static struct tag *mp3_tag_dup(const char *file) { struct tag *ret = NULL; int total_time; diff --git a/src/decoder/mp4_plugin.c b/src/decoder/mp4_plugin.c index 760b8871b..8fe2b18f8 100644 --- a/src/decoder/mp4_plugin.c +++ b/src/decoder/mp4_plugin.c @@ -301,7 +301,7 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *inStream) return true; } -static struct tag *mp4DataDup(char *file, int *mp4MetadataFound) +static struct tag *mp4DataDup(const char *file, int *mp4MetadataFound) { struct tag *ret = NULL; struct input_stream inStream; @@ -390,7 +390,7 @@ static struct tag *mp4DataDup(char *file, int *mp4MetadataFound) return ret; } -static struct tag *mp4TagDup(char *file) +static struct tag *mp4TagDup(const char *file) { struct tag *ret = NULL; int mp4MetadataFound = 0; diff --git a/src/decoder/mpc_plugin.c b/src/decoder/mpc_plugin.c index 258947173..137c01afd 100644 --- a/src/decoder/mpc_plugin.c +++ b/src/decoder/mpc_plugin.c @@ -236,7 +236,7 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream) return true; } -static float mpcGetTime(char *file) +static float mpcGetTime(const char *file) { struct input_stream inStream; float total_time = -1; @@ -274,7 +274,7 @@ static float mpcGetTime(char *file) return total_time; } -static struct tag *mpcTagDup(char *file) +static struct tag *mpcTagDup(const char *file) { struct tag *ret = NULL; float total_time = mpcGetTime(file); diff --git a/src/decoder/oggflac_plugin.c b/src/decoder/oggflac_plugin.c index d50575bea..769259ee5 100644 --- a/src/decoder/oggflac_plugin.c +++ b/src/decoder/oggflac_plugin.c @@ -254,7 +254,7 @@ fail: } /* public functions: */ -static struct tag *oggflac_TagDup(char *file) +static struct tag *oggflac_TagDup(const char *file) { struct input_stream inStream; OggFLAC__SeekableStreamDecoder *decoder; diff --git a/src/decoder/oggvorbis_plugin.c b/src/decoder/oggvorbis_plugin.c index f4c6de7fe..be6664b85 100644 --- a/src/decoder/oggvorbis_plugin.c +++ b/src/decoder/oggvorbis_plugin.c @@ -329,7 +329,7 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream) return true; } -static struct tag *oggvorbis_TagDup(char *file) +static struct tag *oggvorbis_TagDup(const char *file) { struct tag *ret; FILE *fp; diff --git a/src/decoder/wavpack_plugin.c b/src/decoder/wavpack_plugin.c index 9f28475cd..420edade6 100644 --- a/src/decoder/wavpack_plugin.c +++ b/src/decoder/wavpack_plugin.c @@ -277,7 +277,7 @@ static ReplayGainInfo *wavpack_replaygain(WavpackContext *wpc) /* * Reads metainfo from the specified file. */ -static struct tag *wavpack_tagdup(char *fname) +static struct tag *wavpack_tagdup(const char *fname) { WavpackContext *wpc; struct tag *tag; @@ -533,7 +533,7 @@ wavpack_streamdecode(struct decoder * decoder, struct input_stream *is) * Decodes a file. */ static bool -wavpack_filedecode(struct decoder *decoder, char *fname) +wavpack_filedecode(struct decoder *decoder, const char *fname) { char error[ERRORLEN]; WavpackContext *wpc; diff --git a/src/decoder_api.h b/src/decoder_api.h index a48718846..1400f52c2 100644 --- a/src/decoder_api.h +++ b/src/decoder_api.h @@ -86,13 +86,13 @@ struct decoder_plugin { * * returns -1 on error, 0 on success */ - bool (*file_decode)(struct decoder *, char *path); + bool (*file_decode)(struct decoder *, const char *path); /** * file should be the full path! Returns NULL if a tag cannot * be found or read */ - struct tag *(*tag_dup)(char *file); + struct tag *(*tag_dup)(const char *file); /* one or more of the INPUT_PLUGIN_STREAM_* values OR'd together */ unsigned char stream_types; -- cgit v1.2.3