- added a few more FileRdr replacements

- fixed: The streaming music player must return the file reader if it fails to open, so that the next player can still use it.
- fixed: Timidity++'s Instruments class did not delete the sound font when it was destroyed.

..-
This commit is contained in:
Christoph Oelckers 2018-03-10 20:33:49 +01:00
parent 56991a9ace
commit b315bc3be0
9 changed files with 25 additions and 21 deletions

View file

@ -2492,11 +2492,11 @@ bool D_LoadDehLump(int lumpnum)
bool D_LoadDehFile(const char *patchfile)
{
FileReader fr;
FileRdr fr;
if (fr.Open(patchfile))
if (fr.OpenFile(patchfile))
{
PatchSize = fr.GetLength();
PatchSize = (int)fr.GetLength();
PatchName = copystring(patchfile);
PatchFile = new char[PatchSize + 1];

View file

@ -2801,8 +2801,8 @@ void G_DoPlayDemo (void)
{
FixPathSeperator (defdemoname);
DefaultExtension (defdemoname, ".lmp");
FileReader fr;
if (!fr.Open(defdemoname))
FileRdr fr;
if (!fr.OpenFile(defdemoname))
{
I_Error("Unable to open demo '%s'", defdemoname.GetChars());
}

View file

@ -121,15 +121,15 @@ void M_FindResponseFile (void)
if (added_stuff < limit)
{
// READ THE RESPONSE FILE INTO MEMORY
FileReader fr;
if (!fr.Open(Args->GetArg(i) + 1))
FileRdr fr;
if (!fr.OpenFile(Args->GetArg(i) + 1))
{ // [RH] Make this a warning, not an error.
Printf ("No such response file (%s)!\n", Args->GetArg(i) + 1);
}
else
{
Printf ("Found response file %s!\n", Args->GetArg(i) + 1);
size = fr.GetLength();
size = (int)fr.GetLength();
file = new char[size+1];
fr.Read (file, size);
file[size] = 0;

View file

@ -248,8 +248,8 @@ bool FScanner::OpenFile (const char *name)
{
Close ();
FileReader fr;
if (!fr.Open(name)) return false;
FileRdr fr;
if (!fr.OpenFile(name)) return false;
auto filesize = fr.GetLength();
auto filebuf = new uint8_t[filesize];
if (fr.Read(filebuf, filesize) != filesize)

View file

@ -291,8 +291,8 @@ void FSoundFontManager::ProcessOneFile(const FString &fn)
if (!sfi.mName.CompareNoCase(fb)) return;
}
FileReader fr;
if (fr.Open(fn))
FileRdr fr;
if (fr.OpenFile(fn))
{
// Try to identify. We only accept .sf2 and .zip by content. All other archives are intentionally ignored.
char head[16] = { 0};
@ -433,8 +433,8 @@ FSoundFontReader *FSoundFontManager::OpenSoundFont(const char *name, int allowed
// Next check if the file is a .sf file
if (allowed & SF_SF2)
{
FileReader fr;
if (fr.Open(name))
FileRdr fr;
if (fr.OpenFile(name))
{
char head[16] = { 0};
fr.Read(head, 16);
@ -447,8 +447,8 @@ FSoundFontReader *FSoundFontManager::OpenSoundFont(const char *name, int allowed
}
if (allowed & SF_GUS)
{
FileReader fr;
if (fr.Open(name))
FileRdr fr;
if (fr.OpenFile(name))
{
char head[16] = { 0 };
fr.Read(head, 2);

View file

@ -145,7 +145,8 @@ bool MPG123Decoder::open(FileRdr &reader)
MPG123 = 0;
}
return false;
reader = std::move(Reader); // need to give it back.
return false;
}
void MPG123Decoder::getInfo(int *samplerate, ChannelConfig *chans, SampleType *type)

View file

@ -127,7 +127,8 @@ bool SndFileDecoder::open(FileRdr &reader)
sf_close(SndFile);
SndFile = 0;
}
return false;
reader = std::move(Reader); // need to give it back.
return false;
}
void SndFileDecoder::getInfo(int *samplerate, ChannelConfig *chans, SampleType *type)

View file

@ -75,6 +75,8 @@ Instruments::~Instruments()
free_tone_bank();
free_instrument_map();
if (sfreader != nullptr) delete sfreader;
}
void Instruments::free_instrument(Instrument *ip)

View file

@ -306,14 +306,14 @@ int FTextureManager::CountBuildTiles ()
FString artpath = rffpath;
artpath += artfile;
FileReader fr;
FileRdr fr;
if (!fr.Open(artpath))
if (!fr.OpenFile(artpath))
{
break;
}
long len = fr.GetLength();
auto len = fr.GetLength();
uint8_t *art = new uint8_t[len];
if (fr.Read (art, len) != len || (numtiles = CountTiles(art)) == 0)
{