Mercurial > audlegacy
diff Plugins/Input/timidity/libtimidity/instrum.c @ 480:c1dfb4b13be8 trunk
[svn] Use the VFS layer.
author | chainsaw |
---|---|
date | Sat, 21 Jan 2006 07:12:02 -0800 |
parents | d1762728ea4b |
children | d539e5c5f730 |
line wrap: on
line diff
--- a/Plugins/Input/timidity/libtimidity/instrum.c Sat Jan 21 06:32:50 2006 -0800 +++ b/Plugins/Input/timidity/libtimidity/instrum.c Sat Jan 21 07:12:02 2006 -0800 @@ -27,7 +27,7 @@ # include <config.h> #endif -#include <stdio.h> +#include "libaudacious/vfs.h" #include <string.h> #include <stdlib.h> @@ -167,7 +167,7 @@ { MidInstrument *ip; MidSample *sp; - FILE *fp; + VFSFile *fp; char tmp[1024]; int i,j,noluck=0; static char *patch_ext[] = PATCH_EXT_LIST; @@ -205,7 +205,7 @@ /* Read some headers and do cursory sanity checks. There are loads of magic offsets. This could be rewritten... */ - if ((239 != fread(tmp, 1, 239, fp)) || + if ((239 != vfs_fread(tmp, 1, 239, fp)) || (memcmp(tmp, "GF1PATCH110\0ID#000002", 22) && memcmp(tmp, "GF1PATCH100\0ID#000002", 22))) /* don't know what the differences are */ @@ -239,18 +239,18 @@ uint8 tmpchar; #define READ_CHAR(thing) \ - if (1 != fread(&tmpchar, 1, 1, fp)) goto fail; \ + if (1 != vfs_fread(&tmpchar, 1, 1, fp)) goto fail; \ thing = tmpchar; #define READ_SHORT(thing) \ - if (1 != fread(&tmpshort, 2, 1, fp)) goto fail; \ + if (1 != vfs_fread(&tmpshort, 2, 1, fp)) goto fail; \ thing = SWAPLE16(tmpshort); #define READ_LONG(thing) \ - if (1 != fread(&tmplong, 4, 1, fp)) goto fail; \ + if (1 != vfs_fread(&tmplong, 4, 1, fp)) goto fail; \ thing = SWAPLE32(tmplong); - fseek(fp, 7, SEEK_CUR); /* Skip the wave name */ + vfs_fseek(fp, 7, SEEK_CUR); /* Skip the wave name */ - if (1 != fread(&fractions, 1, 1, fp)) + if (1 != vfs_fread(&fractions, 1, 1, fp)) { fail: DEBUG_MSG("Error reading sample %d\n", i); @@ -272,7 +272,7 @@ READ_LONG(sp->root_freq); sp->low_vel = 0; sp->high_vel = 127; - fseek(fp, 2, SEEK_CUR); /* Why have a "root frequency" and then + vfs_fseek(fp, 2, SEEK_CUR); /* Why have a "root frequency" and then * "tuning"?? */ READ_CHAR(tmp[0]); @@ -283,7 +283,7 @@ sp->panning=(uint8)(panning & 0x7F); /* envelope, tremolo, and vibrato */ - if (18 != fread(tmp, 1, 18, fp)) goto fail; + if (18 != vfs_fread(tmp, 1, 18, fp)) goto fail; if (!tmp[13] || !tmp[14]) { @@ -321,7 +321,7 @@ READ_CHAR(sp->modes); - fseek(fp, 40, SEEK_CUR); /* skip the useless scale frequency, scale + vfs_fseek(fp, 40, SEEK_CUR); /* skip the useless scale frequency, scale factor (what's it mean?), and reserved space */ @@ -393,7 +393,7 @@ /* Then read the sample data */ sp->data = safe_malloc(sp->data_length); - if (1 != fread(sp->data, sp->data_length, 1, fp)) + if (1 != vfs_fread(sp->data, sp->data_length, 1, fp)) goto fail; if (!(sp->modes & MODES_16BIT)) /* convert to 16-bit data */ @@ -508,7 +508,7 @@ } } - fclose(fp); + vfs_fclose(fp); return ip; }