input_stream: removed the InputStream typedef

Everybody should use struct input_stream.
This commit is contained in:
Max Kellermann 2008-10-26 19:54:57 +01:00
parent bbaedb17d5
commit 21b8590b53
13 changed files with 65 additions and 50 deletions

@ -26,7 +26,7 @@
#include <FLAC/metadata.h> #include <FLAC/metadata.h>
void init_FlacData(FlacData * data, struct decoder * decoder, void init_FlacData(FlacData * data, struct decoder * decoder,
InputStream * inStream) struct input_stream *inStream)
{ {
data->time = 0; data->time = 0;
data->position = 0; data->position = 0;

@ -144,14 +144,14 @@ typedef struct {
float total_time; float total_time;
FLAC__uint64 position; FLAC__uint64 position;
struct decoder *decoder; struct decoder *decoder;
InputStream *inStream; struct input_stream *inStream;
ReplayGainInfo *replayGainInfo; ReplayGainInfo *replayGainInfo;
struct tag *tag; struct tag *tag;
} FlacData; } FlacData;
/* initializes a given FlacData struct */ /* initializes a given FlacData struct */
void init_FlacData(FlacData * data, struct decoder * decoder, void init_FlacData(FlacData * data, struct decoder * decoder,
InputStream * inStream); struct input_stream *inStream);
void flac_metadata_common_cb(const FLAC__StreamMetadata * block, void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
FlacData * data); FlacData * data);
void flac_error_common_cb(const char *plugin, void flac_error_common_cb(const char *plugin,

@ -23,7 +23,7 @@
#include "_flac_common.h" #include "_flac_common.h"
#include "../utils.h" #include "../utils.h"
ogg_stream_type ogg_stream_type_detect(InputStream * inStream) ogg_stream_type ogg_stream_type_detect(struct input_stream *inStream)
{ {
/* oggflac detection based on code in ogg123 and this post /* oggflac detection based on code in ogg123 and this post
* http://lists.xiph.org/pipermail/flac/2004-December/000393.html * http://lists.xiph.org/pipermail/flac/2004-December/000393.html

@ -26,6 +26,6 @@
typedef enum _ogg_stream_type { VORBIS, FLAC } ogg_stream_type; typedef enum _ogg_stream_type { VORBIS, FLAC } ogg_stream_type;
ogg_stream_type ogg_stream_type_detect(InputStream * inStream); ogg_stream_type ogg_stream_type_detect(struct input_stream *inStream);
#endif /* _OGG_COMMON_H */ #endif /* _OGG_COMMON_H */

@ -29,7 +29,7 @@
/* all code here is either based on or copied from FAAD2's frontend code */ /* all code here is either based on or copied from FAAD2's frontend code */
typedef struct { typedef struct {
struct decoder *decoder; struct decoder *decoder;
InputStream *inStream; struct input_stream *inStream;
size_t bytesIntoBuffer; size_t bytesIntoBuffer;
size_t bytesConsumed; size_t bytesConsumed;
off_t fileOffset; off_t fileOffset;
@ -174,8 +174,9 @@ static void adtsParse(AacBuffer * b, float *length)
*length = (float)frames / framesPerSec; *length = (float)frames / framesPerSec;
} }
static void initAacBuffer(AacBuffer * b, static void
struct decoder *decoder, InputStream * inStream) initAacBuffer(AacBuffer * b, struct decoder *decoder,
struct input_stream *inStream)
{ {
memset(b, 0, sizeof(AacBuffer)); memset(b, 0, sizeof(AacBuffer));
@ -253,7 +254,7 @@ static float getAacFloatTotalTime(char *file)
faacDecConfigurationPtr config; faacDecConfigurationPtr config;
uint32_t sample_rate; uint32_t sample_rate;
unsigned char channels; unsigned char channels;
InputStream inStream; struct input_stream inStream;
long bread; long bread;
if (openInputStream(&inStream, file) < 0) if (openInputStream(&inStream, file) < 0)
@ -301,7 +302,7 @@ static int getAacTotalTime(char *file)
} }
static int aac_stream_decode(struct decoder * mpd_decoder, static int aac_stream_decode(struct decoder * mpd_decoder,
InputStream *inStream) struct input_stream *inStream)
{ {
float file_time; float file_time;
float totalTime = 0; float totalTime = 0;
@ -454,7 +455,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
int seekPositionFound = 0; */ int seekPositionFound = 0; */
uint16_t bitRate = 0; uint16_t bitRate = 0;
AacBuffer b; AacBuffer b;
InputStream inStream; struct input_stream inStream;
int initialized = 0; int initialized = 0;
if ((totalTime = getAacFloatTotalTime(path)) < 0) if ((totalTime = getAacFloatTotalTime(path)) < 0)

@ -45,7 +45,7 @@ typedef struct {
AVCodecContext *aCodecCtx; AVCodecContext *aCodecCtx;
AVCodec *aCodec; AVCodec *aCodec;
struct decoder *decoder; struct decoder *decoder;
InputStream *input; struct input_stream *input;
struct tag *tag; struct tag *tag;
} BasePtrs; } BasePtrs;
@ -54,7 +54,7 @@ typedef struct {
char url[8]; char url[8];
struct decoder *decoder; struct decoder *decoder;
InputStream *input; struct input_stream *input;
} FopsHelper; } FopsHelper;
/** /**
@ -137,8 +137,9 @@ static int ffmpeg_init(void)
return 0; return 0;
} }
static int ffmpeg_helper(InputStream *input, int (*callback)(BasePtrs *ptrs), static int
BasePtrs *ptrs) ffmpeg_helper(struct input_stream *input, int (*callback)(BasePtrs *ptrs),
BasePtrs *ptrs)
{ {
AVFormatContext *pFormatCtx; AVFormatContext *pFormatCtx;
AVCodecContext *aCodecCtx; AVCodecContext *aCodecCtx;
@ -211,7 +212,8 @@ static int ffmpeg_helper(InputStream *input, int (*callback)(BasePtrs *ptrs),
return ret; return ret;
} }
static bool ffmpeg_try_decode(InputStream *input) static bool
ffmpeg_try_decode(struct input_stream *input)
{ {
int ret; int ret;
if (input->seekable) { if (input->seekable) {
@ -320,7 +322,8 @@ static int ffmpeg_decode_internal(BasePtrs *base)
return 0; return 0;
} }
static int ffmpeg_decode(struct decoder *decoder, InputStream *input) static int
ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
{ {
BasePtrs base; BasePtrs base;
int ret; int ret;
@ -352,7 +355,7 @@ static int ffmpeg_tag_internal(BasePtrs *base)
//no tag reading in ffmpeg, check if playable //no tag reading in ffmpeg, check if playable
static struct tag *ffmpeg_tag(char *file) static struct tag *ffmpeg_tag(char *file)
{ {
InputStream input; struct input_stream input;
BasePtrs base; BasePtrs base;
int ret; int ret;
struct tag *tag = NULL; struct tag *tag = NULL;

@ -301,8 +301,9 @@ static struct tag *flacTagDup(char *file)
return ret; return ret;
} }
static int flac_decode_internal(struct decoder * decoder, static int
InputStream * inStream, int is_ogg) flac_decode_internal(struct decoder * decoder, struct input_stream *inStream,
int is_ogg)
{ {
flac_decoder *flacDec; flac_decoder *flacDec;
FlacData data; FlacData data;
@ -378,7 +379,8 @@ fail:
return 0; return 0;
} }
static int flac_decode(struct decoder * decoder, InputStream * inStream) static int
flac_decode(struct decoder * decoder, struct input_stream *inStream)
{ {
return flac_decode_internal(decoder, inStream, 0); return flac_decode_internal(decoder, inStream, 0);
} }
@ -415,12 +417,14 @@ out:
return ret; return ret;
} }
static int oggflac_decode(struct decoder *decoder, InputStream * inStream) static int
oggflac_decode(struct decoder *decoder, struct input_stream *inStream)
{ {
return flac_decode_internal(decoder, inStream, 1); return flac_decode_internal(decoder, inStream, 1);
} }
static bool oggflac_try_decode(InputStream * inStream) static bool
oggflac_try_decode(struct input_stream *inStream)
{ {
return FLAC_API_SUPPORTS_OGG_FLAC && return FLAC_API_SUPPORTS_OGG_FLAC &&
ogg_stream_type_detect(inStream) == FLAC; ogg_stream_type_detect(inStream) == FLAC;

@ -125,12 +125,12 @@ typedef struct _mp3DecodeData {
int decodedFirstFrame; int decodedFirstFrame;
unsigned long bitRate; unsigned long bitRate;
struct decoder *decoder; struct decoder *decoder;
InputStream *inStream; struct input_stream *inStream;
enum mad_layer layer; enum mad_layer layer;
} mp3DecodeData; } mp3DecodeData;
static void initMp3DecodeData(mp3DecodeData * data, struct decoder *decoder, static void initMp3DecodeData(mp3DecodeData * data, struct decoder *decoder,
InputStream * inStream) struct input_stream *inStream)
{ {
data->muteFrame = MUTEFRAME_NONE; data->muteFrame = MUTEFRAME_NONE;
data->highestFrame = 0; data->highestFrame = 0;
@ -753,7 +753,7 @@ static void mp3DecodeDataFinalize(mp3DecodeData * data)
/* this is primarily used for getting total time for tags */ /* this is primarily used for getting total time for tags */
static int getMp3TotalTime(char *file) static int getMp3TotalTime(char *file)
{ {
InputStream inStream; struct input_stream inStream;
mp3DecodeData data; mp3DecodeData data;
int ret; int ret;
@ -770,9 +770,10 @@ static int getMp3TotalTime(char *file)
return ret; return ret;
} }
static int openMp3FromInputStream(InputStream * inStream, mp3DecodeData * data, static int
struct decoder * decoder, struct tag ** tag, openMp3FromInputStream(struct input_stream *inStream, mp3DecodeData * data,
ReplayGainInfo ** replayGainInfo) struct decoder *decoder, struct tag **tag,
ReplayGainInfo **replayGainInfo)
{ {
initMp3DecodeData(data, decoder, inStream); initMp3DecodeData(data, decoder, inStream);
*tag = NULL; *tag = NULL;
@ -988,7 +989,8 @@ static void initAudioFormatFromMp3DecodeData(mp3DecodeData * data,
af->channels = MAD_NCHANNELS(&(data->frame).header); af->channels = MAD_NCHANNELS(&(data->frame).header);
} }
static int mp3_decode(struct decoder * decoder, InputStream * inStream) static int
mp3_decode(struct decoder * decoder, struct input_stream *inStream)
{ {
mp3DecodeData data; mp3DecodeData data;
struct tag *tag = NULL; struct tag *tag = NULL;

@ -68,15 +68,18 @@ static int mp4_getAACTrack(mp4ff_t * infile)
static uint32_t mp4_inputStreamReadCallback(void *inStream, void *buffer, static uint32_t mp4_inputStreamReadCallback(void *inStream, void *buffer,
uint32_t length) uint32_t length)
{ {
return readFromInputStream((InputStream *) inStream, buffer, length); return readFromInputStream((struct input_stream *) inStream,
buffer, length);
} }
static uint32_t mp4_inputStreamSeekCallback(void *inStream, uint64_t position) static uint32_t mp4_inputStreamSeekCallback(void *inStream, uint64_t position)
{ {
return seekInputStream((InputStream *) inStream, position, SEEK_SET); return seekInputStream((struct input_stream *) inStream,
position, SEEK_SET);
} }
static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream) static int
mp4_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
{ {
mp4ff_t *mp4fh; mp4ff_t *mp4fh;
mp4ff_callback_t *mp4cb; mp4ff_callback_t *mp4cb;
@ -304,7 +307,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
static struct tag *mp4DataDup(char *file, int *mp4MetadataFound) static struct tag *mp4DataDup(char *file, int *mp4MetadataFound)
{ {
struct tag *ret = NULL; struct tag *ret = NULL;
InputStream inStream; struct input_stream inStream;
mp4ff_t *mp4fh; mp4ff_t *mp4fh;
mp4ff_callback_t *callback; mp4ff_callback_t *callback;
int32_t track; int32_t track;

@ -23,7 +23,7 @@
#include <mpcdec/mpcdec.h> #include <mpcdec/mpcdec.h>
typedef struct _MpcCallbackData { typedef struct _MpcCallbackData {
InputStream *inStream; struct input_stream *inStream;
struct decoder *decoder; struct decoder *decoder;
} MpcCallbackData; } MpcCallbackData;
@ -94,7 +94,8 @@ static inline int16_t convertSample(MPC_SAMPLE_FORMAT sample)
return val; return val;
} }
static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream) static int
mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
{ {
mpc_decoder decoder; mpc_decoder decoder;
mpc_reader reader; mpc_reader reader;
@ -240,7 +241,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
static float mpcGetTime(char *file) static float mpcGetTime(char *file)
{ {
InputStream inStream; struct input_stream inStream;
float total_time = -1; float total_time = -1;
mpc_reader reader; mpc_reader reader;

@ -44,7 +44,7 @@
#endif #endif
typedef struct _OggCallbackData { typedef struct _OggCallbackData {
InputStream *inStream; struct input_stream *inStream;
struct decoder *decoder; struct decoder *decoder;
} OggCallbackData; } OggCallbackData;
@ -56,7 +56,7 @@ static size_t ogg_read_cb(void *ptr, size_t size, size_t nmemb, void *vdata)
ret = decoder_read(data->decoder, data->inStream, ptr, size * nmemb); ret = decoder_read(data->decoder, data->inStream, ptr, size * nmemb);
errno = 0; errno = 0;
/*if(ret<0) errno = ((InputStream *)inStream)->error; */ /*if(ret<0) errno = ((struct input_stream *)inStream)->error; */
return ret / size; return ret / size;
} }
@ -200,7 +200,8 @@ static void putOggCommentsIntoOutputBuffer(char *streamName,
} }
/* public */ /* public */
static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream) static int
oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
{ {
OggVorbis_File vf; OggVorbis_File vf;
ov_callbacks callbacks; ov_callbacks callbacks;
@ -360,7 +361,8 @@ static struct tag *oggvorbis_TagDup(char *file)
return ret; return ret;
} }
static bool oggvorbis_try_decode(InputStream * inStream) static bool
oggvorbis_try_decode(struct input_stream *inStream)
{ {
if (!inStream->seekable) if (!inStream->seekable)
/* we cannot seek after the detection, so don't bother /* we cannot seek after the detection, so don't bother

@ -333,13 +333,13 @@ static struct tag *wavpack_tagdup(char *fname)
} }
/* /*
* mpd InputStream <=> WavpackStreamReader wrapper callbacks * mpd input_stream <=> WavpackStreamReader wrapper callbacks
*/ */
/* This struct is needed for per-stream last_byte storage. */ /* This struct is needed for per-stream last_byte storage. */
typedef struct { typedef struct {
struct decoder *decoder; struct decoder *decoder;
InputStream *is; struct input_stream *is;
/* Needed for push_back_byte() */ /* Needed for push_back_byte() */
int last_byte; int last_byte;
} InputStreamPlus; } InputStreamPlus;
@ -403,7 +403,7 @@ static WavpackStreamReader mpd_is_reader = {
static void static void
initInputStreamPlus(InputStreamPlus *isp, struct decoder *decoder, initInputStreamPlus(InputStreamPlus *isp, struct decoder *decoder,
InputStream *is) struct input_stream *is)
{ {
isp->decoder = decoder; isp->decoder = decoder;
isp->is = is; isp->is = is;
@ -413,7 +413,7 @@ initInputStreamPlus(InputStreamPlus *isp, struct decoder *decoder,
/* /*
* Tries to decode the specified stream, and gives true if managed to do it. * Tries to decode the specified stream, and gives true if managed to do it.
*/ */
static bool wavpack_trydecode(InputStream *is) static bool wavpack_trydecode(struct input_stream *is)
{ {
char error[ERRORLEN]; char error[ERRORLEN];
WavpackContext *wpc; WavpackContext *wpc;
@ -433,7 +433,7 @@ static bool wavpack_trydecode(InputStream *is)
} }
static int wavpack_open_wvc(struct decoder *decoder, static int wavpack_open_wvc(struct decoder *decoder,
InputStream *is_wvc) struct input_stream *is_wvc)
{ {
char tmp[MPD_PATH_MAX]; char tmp[MPD_PATH_MAX];
const char *utf8url; const char *utf8url;
@ -498,11 +498,12 @@ static int wavpack_open_wvc(struct decoder *decoder,
/* /*
* Decodes a stream. * Decodes a stream.
*/ */
static int wavpack_streamdecode(struct decoder * decoder, InputStream *is) static int
wavpack_streamdecode(struct decoder * decoder, struct input_stream *is)
{ {
char error[ERRORLEN]; char error[ERRORLEN];
WavpackContext *wpc; WavpackContext *wpc;
InputStream is_wvc; struct input_stream is_wvc;
int open_flags = OPEN_2CH_MAX | OPEN_NORMALIZE /*| OPEN_STREAMING*/; int open_flags = OPEN_2CH_MAX | OPEN_NORMALIZE /*| OPEN_STREAMING*/;
InputStreamPlus isp, isp_wvc; InputStreamPlus isp, isp_wvc;

@ -21,8 +21,6 @@
#include <stddef.h> #include <stddef.h>
typedef struct input_stream InputStream;
struct input_stream { struct input_stream {
int ready; int ready;