Commit b73ecbb0 authored by Max Kellermann's avatar Max Kellermann

input: declare struct input_stream

Provide a struct type which can be forward-declared. The typedef InputStream is deprecated now.
parent bae98f77
......@@ -99,7 +99,7 @@ void decoder_seek_error(struct decoder * decoder)
}
size_t decoder_read(struct decoder *decoder,
InputStream *inStream,
struct input_stream *inStream,
void *buffer, size_t length)
{
size_t nbytes;
......@@ -130,7 +130,8 @@ size_t decoder_read(struct decoder *decoder,
* one.
*/
static enum decoder_command
need_chunks(struct decoder *decoder, InputStream * inStream, int seekable)
need_chunks(struct decoder *decoder,
struct input_stream *inStream, int seekable)
{
if (dc.command == DECODE_COMMAND_STOP)
return DECODE_COMMAND_STOP;
......@@ -153,7 +154,8 @@ need_chunks(struct decoder *decoder, InputStream * inStream, int seekable)
}
enum decoder_command
decoder_data(struct decoder *decoder, InputStream * inStream, int seekable,
decoder_data(struct decoder *decoder,
struct input_stream *inStream, int seekable,
void *dataIn, size_t dataInLen,
float data_time, uint16_t bitRate,
ReplayGainInfo * replayGainInfo)
......
......@@ -66,10 +66,10 @@ struct decoder_plugin {
void (*finish)(void);
/**
* returns true if the InputStream is decodable by the
* InputPlugin, false if not
* returns true if the input stream is decodable by the
* decoder plugin, false if not
*/
bool (*try_decode)(InputStream *);
bool (*try_decode)(struct input_stream *);
/**
* this will be used to decode InputStreams, and is
......@@ -77,7 +77,7 @@ struct decoder_plugin {
*
* returns -1 on error, 0 on success
*/
int (*stream_decode)(struct decoder *, InputStream *);
int (*stream_decode)(struct decoder *, struct input_stream *);
/**
* use this if and only if your InputPlugin can only be passed
......@@ -143,7 +143,7 @@ void decoder_seek_error(struct decoder * decoder);
* command (like SEEK or STOP).
*/
size_t decoder_read(struct decoder *decoder,
InputStream *inStream,
struct input_stream *inStream,
void *buffer, size_t length);
/**
......@@ -154,7 +154,8 @@ size_t decoder_read(struct decoder *decoder,
* send the next chunk
*/
enum decoder_command
decoder_data(struct decoder *decoder, InputStream * inStream, int seekable,
decoder_data(struct decoder *decoder,
struct input_stream *inStream, int seekable,
void *data, size_t datalen, float data_time, uint16_t bitRate,
ReplayGainInfo * replayGainInfo);
......
......@@ -33,7 +33,7 @@ static void decodeStart(void)
struct decoder decoder;
int ret;
bool close_instream = true;
InputStream inStream;
struct input_stream inStream;
struct decoder_plugin *plugin = NULL;
char path_max_fs[MPD_PATH_MAX];
......
......@@ -29,7 +29,7 @@ void initInputStream(void)
inputStream_initHttp();
}
int openInputStream(InputStream * inStream, char *url)
int openInputStream(struct input_stream *inStream, char *url)
{
inStream->ready = 0;
inStream->offset = 0;
......@@ -48,18 +48,18 @@ int openInputStream(InputStream * inStream, char *url)
return -1;
}
int seekInputStream(InputStream * inStream, long offset, int whence)
int seekInputStream(struct input_stream *inStream, long offset, int whence)
{
return inStream->seekFunc(inStream, offset, whence);
}
size_t readFromInputStream(InputStream * inStream, void *ptr, size_t size,
size_t nmemb)
size_t readFromInputStream(struct input_stream *inStream,
void *ptr, size_t size, size_t nmemb)
{
return inStream->readFunc(inStream, ptr, size, nmemb);
}
int closeInputStream(InputStream * inStream)
int closeInputStream(struct input_stream *inStream)
{
if (inStream->mime)
free(inStream->mime);
......@@ -71,12 +71,12 @@ int closeInputStream(InputStream * inStream)
return inStream->closeFunc(inStream);
}
int inputStreamAtEOF(InputStream * inStream)
int inputStreamAtEOF(struct input_stream *inStream)
{
return inStream->atEOFFunc(inStream);
}
int bufferInputStream(InputStream * inStream)
int bufferInputStream(struct input_stream *inStream)
{
return inStream->bufferFunc(inStream);
}
......@@ -21,17 +21,17 @@
#include <stddef.h>
typedef struct _InputStream InputStream;
typedef struct input_stream InputStream;
typedef int (*InputStreamSeekFunc) (InputStream * inStream, long offset,
typedef int (*InputStreamSeekFunc) (struct input_stream *inStream, long offset,
int whence);
typedef size_t(*InputStreamReadFunc) (InputStream * inStream, void *ptr,
typedef size_t(*InputStreamReadFunc) (struct input_stream *inStream, void *ptr,
size_t size, size_t nmemb);
typedef int (*InputStreamCloseFunc) (InputStream * inStream);
typedef int (*InputStreamAtEOFFunc) (InputStream * inStream);
typedef int (*InputStreamBufferFunc) (InputStream * inStream);
typedef int (*InputStreamCloseFunc) (struct input_stream *inStream);
typedef int (*InputStreamAtEOFFunc) (struct input_stream *inStream);
typedef int (*InputStreamBufferFunc) (struct input_stream *inStream);
struct _InputStream {
struct input_stream {
int ready;
int error;
......@@ -57,16 +57,16 @@ int isUrlSaneForInputStream(char *url);
/* if an error occurs for these 3 functions, then -1 is returned and errno
for the input stream is set */
int openInputStream(InputStream * inStream, char *url);
int seekInputStream(InputStream * inStream, long offset, int whence);
int closeInputStream(InputStream * inStream);
int inputStreamAtEOF(InputStream * inStream);
int openInputStream(struct input_stream *inStream, char *url);
int seekInputStream(struct input_stream *inStream, long offset, int whence);
int closeInputStream(struct input_stream *inStream);
int inputStreamAtEOF(struct input_stream *inStream);
/* return value: -1 is error, 1 inidicates stuff was buffered, 0 means nothing
was buffered */
int bufferInputStream(InputStream * inStream);
int bufferInputStream(struct input_stream *inStream);
size_t readFromInputStream(InputStream * inStream, void *ptr, size_t size,
size_t nmemb);
size_t readFromInputStream(struct input_stream *inStream,
void *ptr, size_t size, size_t nmemb);
#endif
......@@ -25,7 +25,7 @@ void inputStream_initFile(void)
{
}
int inputStream_fileOpen(InputStream * inStream, char *filename)
int inputStream_fileOpen(struct input_stream *inStream, char *filename)
{
FILE *fp;
......@@ -57,7 +57,8 @@ int inputStream_fileOpen(InputStream * inStream, char *filename)
return 0;
}
int inputStream_fileSeek(InputStream * inStream, long offset, int whence)
int inputStream_fileSeek(struct input_stream *inStream, long offset,
int whence)
{
if (fseek((FILE *) inStream->data, offset, whence) == 0) {
inStream->offset = ftell((FILE *) inStream->data);
......@@ -69,7 +70,8 @@ int inputStream_fileSeek(InputStream * inStream, long offset, int whence)
return 0;
}
size_t inputStream_fileRead(InputStream * inStream, void *ptr, size_t size,
size_t inputStream_fileRead(struct input_stream *inStream,
void *ptr, size_t size,
size_t nmemb)
{
size_t readSize;
......@@ -86,7 +88,7 @@ size_t inputStream_fileRead(InputStream * inStream, void *ptr, size_t size,
return readSize;
}
int inputStream_fileClose(InputStream * inStream)
int inputStream_fileClose(struct input_stream *inStream)
{
if (fclose((FILE *) inStream->data) < 0) {
inStream->error = errno;
......@@ -96,7 +98,7 @@ int inputStream_fileClose(InputStream * inStream)
return 0;
}
int inputStream_fileAtEOF(InputStream * inStream)
int inputStream_fileAtEOF(struct input_stream *inStream)
{
if (feof((FILE *) inStream->data))
return 1;
......@@ -108,7 +110,7 @@ int inputStream_fileAtEOF(InputStream * inStream)
return 0;
}
int inputStream_fileBuffer(mpd_unused InputStream * inStream)
int inputStream_fileBuffer(mpd_unused struct input_stream *inStream)
{
return 0;
}
......@@ -23,17 +23,19 @@
void inputStream_initFile(void);
int inputStream_fileOpen(InputStream * inStream, char *filename);
int inputStream_fileOpen(struct input_stream *inStream, char *filename);
int inputStream_fileSeek(InputStream * inStream, long offset, int whence);
int inputStream_fileSeek(struct input_stream *inStream, long offset,
int whence);
size_t inputStream_fileRead(InputStream * inStream, void *ptr, size_t size,
size_t inputStream_fileRead(struct input_stream *inStream,
void *ptr, size_t size,
size_t nmemb);
int inputStream_fileClose(InputStream * inStream);
int inputStream_fileClose(struct input_stream *inStream);
int inputStream_fileAtEOF(InputStream * inStream);
int inputStream_fileAtEOF(struct input_stream *inStream);
int inputStream_fileBuffer(InputStream * inStream);
int inputStream_fileBuffer(struct input_stream *inStream);
#endif
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