Permalink
Browse files

Use VFSFile member functions.

  • Loading branch information...
1 parent f91f908 commit ae0cdf6a98dc7dc91d6156d07a62b0a2f3d8479d @jlindgren90 jlindgren90 committed Sep 17, 2014
Showing with 576 additions and 690 deletions.
  1. +28 −31 src/aac-raw/aac.cc
  2. +6 −6 src/adplug/adplug-xmms.cc
  3. +3 −3 src/adplug/adplug-xmms.h
  4. +1 −1 src/adplug/core/a2m.cc
  5. +1 −2 src/adplug/core/a2m.h
  6. +2 −2 src/adplug/core/adl.cc
  7. +1 −1 src/adplug/core/adl.h
  8. +3 −3 src/adplug/core/adplug.cc
  9. +1 −1 src/adplug/core/adplug.h
  10. +3 −4 src/adplug/core/adtrack.cc
  11. +1 −1 src/adplug/core/adtrack.h
  12. +1 −1 src/adplug/core/amd.cc
  13. +1 −1 src/adplug/core/amd.h
  14. +1 −1 src/adplug/core/bam.cc
  15. +1 −1 src/adplug/core/bam.h
  16. +26 −34 src/adplug/core/binio_virtual.h
  17. +1 −1 src/adplug/core/cff.cc
  18. +1 −1 src/adplug/core/cff.h
  19. +1 −1 src/adplug/core/cmf.cc
  20. +1 −1 src/adplug/core/cmf.h
  21. +2 −2 src/adplug/core/d00.cc
  22. +1 −1 src/adplug/core/d00.h
  23. +1 −1 src/adplug/core/dfm.cc
  24. +1 −1 src/adplug/core/dfm.h
  25. +2 −2 src/adplug/core/dmo.cc
  26. +1 −1 src/adplug/core/dmo.h
  27. +1 −1 src/adplug/core/dro.cc
  28. +1 −1 src/adplug/core/dro.h
  29. +1 −1 src/adplug/core/dro2.cc
  30. +1 −1 src/adplug/core/dro2.h
  31. +1 −1 src/adplug/core/dtm.cc
  32. +1 −1 src/adplug/core/dtm.h
  33. +1 −1 src/adplug/core/fmc.cc
  34. +1 −1 src/adplug/core/fmc.h
  35. +4 −2 src/adplug/core/fprovide.cc
  36. +2 −2 src/adplug/core/fprovide.h
  37. +3 −3 src/adplug/core/hsc.cc
  38. +1 −1 src/adplug/core/hsc.h
  39. +2 −2 src/adplug/core/hsp.cc
  40. +1 −1 src/adplug/core/hsp.h
  41. +3 −3 src/adplug/core/imf.cc
  42. +1 −1 src/adplug/core/imf.h
  43. +2 −2 src/adplug/core/jbm.cc
  44. +1 −1 src/adplug/core/jbm.h
  45. +3 −4 src/adplug/core/ksm.cc
  46. +1 −1 src/adplug/core/ksm.h
  47. +2 −2 src/adplug/core/lds.cc
  48. +1 −1 src/adplug/core/lds.h
  49. +1 −1 src/adplug/core/mad.cc
  50. +1 −1 src/adplug/core/mad.h
  51. +3 −7 src/adplug/core/mid.cc
  52. +1 −1 src/adplug/core/mid.h
  53. +2 −2 src/adplug/core/mkj.cc
  54. +1 −1 src/adplug/core/mkj.h
  55. +1 −1 src/adplug/core/msc.cc
  56. +1 −1 src/adplug/core/msc.h
  57. +1 −1 src/adplug/core/mtk.cc
  58. +1 −1 src/adplug/core/mtk.h
  59. +1 −1 src/adplug/core/player.h
  60. +1 −1 src/adplug/core/rad.cc
  61. +1 −1 src/adplug/core/rad.h
  62. +1 −1 src/adplug/core/raw.cc
  63. +1 −1 src/adplug/core/raw.h
  64. +2 −2 src/adplug/core/rix.cc
  65. +1 −1 src/adplug/core/rix.h
  66. +3 −4 src/adplug/core/rol.cc
  67. +1 −1 src/adplug/core/rol.h
  68. +1 −1 src/adplug/core/s3m.cc
  69. +1 −1 src/adplug/core/s3m.h
  70. +2 −2 src/adplug/core/sa2.cc
  71. +1 −1 src/adplug/core/sa2.h
  72. +1 −1 src/adplug/core/sng.cc
  73. +1 −1 src/adplug/core/sng.h
  74. +1 −1 src/adplug/core/u6m.cc
  75. +1 −2 src/adplug/core/u6m.h
  76. +1 −1 src/adplug/core/xad.cc
  77. +1 −1 src/adplug/core/xad.h
  78. +1 −1 src/adplug/core/xsm.cc
  79. +1 −1 src/adplug/core/xsm.h
  80. +10 −13 src/amidi-plug/amidi-plug.cc
  81. +0 −1 src/amidi-plug/i_configure.cc
  82. +13 −12 src/amidi-plug/i_midi.cc
  83. +2 −1 src/amidi-plug/i_midi.h
  84. +1 −1 src/asx/asx.cc
  85. +6 −6 src/asx3/asx3.cc
  86. +2 −2 src/audpl/audpl.cc
  87. +7 −7 src/cdaudio-ng/cdaudio-ng.cc
  88. +3 −3 src/console/Audacious_Driver.cc
  89. +13 −7 src/console/Vfs_File.cc
  90. +2 −2 src/console/plugin.cc
  91. +2 −2 src/cue/cue.cc
  92. +12 −12 src/ffaudio/ffaudio-core.cc
  93. +6 −6 src/ffaudio/ffaudio-io.cc
  94. +2 −2 src/ffaudio/ffaudio-stdinc.h
  95. +7 −7 src/ffaudio/itunes-cover.cc
  96. +10 −13 src/filewriter/filewriter.cc
  97. +1 −1 src/filewriter/filewriter.h
  98. +4 −4 src/filewriter/flac.cc
  99. +2 −2 src/filewriter/mp3.cc
  100. +4 −4 src/filewriter/wav.cc
  101. +3 −3 src/flacng/flacng.h
  102. +13 −13 src/flacng/metadata.cc
  103. +4 −10 src/flacng/plugin.cc
  104. +6 −12 src/flacng/seekable_stream_callbacks.cc
  105. +9 −5 src/m3u/m3u.cc
  106. +3 −3 src/metronom/metronom.cc
  107. +3 −6 src/modplug/archive/arch_raw.cc
  108. +1 −1 src/modplug/archive/arch_raw.h
  109. +6 −6 src/modplug/modplugbmp.cc
  110. +1 −1 src/modplug/modplugbmp.h
  111. +3 −3 src/modplug/plugin.cc
  112. +3 −3 src/modplug/plugin.h
  113. +20 −22 src/mpg123/mpg123.cc
  114. +8 −5 src/pls/pls.cc
  115. +8 −8 src/psf/plugin.cc
  116. +6 −6 src/sid/xmms-sid.cc
  117. +12 −5 src/sid/xs_sidplay2.cc
  118. +10 −11 src/skins/preset-browser.cc
  119. +4 −2 src/skins/ui_equalizer.cc
  120. +2 −4 src/skins/ui_skin.cc
  121. +3 −10 src/skins/ui_skin_load_ini.cc
  122. +4 −5 src/skins/util.cc
  123. +1 −1 src/skins/util.h
  124. +11 −15 src/sndfile/plugin.cc
  125. +3 −3 src/tonegen/tonegen.cc
  126. +19 −31 src/vorbis/vcedit.cc
  127. +3 −12 src/vorbis/vcedit.h
  128. +9 −11 src/vorbis/vcupdate.cc
  129. +20 −19 src/vorbis/vorbis.cc
  130. +1 −1 src/vorbis/vorbis.h
  131. +3 −4 src/vtx/ay8912.cc
  132. +1 −2 src/vtx/ayemu_vtxfile.h
  133. +2 −1 src/vtx/info.cc
  134. +6 −3 src/vtx/lh5dec.cc
  135. +16 −18 src/vtx/vtx.cc
  136. +0 −1 src/vtx/vtx.h
  137. +37 −80 src/vtx/vtxfile.cc
  138. +24 −37 src/wavpack/wavpack.cc
  139. +8 −8 src/xsf/plugin.cc
  140. +6 −8 src/xspf/xspf.cc
