Update of /cvsroot/audacity/audacity-src/src/ondemand In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv14241/ondemand
Modified Files: ODManager.cpp ODManager.h Log Message: checking in fix for OD P3 Index: ODManager.cpp =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/ondemand/ODManager.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- ODManager.cpp 26 May 2009 00:10:53 -0000 1.28 +++ ODManager.cpp 19 Sep 2009 00:03:57 -0000 1.29 @@ -20,6 +20,7 @@ ODLock gODInitedMutex; bool gManagerCreated=false; +bool gPause=false; //to be loaded in and used with Pause/Resume before ODMan init. /// a flag that is set if we have loaded some OD blockfiles from PCM. bool sHasLoadedOD=false; @@ -31,7 +32,7 @@ DEFINE_EVENT_TYPE(EVT_ODTASK_UPDATE) //OD files are "greater than" non OD files, to produce a sort that has -//OD Files at the end. +//OD Files at the end int CompareODFileName(const wxString& first, const wxString& second) { bool firstIsOD = false; @@ -94,9 +95,19 @@ else if(secondIsOD&&!firstIsOD) return 1; + //if they are both OD-files, or both non-OD-files, use a normal string comparison + //to get alphabetical sorting return first.Cmp(second); } +//using this with wxStringArray::Sort will give you a list that +//is alphabetical, without depending on case. If you use the +//default sort, you will get strings with 'R' before 'a', because it is in caps. +int CompareNoCaseFileName(const wxString& first, const wxString& second) +{ + return first.CmpNoCase(second); +} + void ODManager::LockLibSndFileMutex() { sLibSndFileMutex.Lock(); @@ -113,6 +124,7 @@ { mTerminate = false; mTerminated = false; + mPause= gPause; } //private constructor - delete with static method Quit() @@ -250,6 +262,7 @@ { ODTaskThread* thread; bool tasksInArray; + bool paused; mNeedsDraw=0; @@ -273,7 +286,11 @@ mTasksMutex.Unlock(); mCurrentThreadsMutex.Lock(); - while( tasksInArray&& mCurrentThreads < mMaxThreads) + mPauseLock.Lock(); + paused=mPause; + mPauseLock.Unlock(); + + while(!paused && tasksInArray&& mCurrentThreads < mMaxThreads) { mCurrentThreads++; mCurrentThreadsMutex.Unlock(); @@ -301,6 +318,8 @@ } mCurrentThreadsMutex.Unlock(); + //TODO: use a conditon variable to block here instead of a sleep. + //Also find out if the condition variable polls to quickly - we don't want that either. wxThread::Sleep(200); //wxSleep can't be called from non-main thread. // ::wxMilliSleep(250); @@ -335,6 +354,25 @@ } +void ODManager::Pause(bool pause) +{ + if(IsInstanceCreated()) + { + ODManager::Instance()->mPauseLock.Lock(); + ODManager::Instance()->mPause = pause; + ODManager::Instance()->mPauseLock.Unlock(); + } + else + { + gPause=pause; + } +} + +void ODManager::Resume() +{ + Pause(false); +} + void ODManager::Quit() { if(IsInstanceCreated()) Index: ODManager.h =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/ondemand/ODManager.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- ODManager.h 14 Dec 2008 06:58:08 -0000 1.17 +++ ODManager.h 19 Sep 2009 00:03:57 -0000 1.18 @@ -44,7 +44,7 @@ ///wxstring compare function for sorting filenames with od int CompareODFileName(const wxString& first, const wxString& second); int CompareODFirstFileName(const wxString& first, const wxString& second); - +int CompareNoCaseFileName(const wxString& first, const wxString& second); /// A singleton that manages currently running Tasks on an arbitrary /// number of threads. class WaveTrack; @@ -106,10 +106,14 @@ ///Get Total Number of Tasks. int GetTotalNumTasks(); + //Pause/unpause all OD Tasks. Does not occur immediately. + static void Pause(bool pause = true); + static void Resume(); static void LockLibSndFileMutex(); static void UnlockLibSndFileMutex(); + protected: //private constructor - Singleton. @@ -134,6 +138,10 @@ std::vector<ODTask*> mTasks; //mutex for above variable ODLock mTasksMutex; + + //global pause switch for OD + bool mPause; + ODLock mPauseLock; int mNeedsDraw; ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Audacity-cvs mailing list Audacity-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/audacity-cvs