mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02:00
Fixed bug "On Demand calculation stuck at 1%". (Don't know if it had a bugzilla entry. Didn't find one.)
Basic problem was in using wxConvUTF8 instead of wxConvFile. I believe wxConvFile should work on all platforms, but if not we can "#ifdef _WIN32" its use. Also simplified the code by getting rid of the mFileNameChar member. It was used only in ODPCMAliasBlockFile::WriteSummary() so there's no reason to do the conversion from mFileName in so many places -- just do it once, in ODPCMAliasBlockFile::WriteSummary().
This commit is contained in:
parent
bce418b19b
commit
ceb5aff5cb
@ -47,12 +47,7 @@ ODPCMAliasBlockFile::ODPCMAliasBlockFile(wxFileName fileName,
|
|||||||
sampleCount aliasLen, int aliasChannel):
|
sampleCount aliasLen, int aliasChannel):
|
||||||
PCMAliasBlockFile(fileName, aliasedFile, aliasStart, aliasLen, aliasChannel,false)
|
PCMAliasBlockFile(fileName, aliasedFile, aliasStart, aliasLen, aliasChannel,false)
|
||||||
{
|
{
|
||||||
|
mSummaryAvailable = mSummaryBeingComputed = mHasBeenSaved = false;
|
||||||
mSummaryAvailable=mSummaryBeingComputed=mHasBeenSaved=false;
|
|
||||||
mFileNameChar = new char[strlen(mFileName.GetFullPath().mb_str(wxConvUTF8))+1];
|
|
||||||
strcpy(mFileNameChar,mFileName.GetFullPath().mb_str(wxConvUTF8));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///summaryAvailable should be true if the file has been written already.
|
///summaryAvailable should be true if the file has been written already.
|
||||||
@ -65,13 +60,10 @@ ODPCMAliasBlockFile::ODPCMAliasBlockFile(wxFileName existingFileName,
|
|||||||
{
|
{
|
||||||
mSummaryAvailable=summaryAvailable;
|
mSummaryAvailable=summaryAvailable;
|
||||||
mSummaryBeingComputed=mHasBeenSaved=false;
|
mSummaryBeingComputed=mHasBeenSaved=false;
|
||||||
mFileNameChar = new char[strlen(mFileName.GetFullPath().mb_str(wxConvUTF8))+1];
|
|
||||||
strcpy(mFileNameChar,mFileName.GetFullPath().mb_str(wxConvUTF8));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ODPCMAliasBlockFile::~ODPCMAliasBlockFile()
|
ODPCMAliasBlockFile::~ODPCMAliasBlockFile()
|
||||||
{
|
{
|
||||||
delete [] mFileNameChar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Increases the reference count of this block by one. Only
|
/// Increases the reference count of this block by one. Only
|
||||||
@ -381,9 +373,6 @@ void ODPCMAliasBlockFile::SetFileName(wxFileName &name)
|
|||||||
{
|
{
|
||||||
mFileNameMutex.Lock();
|
mFileNameMutex.Lock();
|
||||||
mFileName=name;
|
mFileName=name;
|
||||||
delete [] mFileNameChar;
|
|
||||||
mFileNameChar = new char[strlen(mFileName.GetFullPath().mb_str(wxConvUTF8))+1];
|
|
||||||
strcpy(mFileNameChar,mFileName.GetFullPath().mb_str(wxConvUTF8));
|
|
||||||
mFileNameMutex.Unlock();
|
mFileNameMutex.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,12 +392,20 @@ void ODPCMAliasBlockFile::WriteSummary()
|
|||||||
//the mFileName path may change, for example, when the project is saved.
|
//the mFileName path may change, for example, when the project is saved.
|
||||||
//(it moves from /tmp/ to wherever it is saved to.
|
//(it moves from /tmp/ to wherever it is saved to.
|
||||||
mFileNameMutex.Lock();
|
mFileNameMutex.Lock();
|
||||||
//wxFFile is not thread-safe - if any error occurs in fopen, it posts a wxlog message which WILL crash
|
|
||||||
//audacity because it goes into the wx GUI. For this reason I left the FILE* method commented out (mchinen)
|
//wxFFile is not thread-safe - if any error occurs in opening the file,
|
||||||
//wxFFile summaryFile(mFileName.GetFullPath(), wxT("wb"));
|
// it posts a wxlog message which WILL crash
|
||||||
|
// Audacity because it goes into the wx GUI.
|
||||||
FILE* summaryFile=fopen(mFileNameChar, "wb");
|
// For this reason I left the wxFFile method commented out. (mchinen)
|
||||||
|
// wxFFile summaryFile(mFileName.GetFullPath(), wxT("wb"));
|
||||||
|
|
||||||
|
// ...and we use fopen instead.
|
||||||
|
wxString sFullPath = mFileName.GetFullPath();
|
||||||
|
char* fileNameChar = new char[strlen(sFullPath.mb_str(wxConvFile)) + 1];
|
||||||
|
strcpy(fileNameChar, sFullPath.mb_str(wxConvFile));
|
||||||
|
FILE* summaryFile = fopen(fileNameChar, "wb");
|
||||||
|
delete [] fileNameChar;
|
||||||
|
|
||||||
mFileNameMutex.Unlock();
|
mFileNameMutex.Unlock();
|
||||||
|
|
||||||
if( !summaryFile){//.IsOpened() ){
|
if( !summaryFile){//.IsOpened() ){
|
||||||
@ -418,7 +415,7 @@ void ODPCMAliasBlockFile::WriteSummary()
|
|||||||
//and wxLog calls are not thread safe.
|
//and wxLog calls are not thread safe.
|
||||||
printf("Unable to write summary data to file: ");// %s",
|
printf("Unable to write summary data to file: ");// %s",
|
||||||
printf("test..\n");
|
printf("test..\n");
|
||||||
printf(" filename: %s\n",mFileNameChar);
|
printf(" filename: %s\n", fileNameChar);
|
||||||
mFileNameMutex.Unlock();
|
mFileNameMutex.Unlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -438,7 +435,7 @@ void ODPCMAliasBlockFile::WriteSummary()
|
|||||||
delete [] (char *) summaryData;
|
delete [] (char *) summaryData;
|
||||||
|
|
||||||
|
|
||||||
// printf("write successful. filename: %s\n",mFileNameChar);
|
// printf("write successful. filename: %s\n", fileNameChar);
|
||||||
|
|
||||||
mSummaryAvailableMutex.Lock();
|
mSummaryAvailableMutex.Lock();
|
||||||
mSummaryAvailable=true;
|
mSummaryAvailable=true;
|
||||||
|
@ -152,8 +152,6 @@ class ODPCMAliasBlockFile : public PCMAliasBlockFile
|
|||||||
friend class ODComputeSummaryTask;
|
friend class ODComputeSummaryTask;
|
||||||
friend class ODDecodeTask;
|
friend class ODDecodeTask;
|
||||||
|
|
||||||
char* mFileNameChar;
|
|
||||||
|
|
||||||
ODLock mWriteSummaryMutex;
|
ODLock mWriteSummaryMutex;
|
||||||
|
|
||||||
//need to protect this since it is changed from the main thread upon save.
|
//need to protect this since it is changed from the main thread upon save.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user