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.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user