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