View
@@ -78,14 +78,14 @@ static int find_aac_header (unsigned char * data, int length, int * size)
return -1;
}
-static bool parse_aac_stream (const char * filename, VFSFile * stream)
+static bool parse_aac_stream (const char * filename, VFSFile & stream)
{
unsigned char data[8192];
int offset, found, inner, size;
size = 0; /* avoid bogus uninitialized variable warning */
- if (vfs_fread (data, 1, sizeof data, stream) != sizeof data)
+ if (stream.fread (data, 1, sizeof data) != sizeof data)
{
PROBE_DEBUG ("Read failed.\n");
return false;
@@ -128,13 +128,13 @@ static int aac_probe (unsigned char * buf, int len)
/* Gets info (some approximated) from an AAC/ADTS file. <length> is
* milliseconds, <bitrate> is kilobits per second. Any parameters that cannot
* be read are set to -1. */
-static void calc_aac_info (VFSFile * handle, int * length, int * bitrate,
+static void calc_aac_info (VFSFile & handle, int * length, int * bitrate,
int * samplerate, int * channels)
{
NeAACDecHandle decoder;
NeAACDecFrameInfo frame;
bool initted = false;
- int size = vfs_fsize (handle);
+ int size = handle.fsize ();
unsigned char buffer[BUFFER_SIZE];
int offset = 0, filled = 0;
int found, bytes_used = 0, time_used = 0;
@@ -147,7 +147,7 @@ static void calc_aac_info (VFSFile * handle, int * length, int * bitrate,
*channels = -1;
/* look for a representative bitrate in the middle of the file */
- if (size > 0 && vfs_fseek (handle, size / 2, VFS_SEEK_SET))
+ if (size < 0 || handle.fseek (size / 2, VFS_SEEK_SET) < 0)
goto DONE;
for (found = 0; found < 32; found++)
@@ -157,7 +157,7 @@ static void calc_aac_info (VFSFile * handle, int * length, int * bitrate,
memmove (buffer, buffer + offset, filled);
offset = 0;
- if (vfs_fread (buffer + filled, 1, BUFFER_SIZE - filled, handle)
+ if (handle.fread (buffer + filled, 1, BUFFER_SIZE - filled)
!= BUFFER_SIZE - filled)
{
PROBE_DEBUG ("Read failed.\n");
@@ -233,36 +233,32 @@ static void calc_aac_info (VFSFile * handle, int * length, int * bitrate,
NeAACDecClose (decoder);
}
-static Tuple aac_get_tuple (const char * filename, VFSFile * handle)
+static Tuple aac_get_tuple (const char * filename, VFSFile & handle)
{
Tuple tuple;
int length, bitrate, samplerate, channels;
tuple.set_filename (filename);
tuple.set_str (FIELD_CODEC, "MPEG-2/4 AAC");
- if (!vfs_is_remote (filename))
- {
- calc_aac_info (handle, &length, &bitrate, &samplerate, &channels);
-
- if (length > 0)
- tuple.set_int (FIELD_LENGTH, length);
+ calc_aac_info (handle, &length, &bitrate, &samplerate, &channels);
- if (bitrate > 0)
- tuple.set_int (FIELD_BITRATE, bitrate);
- }
+ if (length > 0)
+ tuple.set_int (FIELD_LENGTH, length);
+ if (bitrate > 0)
+ tuple.set_int (FIELD_BITRATE, bitrate);
tuple.fetch_stream_info (handle);
return tuple;
}
-static void aac_seek (VFSFile * file, NeAACDecHandle dec, int time, int len,
+static void aac_seek (VFSFile & file, NeAACDecHandle dec, int time, int len,
void * buf, int size, int * buflen)
{
/* == ESTIMATE BYTE OFFSET == */
- int64_t total = vfs_fsize (file);
+ int64_t total = file.fsize ();
if (total < 0)
{
AUDERR ("File is not seekable.\n");
@@ -271,10 +267,10 @@ static void aac_seek (VFSFile * file, NeAACDecHandle dec, int time, int len,
/* == SEEK == */
- if (vfs_fseek (file, total * time / len, VFS_SEEK_SET))
+ if (file.fseek (total * time / len, VFS_SEEK_SET))
return;
- * buflen = vfs_fread (buf, 1, size, file);
+ * buflen = file.fread (buf, 1, size);
/* == FIND FRAME HEADER == */
@@ -291,7 +287,7 @@ static void aac_seek (VFSFile * file, NeAACDecHandle dec, int time, int len,
{
* buflen -= used;
memmove (buf, (char *) buf + used, * buflen);
- * buflen += vfs_fread ((char *) buf + * buflen, 1, size - * buflen, file);
+ * buflen += file.fread ((char *) buf + * buflen, 1, size - * buflen);
}
/* == START DECODING == */
@@ -303,11 +299,11 @@ static void aac_seek (VFSFile * file, NeAACDecHandle dec, int time, int len,
{
* buflen -= used;
memmove (buf, (char *) buf + used, * buflen);
- * buflen += vfs_fread ((char *) buf + * buflen, 1, size - * buflen, file);
+ * buflen += file.fread ((char *) buf + * buflen, 1, size - * buflen);
}
}
-static bool my_decode_aac (const char * filename, VFSFile * file)
+static bool my_decode_aac (const char * filename, VFSFile & file)
{
NeAACDecHandle decoder = 0;
NeAACDecConfigurationPtr decoder_config;
@@ -337,20 +333,21 @@ static bool my_decode_aac (const char * filename, VFSFile * file)
unsigned char buf[BUFFER_SIZE];
int buflen;
- buflen = vfs_fread (buf, 1, sizeof buf, file);
+ buflen = file.fread (buf, 1, sizeof buf);
/* == SKIP ID3 TAG == */
if (buflen >= 10 && ! strncmp ((char *) buf, "ID3", 3))
{
- if (vfs_fseek (file, 10 + (buf[6] << 21) + (buf[7] << 14) + (buf[8] <<
- 7) + buf[9], VFS_SEEK_SET))
+ int tagsize = 10 + (buf[6] << 21) + (buf[7] << 14) + (buf[8] << 7) + buf[9];
+
+ if (file.fseek (tagsize, VFS_SEEK_SET))
{
AUDERR ("Failed to seek past ID3v2 tag.\n");
goto ERR_CLOSE_DECODER;
}
- buflen = vfs_fread (buf, 1, sizeof buf, file);
+ buflen = file.fread (buf, 1, sizeof buf);
}
/* == FIND FRAME HEADER == */
@@ -368,7 +365,7 @@ static bool my_decode_aac (const char * filename, VFSFile * file)
{
buflen -= used;
memmove (buf, buf + used, buflen);
- buflen += vfs_fread (buf + buflen, 1, sizeof buf - buflen, file);
+ buflen += file.fread (buf + buflen, 1, sizeof buf - buflen);
}
/* == START DECODING == */
@@ -377,7 +374,7 @@ static bool my_decode_aac (const char * filename, VFSFile * file)
{
buflen -= used;
memmove (buf, buf + used, buflen);
- buflen += vfs_fread (buf + buflen, 1, sizeof buf - buflen, file);
+ buflen += file.fread (buf + buflen, 1, sizeof buf - buflen);
}
/* == CHECK FOR METADATA == */
@@ -432,7 +429,7 @@ static bool my_decode_aac (const char * filename, VFSFile * file)
used = 1 + aac_probe (buf + 1, buflen - 1);
buflen -= used;
memmove (buf, buf + used, buflen);
- buflen += vfs_fread (buf + buflen, 1, sizeof buf - buflen, file);
+ buflen += file.fread (buf + buflen, 1, sizeof buf - buflen);
}
continue;
@@ -442,7 +439,7 @@ static bool my_decode_aac (const char * filename, VFSFile * file)
{
buflen -= used;
memmove (buf, buf + used, buflen);
- buflen += vfs_fread (buf + buflen, 1, sizeof buf - buflen, file);
+ buflen += file.fread (buf + buflen, 1, sizeof buf - buflen);
}
/* == PLAY THE SOUND == */
@@ -102,14 +102,14 @@ dbg_printf (const char *fmt, ...)
#endif
static CPlayer *
-factory (VFSFile * fd, Copl * newopl)
+factory (VFSFile & fd, Copl * newopl)
{
return CAdPlug::factory (fd, newopl, conf.players);
}
/***** Main player (!! threaded !!) *****/
-Tuple adplug_get_tuple (const char * filename, VFSFile * fd)
+Tuple adplug_get_tuple (const char * filename, VFSFile & fd)
{
Tuple tuple;
CSilentopl tmpopl;
@@ -143,7 +143,7 @@ Tuple adplug_get_tuple (const char * filename, VFSFile * fd)
// Define sampsize macro (only usable inside play_loop()!)
#define sampsize ((bit16 ? 2 : 1) * (stereo ? 2 : 1))
-static bool play_loop (const char * filename, VFSFile * fd)
+static bool play_loop (const char * filename, VFSFile & fd)
/* Main playback thread. Takes the filename to play as argument. */
{
dbg_printf ("play_loop(\"%s\"): ", filename);
@@ -249,7 +249,7 @@ static bool play_loop (const char * filename, VFSFile * fd)
/***** Informational *****/
bool
-adplug_is_our_fd (const char * filename, VFSFile * fd)
+adplug_is_our_fd (const char * filename, VFSFile & fd)
{
CSilentopl tmpopl;
@@ -271,7 +271,7 @@ adplug_is_our_fd (const char * filename, VFSFile * fd)
/***** Player control *****/
bool
-adplug_play (const char * filename, VFSFile * file)
+adplug_play (const char * filename, VFSFile & file)
{
dbg_printf ("adplug_play(\"%s\"): ", filename);
audio_error = false;
@@ -335,7 +335,7 @@ bool adplug_init (void)
std::string userdb;
userdb = std::string ("file://") + homedir + "/" ADPLUG_CONFDIR "/" + ADPLUGDB_FILE;
- if (vfs_file_test (userdb.c_str (), VFS_EXISTS))
+ if (VFSFile::test_file (userdb.c_str (), VFS_EXISTS))
{
plr.db->load (userdb); // load user's database
dbg_printf (" (userdb=\"%s\")", userdb.c_str());
@@ -26,9 +26,9 @@ bool adplug_init (void);
void adplug_quit (void);
void adplug_about (void);
void adplug_config (void);
-bool adplug_play (const char * filename, VFSFile * file);
+bool adplug_play (const char * filename, VFSFile & file);
void adplug_info_box (const char * filename);
-Tuple adplug_get_tuple (const char * filename, VFSFile * file);
-bool adplug_is_our_fd (const char * filename, VFSFile * file);
+Tuple adplug_get_tuple (const char * filename, VFSFile & file);
+bool adplug_is_our_fd (const char * filename, VFSFile & file);
#endif
@@ -64,7 +64,7 @@ Ca2mLoader::factory (Copl * newopl)
}
bool
-Ca2mLoader::load (VFSFile * fd, const CFileProvider & fp)
+Ca2mLoader::load (VFSFile & fd, const CFileProvider & fp)
{
binistream *f = fp.open (fd);
if (!f)
@@ -33,7 +33,7 @@ class Ca2mLoader: public CmodPlayer
: CmodPlayer(newopl)
{ };
- bool load(VFSFile *fd, const CFileProvider &fp);
+ bool load(VFSFile &fd, const CFileProvider &fp);
float getrefresh();
std::string gettype()
@@ -82,4 +82,3 @@ class Ca2mLoader: public CmodPlayer
unsigned char *obuf, *buf;
};
#endif
-
@@ -2748,10 +2748,10 @@ CadlPlayer::play (uint8_t track)
// }
bool
-CadlPlayer::load (VFSFile * fd, const CFileProvider & fp)
+CadlPlayer::load (VFSFile & fd, const CFileProvider & fp)
{
binistream *f = fp.open (fd);
- std::string filename (vfs_get_filename (fd));
+ std::string filename (fd.filename ());
// file validation section
if (!f || !fp.extension (filename, ".adl"))
@@ -36,7 +36,7 @@ class CadlPlayer: public CPlayer
CadlPlayer(Copl *newopl);
~CadlPlayer();
- bool load(VFSFile *fd, const CFileProvider &fp);
+ bool load(VFSFile &fd, const CFileProvider &fp);
bool update();
void rewind(int subsong = -1);
@@ -189,7 +189,7 @@ CAdPlugDatabase *
CAdPlug::database = 0;
CPlayer *
-CAdPlug::factory (VFSFile * fd, Copl * opl, const CPlayers & pl,
+CAdPlug::factory (VFSFile & fd, Copl * opl, const CPlayers & pl,
const CFileProvider & fp)
{
CPlayer *p;
@@ -201,7 +201,7 @@ CAdPlug::factory (VFSFile * fd, Copl * opl, const CPlayers & pl,
{
for (j = 0; (*i)->get_extension (j); j++)
{
- if (fp.extension (vfs_get_filename (fd), (*i)->get_extension (j)))
+ if (fp.extension (fd.filename (), (*i)->get_extension (j)))
{
AdPlug_LogWrite ("Trying direct hit: %s\n", (*i)->filetype.c_str ());
@@ -216,7 +216,7 @@ CAdPlug::factory (VFSFile * fd, Copl * opl, const CPlayers & pl,
delete p;
- if (vfs_fseek (fd, 0, VFS_SEEK_SET) < 0)
+ if (fd.fseek (0, VFS_SEEK_SET) < 0)
return 0;
}
}
@@ -37,7 +37,7 @@ class CAdPlug
public:
static const CPlayers& getPlayers();
- static CPlayer *factory(VFSFile *fd, Copl *opl,
+ static CPlayer *factory(VFSFile &fd, Copl *opl,
const CPlayers &pl = getPlayers(),
const CFileProvider &fp = CProvider_Filesystem());
@@ -44,7 +44,7 @@ CadtrackLoader::factory (Copl * newopl)
}
bool
-CadtrackLoader::load (VFSFile * fd, const CFileProvider & fp)
+CadtrackLoader::load (VFSFile & fd, const CFileProvider & fp)
{
binistream *f = fp.open (fd);
if (!f)
@@ -55,7 +55,7 @@ CadtrackLoader::load (VFSFile * fd, const CFileProvider & fp)
unsigned char chp, octave, pnote = 0;
int i, j;
AdTrackInst myinst;
- std::string filename (vfs_get_filename (fd));
+ std::string filename (fd.filename ());
// file validation
if (!fp.extension (filename, ".sng") || fp.filesize (f) != 36000)
@@ -70,12 +70,11 @@ CadtrackLoader::load (VFSFile * fd, const CFileProvider & fp)
AdPlug_LogWrite ("CadtrackLoader::load(,\"%s\"): Checking for \"%s\"...\n",
filename.c_str (), instfilename.c_str ());
- VFSFile *instfd = vfs_fopen (instfilename.c_str (), "rb");
+ VFSFile instfd (instfilename.c_str (), "rb");
instf = fp.open (instfd);
if (!instf || fp.filesize (instf) != 468)
{
fp.close (f);
- vfs_fclose (instfd);
return false;
}
@@ -30,7 +30,7 @@ class CadtrackLoader: public CmodPlayer
: CmodPlayer(newopl)
{ };
- bool load(VFSFile *fd, const CFileProvider &fp);
+ bool load(VFSFile &fd, const CFileProvider &fp);
float getrefresh();
std::string gettype()
@@ -31,7 +31,7 @@ CamdLoader::factory (Copl * newopl)
}
bool
-CamdLoader::load (VFSFile * fd, const CFileProvider & fp)
+CamdLoader::load (VFSFile & fd, const CFileProvider & fp)
{
binistream *f = fp.open (fd);
if (!f)
@@ -30,7 +30,7 @@ class CamdLoader: public CmodPlayer
: CmodPlayer(newopl)
{ };
- bool load(VFSFile *fd, const CFileProvider &fp);
+ bool load(VFSFile &fd, const CFileProvider &fp);
float getrefresh();
std::string gettype()
Oops, something went wrong.

0 comments on commit ae0cdf6

Please sign in to comment.