aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:04 +0200
committerMax Kellermann <max@duempel.org>2008-08-26 08:27:04 +0200
commit154aa496e8c18bba3dc10c607987c187f4686ae4 (patch)
tree32a2a35f74e823c5eea21bbfbebef1297fe6e989 /src/inputPlugins
parent241cd043ca4f9dd560e6d947a9bf025f58de4ea9 (diff)
downloadmpd-154aa496e8c18bba3dc10c607987c187f4686ae4.tar.gz
mpd-154aa496e8c18bba3dc10c607987c187f4686ae4.tar.xz
mpd-154aa496e8c18bba3dc10c607987c187f4686ae4.zip
added struct decoder
The decoder struct should later be made opaque to the decoder plugin, because maintaining a stable struct ABI is quite difficult. The ABI should only consist of a small number of stable functions.
Diffstat (limited to 'src/inputPlugins')
-rw-r--r--src/inputPlugins/_flac_common.c4
-rw-r--r--src/inputPlugins/_flac_common.h4
-rw-r--r--src/inputPlugins/aac_plugin.c2
-rw-r--r--src/inputPlugins/audiofile_plugin.c2
-rw-r--r--src/inputPlugins/flac_plugin.c13
-rw-r--r--src/inputPlugins/mod_plugin.c2
-rw-r--r--src/inputPlugins/mp3_plugin.c3
-rw-r--r--src/inputPlugins/mp4_plugin.c3
-rw-r--r--src/inputPlugins/mpc_plugin.c3
-rw-r--r--src/inputPlugins/oggflac_plugin.c8
-rw-r--r--src/inputPlugins/oggvorbis_plugin.c3
-rw-r--r--src/inputPlugins/wavpack_plugin.c11
12 files changed, 35 insertions, 23 deletions
diff --git a/src/inputPlugins/_flac_common.c b/src/inputPlugins/_flac_common.c
index 9e70662be..e1017e596 100644
--- a/src/inputPlugins/_flac_common.c
+++ b/src/inputPlugins/_flac_common.c
@@ -30,12 +30,14 @@
#include <FLAC/format.h>
#include <FLAC/metadata.h>
-void init_FlacData(FlacData * data, InputStream * inStream)
+void init_FlacData(FlacData * data, struct decoder * decoder,
+ InputStream * inStream)
{
data->chunk_length = 0;
data->time = 0;
data->position = 0;
data->bitRate = 0;
+ data->decoder = decoder;
data->inStream = inStream;
data->replayGainInfo = NULL;
data->tag = NULL;
diff --git a/src/inputPlugins/_flac_common.h b/src/inputPlugins/_flac_common.h
index fb69277ff..0437a416d 100644
--- a/src/inputPlugins/_flac_common.h
+++ b/src/inputPlugins/_flac_common.h
@@ -144,13 +144,15 @@ typedef struct {
float time;
unsigned int bitRate;
FLAC__uint64 position;
+ struct decoder *decoder;
InputStream *inStream;
ReplayGainInfo *replayGainInfo;
MpdTag *tag;
} FlacData;
/* initializes a given FlacData struct */
-void init_FlacData(FlacData * data, InputStream * inStream);
+void init_FlacData(FlacData * data, struct decoder * decoder,
+ InputStream * inStream);
void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
FlacData * data);
void flac_error_common_cb(const char *plugin,
diff --git a/src/inputPlugins/aac_plugin.c b/src/inputPlugins/aac_plugin.c
index 2ca757392..4f1818478 100644
--- a/src/inputPlugins/aac_plugin.c
+++ b/src/inputPlugins/aac_plugin.c
@@ -278,7 +278,7 @@ static int getAacTotalTime(char *file)
return file_time;
}
-static int aac_decode(char *path)
+static int aac_decode(mpd_unused struct decoder * mpd_decoder, char *path)
{
float file_time;
float totalTime;
diff --git a/src/inputPlugins/audiofile_plugin.c b/src/inputPlugins/audiofile_plugin.c
index 08c5e6e16..0cc357135 100644
--- a/src/inputPlugins/audiofile_plugin.c
+++ b/src/inputPlugins/audiofile_plugin.c
@@ -40,7 +40,7 @@ static int getAudiofileTotalTime(char *file)
return total_time;
}
-static int audiofile_decode(char *path)
+static int audiofile_decode(mpd_unused struct decoder * decoder, char *path)
{
int fs, frame_count;
AFfilehandle af_fp;
diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c
index a5b44c7f4..7c4b8e356 100644
--- a/src/inputPlugins/flac_plugin.c
+++ b/src/inputPlugins/flac_plugin.c
@@ -376,7 +376,8 @@ static MpdTag *flacTagDup(char *file)
return ret;
}
-static int flac_decode_internal(InputStream * inStream, int is_ogg)
+static int flac_decode_internal(struct decoder * decoder,
+ InputStream * inStream, int is_ogg)
{
flac_decoder *flacDec;
FlacData data;
@@ -384,7 +385,7 @@ static int flac_decode_internal(InputStream * inStream, int is_ogg)
if (!(flacDec = flac_new()))
return -1;
- init_FlacData(&data, inStream);
+ init_FlacData(&data, decoder, inStream);
#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
if(!FLAC__stream_decoder_set_metadata_respond(flacDec, FLAC__METADATA_TYPE_VORBIS_COMMENT))
@@ -458,9 +459,9 @@ fail:
return 0;
}
-static int flac_decode(InputStream * inStream)
+static int flac_decode(struct decoder * decoder, InputStream * inStream)
{
- return flac_decode_internal(inStream, 0);
+ return flac_decode_internal(decoder, inStream, 0);
}
#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7
@@ -499,9 +500,9 @@ out:
return ret;
}
-static int oggflac_decode(InputStream * inStream)
+static int oggflac_decode(struct decoder *decoder, InputStream * inStream)
{
- return flac_decode_internal(inStream, 1);
+ return flac_decode_internal(decoder, inStream, 1);
}
static unsigned int oggflac_try_decode(InputStream * inStream)
diff --git a/src/inputPlugins/mod_plugin.c b/src/inputPlugins/mod_plugin.c
index 40e2ef841..a041f1e34 100644
--- a/src/inputPlugins/mod_plugin.c
+++ b/src/inputPlugins/mod_plugin.c
@@ -159,7 +159,7 @@ static void mod_close(mod_Data * data)
free(data);
}
-static int mod_decode(char *path)
+static int mod_decode(mpd_unused struct decoder * decoder, char *path)
{
mod_Data *data;
float total_time = 0.0;
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c
index 4288f85de..e68452470 100644
--- a/src/inputPlugins/mp3_plugin.c
+++ b/src/inputPlugins/mp3_plugin.c
@@ -1015,7 +1015,8 @@ static void initAudioFormatFromMp3DecodeData(mp3DecodeData * data,
af->channels = MAD_NCHANNELS(&(data->frame).header);
}
-static int mp3_decode(InputStream * inStream)
+static int mp3_decode(mpd_unused struct decoder * decoder,
+ InputStream * inStream)
{
mp3DecodeData data;
MpdTag *tag = NULL;
diff --git a/src/inputPlugins/mp4_plugin.c b/src/inputPlugins/mp4_plugin.c
index 0bdd3e75b..e715b3983 100644
--- a/src/inputPlugins/mp4_plugin.c
+++ b/src/inputPlugins/mp4_plugin.c
@@ -78,7 +78,8 @@ static uint32_t mp4_inputStreamSeekCallback(void *inStream, uint64_t position)
return seekInputStream((InputStream *) inStream, position, SEEK_SET);
}
-static int mp4_decode(InputStream * inStream)
+static int mp4_decode(mpd_unused struct decoder * mpd_decoder,
+ InputStream * inStream)
{
mp4ff_t *mp4fh;
mp4ff_callback_t *mp4cb;
diff --git a/src/inputPlugins/mpc_plugin.c b/src/inputPlugins/mpc_plugin.c
index c6b13cdff..f69e9eddb 100644
--- a/src/inputPlugins/mpc_plugin.c
+++ b/src/inputPlugins/mpc_plugin.c
@@ -106,7 +106,8 @@ static inline mpd_sint16 convertSample(MPC_SAMPLE_FORMAT sample)
return val;
}
-static int mpc_decode(InputStream * inStream)
+static int mpc_decode(mpd_unused struct decoder * mpd_decoder,
+ InputStream * inStream)
{
mpc_decoder decoder;
mpc_reader reader;
diff --git a/src/inputPlugins/oggflac_plugin.c b/src/inputPlugins/oggflac_plugin.c
index 552b550be..a365f73cc 100644
--- a/src/inputPlugins/oggflac_plugin.c
+++ b/src/inputPlugins/oggflac_plugin.c
@@ -314,7 +314,7 @@ static MpdTag *oggflac_TagDup(char *file)
return NULL;
}
- init_FlacData(&data, &inStream);
+ init_FlacData(&data, NULL, &inStream);
/* errors here won't matter,
* data.tag will be set or unset, that's all we care about */
@@ -331,13 +331,15 @@ static unsigned int oggflac_try_decode(InputStream * inStream)
return (ogg_stream_type_detect(inStream) == FLAC) ? 1 : 0;
}
-static int oggflac_decode(InputStream * inStream)
+static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream)
{
+ DecoderControl *dc = mpd_decoder->dc;
+ OutputBuffer *ob = mpd_decoder->ob;
OggFLAC__SeekableStreamDecoder *decoder = NULL;
FlacData data;
int ret = 0;
- init_FlacData(&data, inStream);
+ init_FlacData(&data, mpd_decoder, inStream);
if (!(decoder = full_decoder_init_and_read_metadata(&data, 0))) {
ret = -1;
diff --git a/src/inputPlugins/oggvorbis_plugin.c b/src/inputPlugins/oggvorbis_plugin.c
index 993035f37..cb0c5a948 100644
--- a/src/inputPlugins/oggvorbis_plugin.c
+++ b/src/inputPlugins/oggvorbis_plugin.c
@@ -210,7 +210,8 @@ static void putOggCommentsIntoOutputBuffer(char *streamName,
}
/* public */
-static int oggvorbis_decode(InputStream * inStream)
+static int oggvorbis_decode(mpd_unused struct decoder * decoder,
+ InputStream * inStream)
{
OggVorbis_File vf;
ov_callbacks callbacks;
diff --git a/src/inputPlugins/wavpack_plugin.c b/src/inputPlugins/wavpack_plugin.c
index ae5f50826..99491a232 100644
--- a/src/inputPlugins/wavpack_plugin.c
+++ b/src/inputPlugins/wavpack_plugin.c
@@ -124,7 +124,8 @@ static void format_samples_float(mpd_unused int Bps, void *buffer,
* This does the main decoding thing.
* Requires an already opened WavpackContext.
*/
-static void wavpack_decode(WavpackContext *wpc, int canseek,
+static void wavpack_decode(mpd_unused struct decoder * decoder,
+ WavpackContext *wpc, int canseek,
ReplayGainInfo *replayGainInfo)
{
void (*format_samples)(int Bps, void *buffer, uint32_t samcnt);
@@ -436,7 +437,7 @@ static unsigned int wavpack_trydecode(InputStream *is)
/*
* Decodes a stream.
*/
-static int wavpack_streamdecode(InputStream *is)
+static int wavpack_streamdecode(struct decoder * decoder, InputStream *is)
{
char error[ERRORLEN];
WavpackContext *wpc;
@@ -535,7 +536,7 @@ static int wavpack_streamdecode(InputStream *is)
return -1;
}
- wavpack_decode(wpc, canseek, NULL);
+ wavpack_decode(decoder, wpc, canseek, NULL);
WavpackCloseFile(wpc);
if (wvc_url != NULL) {
@@ -550,7 +551,7 @@ static int wavpack_streamdecode(InputStream *is)
/*
* Decodes a file.
*/
-static int wavpack_filedecode(char *fname)
+static int wavpack_filedecode(struct decoder * decoder, char *fname)
{
char error[ERRORLEN];
WavpackContext *wpc;
@@ -566,7 +567,7 @@ static int wavpack_filedecode(char *fname)
replayGainInfo = wavpack_replaygain(wpc);
- wavpack_decode(wpc, 1, replayGainInfo);
+ wavpack_decode(decoder, wpc, 1, replayGainInfo);
if (replayGainInfo)
freeReplayGainInfo(replayGainInfo);