"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/stream.c" between
libtimidity-0.2.6.tar.gz and libtimidity-0.2.7.tar.gz

About: libTiMidity is a MIDI to WAVE converter library that uses Gravis Ultrasound-compatible patch files to generate digital audio data from General MIDI files.

stream.c  (libtimidity-0.2.6):stream.c  (libtimidity-0.2.7)
skipping to change at line 41 skipping to change at line 41
#include "config.h" #include "config.h"
#endif #endif
#include "string.h" #include "string.h"
#include "timidity_internal.h" #include "timidity_internal.h"
#include "common.h" #include "common.h"
struct _MidIStream struct _MidIStream
{ {
MidIStreamReadFunc read; MidIStreamReadFunc read_fn;
MidIStreamSeekFunc seek; MidIStreamSeekFunc seek_fn;
MidIStreamTellFunc tell; MidIStreamTellFunc tell_fn;
MidIStreamCloseFunc close; MidIStreamCloseFunc close_fn;
void *ctx; void *ctx;
}; };
typedef struct StdIOContext typedef struct StdIOContext
{ {
FILE *fp; FILE *fp;
int autoclose; int autoclose;
} StdIOContext; } StdIOContext;
static size_t static size_t
skipping to change at line 172 skipping to change at line 172
ctx = (StdIOContext *) timi_malloc(sizeof(StdIOContext)); ctx = (StdIOContext *) timi_malloc(sizeof(StdIOContext));
if (ctx == NULL) if (ctx == NULL)
{ {
timi_free (stream); timi_free (stream);
return NULL; return NULL;
} }
ctx->fp = fp; ctx->fp = fp;
ctx->autoclose = autoclose; ctx->autoclose = autoclose;
stream->ctx = ctx; stream->ctx = ctx;
stream->read = stdio_istream_read; stream->read_fn = stdio_istream_read;
stream->seek = stdio_istream_seek; stream->seek_fn = stdio_istream_seek;
stream->tell = stdio_istream_tell; stream->tell_fn = stdio_istream_tell;
stream->close = stdio_istream_close; stream->close_fn = stdio_istream_close;
return stream; return stream;
} }
MidIStream * MidIStream *
mid_istream_open_file (const char *file) mid_istream_open_file (const char *file)
{ {
FILE *fp; FILE *fp;
fp = fopen (file, "rb"); fp = fopen (file, "rb");
skipping to change at line 213 skipping to change at line 213
if (ctx == NULL) if (ctx == NULL)
{ {
timi_free (stream); timi_free (stream);
return NULL; return NULL;
} }
ctx->base = (sint8 *) mem; ctx->base = (sint8 *) mem;
ctx->current = (sint8 *) mem; ctx->current = (sint8 *) mem;
ctx->end = ((sint8 *) mem) + size; ctx->end = ((sint8 *) mem) + size;
stream->ctx = ctx; stream->ctx = ctx;
stream->read = mem_istream_read; stream->read_fn = mem_istream_read;
stream->seek = mem_istream_seek; stream->seek_fn = mem_istream_seek;
stream->tell = mem_istream_tell; stream->tell_fn = mem_istream_tell;
stream->close = mem_istream_close; stream->close_fn = mem_istream_close;
return stream; return stream;
} }
MidIStream * MidIStream *
mid_istream_open_callbacks (MidIStreamReadFunc read, mid_istream_open_callbacks (MidIStreamReadFunc readfn,
MidIStreamSeekFunc seek, MidIStreamSeekFunc seekfn,
MidIStreamTellFunc tell, MidIStreamTellFunc tellfn,
MidIStreamCloseFunc close, void *context) MidIStreamCloseFunc closefn, void *context)
{ {
MidIStream *stream; MidIStream *stream;
stream = (MidIStream *) timi_malloc(sizeof(MidIStream)); stream = (MidIStream *) timi_malloc(sizeof(MidIStream));
if (stream == NULL) if (stream == NULL)
return NULL; return NULL;
stream->ctx = context; stream->ctx = context;
stream->read = read; stream->read_fn = readfn;
stream->seek = seek; stream->seek_fn = seekfn;
stream->tell = tell; stream->tell_fn = tellfn;
stream->close = close; stream->close_fn = closefn;
return stream; return stream;
} }
size_t size_t
mid_istream_read (MidIStream * stream, void *ptr, size_t size, size_t nmemb) mid_istream_read (MidIStream * stream, void *ptr, size_t size, size_t nmemb)
{ {
return stream->read (stream->ctx, ptr, size, nmemb); return stream->read_fn (stream->ctx, ptr, size, nmemb);
} }
int int
mid_istream_seek (MidIStream * stream, long offset, int whence) mid_istream_seek (MidIStream * stream, long offset, int whence)
{ {
return stream->seek (stream->ctx, offset, whence); return stream->seek_fn (stream->ctx, offset, whence);
} }
long long
mid_istream_tell (MidIStream * stream) mid_istream_tell (MidIStream * stream)
{ {
return stream->tell (stream->ctx); return stream->tell_fn (stream->ctx);
} }
int int
mid_istream_skip (MidIStream * stream, long len) mid_istream_skip (MidIStream * stream, long len)
{ {
if (stream->seek (stream->ctx, len, SEEK_CUR) < 0) if (stream->seek_fn (stream->ctx, len, SEEK_CUR) < 0)
return -1; return -1;
return 0; return 0;
} }
int int
mid_istream_close (MidIStream * stream) mid_istream_close (MidIStream * stream)
{ {
int ret = stream->close (stream->ctx); int ret = stream->close_fn (stream->ctx);
timi_free (stream); timi_free (stream);
return ret; return ret;
} }
 End of changes. 10 change blocks. 
25 lines changed or deleted 25 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)