mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-12 13:21:51 +00:00
Close the file handle in the sndfile decoder
This commit is contained in:
parent
73d51a4446
commit
b1c98acf33
2 changed files with 11 additions and 7 deletions
|
@ -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)
|
||||
{
|
||||
sf_close(SndFile);
|
||||
SndFile = 0;
|
||||
}
|
||||
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;
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue