forked from mia/Aegisub
Fixed a memory leak that would occur when loading audio while using the hard disk cache
Originally committed to SVN as r3056.
This commit is contained in:
parent
f20d079598
commit
0d1ede1ed1
2 changed files with 6 additions and 3 deletions
|
@ -82,11 +82,11 @@ HDAudioProvider::HDAudioProvider(AudioProvider *source) {
|
|||
|
||||
// Write to disk
|
||||
int block = 4096;
|
||||
char *temp = new char[block * channels * bytes_per_sample];
|
||||
data = new char[block * channels * bytes_per_sample];
|
||||
for (int64_t i=0;i<num_samples && !canceled; i+=block) {
|
||||
if (block+i > num_samples) block = num_samples - i;
|
||||
source->GetAudio(temp,i,block);
|
||||
file_cache.Write(temp,block * channels * bytes_per_sample);
|
||||
source->GetAudio(data,i,block);
|
||||
file_cache.Write(data,block * channels * bytes_per_sample);
|
||||
progress->SetProgress(i,num_samples);
|
||||
}
|
||||
file_cache.Seek(0);
|
||||
|
@ -97,6 +97,7 @@ HDAudioProvider::HDAudioProvider(AudioProvider *source) {
|
|||
}
|
||||
else {
|
||||
file_cache.Close();
|
||||
delete[] data;
|
||||
throw wxString(_T("Audio loading cancelled by user"));
|
||||
}
|
||||
}
|
||||
|
@ -107,6 +108,7 @@ HDAudioProvider::HDAudioProvider(AudioProvider *source) {
|
|||
HDAudioProvider::~HDAudioProvider() {
|
||||
file_cache.Close();
|
||||
wxRemoveFile(diskCacheFilename);
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ private:
|
|||
wxFile file_cache;
|
||||
wxString diskCacheFilename;
|
||||
bool samples_native_endian;
|
||||
char *data;
|
||||
|
||||
static wxString DiskCachePath();
|
||||
static wxString DiskCacheName();
|
||||
|
|
Loading…
Reference in a new issue