aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-17 17:53:48 +0200
committerMax Kellermann <max@duempel.org>2008-10-17 17:53:48 +0200
commitb73ecbb073625b56aaef33f2fa7f102fdc9a6247 (patch)
tree667ed6c913b812765cf057eb3030109a62d14404
parentbae98f777b5e97ccd25d79d60a28f75116308626 (diff)
downloadmpd-b73ecbb073625b56aaef33f2fa7f102fdc9a6247.tar.gz
mpd-b73ecbb073625b56aaef33f2fa7f102fdc9a6247.tar.xz
mpd-b73ecbb073625b56aaef33f2fa7f102fdc9a6247.zip
input: declare struct input_stream
Provide a struct type which can be forward-declared. The typedef InputStream is deprecated now.
Diffstat (limited to '')
-rw-r--r--src/decoder_api.c8
-rw-r--r--src/decoder_api.h13
-rw-r--r--src/decoder_thread.c2
-rw-r--r--src/inputStream.c14
-rw-r--r--src/inputStream.h28
-rw-r--r--src/inputStream_file.c14
-rw-r--r--src/inputStream_file.h14
7 files changed, 50 insertions, 43 deletions
diff --git a/src/decoder_api.c b/src/decoder_api.c
index 2d2bed796..933ee7106 100644
--- a/src/decoder_api.c
+++ b/src/decoder_api.c
@@ -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)
diff --git a/src/decoder_api.h b/src/decoder_api.h
index d0985f123..7d8a1e567 100644
--- a/src/decoder_api.h
+++ b/src/decoder_api.h
@@ -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);
diff --git a/src/decoder_thread.c b/src/decoder_thread.c
index 32ab972c8..c8f19a33f 100644
--- a/src/decoder_thread.c
+++ b/src/decoder_thread.c
@@ -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];
diff --git a/src/inputStream.c b/src/inputStream.c
index 3ea62fb0a..5805018f2 100644
--- a/src/inputStream.c
+++ b/src/inputStream.c
@@ -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);
}
diff --git a/src/inputStream.h b/src/inputStream.h
index 08a72b3d6..31216ef2c 100644
--- a/src/inputStream.h
+++ b/src/inputStream.h
@@ -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
diff --git a/src/inputStream_file.c b/src/inputStream_file.c
index 7110eb2e8..eea1d11aa 100644
--- a/src/inputStream_file.c
+++ b/src/inputStream_file.c
@@ -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;
}
diff --git a/src/inputStream_file.h b/src/inputStream_file.h
index fad7ac26e..c0f56be04 100644
--- a/src/inputStream_file.h
+++ b/src/inputStream_file.h
@@ -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