mirror of https://github.com/odrling/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
|
@ -82,11 +82,11 @@ HDAudioProvider::HDAudioProvider(AudioProvider *source) {
|
||||||
|
|
||||||
// Write to disk
|
// Write to disk
|
||||||
int block = 4096;
|
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) {
|
for (int64_t i=0;i<num_samples && !canceled; i+=block) {
|
||||||
if (block+i > num_samples) block = num_samples - i;
|
if (block+i > num_samples) block = num_samples - i;
|
||||||
source->GetAudio(temp,i,block);
|
source->GetAudio(data,i,block);
|
||||||
file_cache.Write(temp,block * channels * bytes_per_sample);
|
file_cache.Write(data,block * channels * bytes_per_sample);
|
||||||
progress->SetProgress(i,num_samples);
|
progress->SetProgress(i,num_samples);
|
||||||
}
|
}
|
||||||
file_cache.Seek(0);
|
file_cache.Seek(0);
|
||||||
|
@ -97,6 +97,7 @@ HDAudioProvider::HDAudioProvider(AudioProvider *source) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
file_cache.Close();
|
file_cache.Close();
|
||||||
|
delete[] data;
|
||||||
throw wxString(_T("Audio loading cancelled by user"));
|
throw wxString(_T("Audio loading cancelled by user"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,6 +108,7 @@ HDAudioProvider::HDAudioProvider(AudioProvider *source) {
|
||||||
HDAudioProvider::~HDAudioProvider() {
|
HDAudioProvider::~HDAudioProvider() {
|
||||||
file_cache.Close();
|
file_cache.Close();
|
||||||
wxRemoveFile(diskCacheFilename);
|
wxRemoveFile(diskCacheFilename);
|
||||||
|
delete[] data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ private:
|
||||||
wxFile file_cache;
|
wxFile file_cache;
|
||||||
wxString diskCacheFilename;
|
wxString diskCacheFilename;
|
||||||
bool samples_native_endian;
|
bool samples_native_endian;
|
||||||
|
char *data;
|
||||||
|
|
||||||
static wxString DiskCachePath();
|
static wxString DiskCachePath();
|
||||||
static wxString DiskCacheName();
|
static wxString DiskCacheName();
|
||||||
|
|
Loading…
Reference in New Issue