gzdoom/dumb/src/helpers/stdfile.c
Randy Heit 01f59fa85f - Added an alternate module replay engine that uses foo_dumb's replayer, a
heavily customized version of DUMB (Dynamic Universal Music Bibliotheque).
  It has been slightly modified by me:
  * Added support for Ogg Vorbis-compressed samples in XM files ala FMOD.
  * Removed excessive mallocs from the replay core.
  * Rerolled the loops in resample.c. Unrolling them made the object file
    ~250k large while providing little benefit. Even at ~100k, I think it's
    still larger than it ought to be, but I'll live with it for now.
  Other than that, it's essentially the same thing you'd hear in foobar2000,
  minus some subsong detection features. Release builds of the library look
  like they might even be slightly faster than FMOD, which is a plus.
- Fixed: Timidity::font_add() did not release the file reader it created.
- Fixed: The SF2 loader did not free the sample headers in its destructor.


SVN r995 (trunk)
2008-05-29 23:33:07 +00:00

93 lines
2.1 KiB
C

/* _______ ____ __ ___ ___
* \ _ \ \ / \ / \ \ / / ' ' '
* | | \ \ | | || | \/ | . .
* | | | | | | || ||\ /| |
* | | | | | | || || \/ | | ' ' '
* | | | | | | || || | | . .
* | |_/ / \ \__// || | |
* /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque
* / \
* / . \
* stdfile.c - stdio file input module. / / \ \
* | < / \_
* By entheh. | \/ /\ /
* \_ / > /
* | \ / /
* | ' /
* \__/
*/
#include <stdio.h>
#include "dumb.h"
static void *dumb_stdfile_open(const char *filename)
{
return fopen(filename, "rb");
}
static int dumb_stdfile_skip(void *f, int32 n)
{
return fseek(f, n, SEEK_CUR);
}
static int dumb_stdfile_getc(void *f)
{
return fgetc(f);
}
static int32 dumb_stdfile_getnc(char *ptr, int32 n, void *f)
{
return (int32)fread(ptr, 1, n, f);
}
static void dumb_stdfile_close(void *f)
{
fclose(f);
}
static const DUMBFILE_SYSTEM stdfile_dfs = {
&dumb_stdfile_open,
&dumb_stdfile_skip,
&dumb_stdfile_getc,
&dumb_stdfile_getnc,
&dumb_stdfile_close
};
void DUMBEXPORT dumb_register_stdfiles(void)
{
register_dumbfile_system(&stdfile_dfs);
}
static const DUMBFILE_SYSTEM stdfile_dfs_leave_open = {
NULL,
&dumb_stdfile_skip,
&dumb_stdfile_getc,
&dumb_stdfile_getnc,
NULL
};
DUMBFILE *DUMBEXPORT dumbfile_open_stdfile(FILE *p)
{
DUMBFILE *d = dumbfile_open_ex(p, &stdfile_dfs_leave_open);
return d;
}