Close the file handle in the sndfile decoder

This commit is contained in:
Chris Robinson 2014-06-19 17:50:03 -07:00
parent 73d51a4446
commit b1c98acf33
2 changed files with 11 additions and 7 deletions

View File

@ -145,6 +145,9 @@ SndFileDecoder::~SndFileDecoder()
if(SndFile)
sf_close(SndFile);
SndFile = 0;
if(File)
fclose(File);
File = 0;
}
bool SndFileDecoder::open(const char *data, size_t length)
@ -157,14 +160,14 @@ bool SndFileDecoder::open(const char *data, size_t length)
SndFile = sf_open_virtual(&sfio, SFM_READ, &SndInfo, this);
if(SndFile)
{
if(SndInfo.channels != 1 && SndInfo.channels != 2)
{
if(SndInfo.channels == 1 || SndInfo.channels == 2)
return true;
sf_close(SndFile);
SndFile = 0;
}
}
return SndFile != 0;
return false;
}
bool SndFileDecoder::open(const char *fname, size_t offset, size_t length)
@ -189,6 +192,7 @@ bool SndFileDecoder::open(const char *fname, size_t offset, size_t length)
}
}
fclose(File);
File = 0;
}
return false;

View File

@ -182,7 +182,7 @@ struct SndFileDecoder : public SoundDecoder
virtual bool seek(size_t ms_offset);
virtual size_t getSampleOffset();
SndFileDecoder() : SndFile(0) { }
SndFileDecoder() : SndFile(0), File(0) { }
virtual ~SndFileDecoder();
protected: