Update of /cvsroot/audacity/audacity-src/src/ondemand
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv31159/ondemand

Modified Files:
        ODTask.cpp ODManager.h ODManager.cpp 
Log Message:
improvements for od: normalizing redraw time, fixing overall percentage 
displayed in status bar, and posting final import complete message.


Index: ODManager.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/ondemand/ODManager.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- ODManager.cpp       7 Oct 2009 15:50:35 -0000       1.32
+++ ODManager.cpp       7 Oct 2009 23:31:41 -0000       1.33
@@ -128,9 +128,6 @@
    
    //must set up the queue condition
    mQueueNotEmptyCond = new ODCondition(&mQueueNotEmptyCondLock);
-//#ifndef __WX_MAC__
-//   mQueueNotEmptyCondLock.Lock();
-//#endif   
 }
 
 //private constructor - delete with static method Quit()
@@ -152,9 +149,7 @@
    mTasksMutex.Lock();
    mTasks.push_back(task);
    mTasksMutex.Unlock();
-   //signal the queue not empty condition.
-//#ifdef __WX_MAC__
-   
+   //signal the queue not empty condition.   
    bool paused;
    
    mPauseLock.Lock();
@@ -162,15 +157,25 @@
    mPauseLock.Unlock();
 
    mQueueNotEmptyCondLock.Lock();
-//#endif
-   //don't signal if we are paused.
-   
+   //don't signal if we are paused since if we wake up the loop it will start 
processing other tasks while paused
    if(!paused)
       mQueueNotEmptyCond->Signal();
+   mQueueNotEmptyCondLock.Unlock();
 
-//#ifdef __WX_MAC__   
+}
+
+void ODManager::SignalTaskQueueLoop()
+{
+   bool paused;
+   
+   mPauseLock.Lock();
+   paused=mPause;
+   mPauseLock.Unlock();
+   mQueueNotEmptyCondLock.Lock();
+   //don't signal if we are paused
+   if(!paused)
+      mQueueNotEmptyCond->Signal();
    mQueueNotEmptyCondLock.Unlock();
-//#endif
 }
 
 ///removes a task from the active task queue
@@ -289,6 +294,7 @@
    ODTaskThread* thread;
    bool tasksInArray;
    bool paused;
+   int  numQueues=0;
    
    mNeedsDraw=0;
 
@@ -345,25 +351,22 @@
 
       mCurrentThreadsMutex.Unlock();
       //use a conditon variable to block here instead of a sleep.  
-      //wxThread::Sleep(200);
-      //the behavior for wait is different in pthreads(mac) and wx (win/linux).
-      //wait in wx locks 
-//#ifdef __WX_MAC__
+
       mQueueNotEmptyCondLock.Lock();
-//#endif
       if(tasksInArray<=0 || paused)
          mQueueNotEmptyCond->Wait();
-//#ifdef __WX_MAC__
-      mQueueNotEmptyCondLock.Unlock();
-//#endif      
+      mQueueNotEmptyCondLock.Unlock();  
+      
       //if there is some ODTask running, then there will be something in the 
queue.  If so then redraw to show progress      
       mQueuesMutex.Lock();
       mNeedsDraw += mQueues.size()>0?1:0;
+      numQueues=mQueues.size();
       mQueuesMutex.Unlock();
 
-//TODO:check with last draw time and only redraw if more than half a second 
has passed.
       //redraw the current project only (ODTasks will send a redraw on 
complete even if the projects are in the background)
-      if(mNeedsDraw )
+      //we don't want to redraw at a faster rate when we have more queues 
because
+      //this means the CPU is already taxed.  This if statement normalizes the 
rate
+      if(mNeedsDraw>numQueues && numQueues)
       {
          mNeedsDraw=0;
          wxCommandEvent event( EVT_ODTASK_UPDATE );
@@ -395,13 +398,9 @@
       ODManager::Instance()->mPauseLock.Unlock();
       
       //we should check the queue again.
-//#ifdef __WX_MAC__
-         ODManager::Instance()->mQueueNotEmptyCondLock.Lock();
-//#endif
+      ODManager::Instance()->mQueueNotEmptyCondLock.Lock();
       ODManager::Instance()->mQueueNotEmptyCond->Signal();
-//#ifdef __WX_MAC__
-         ODManager::Instance()->mQueueNotEmptyCondLock.Unlock();
-//#endif         
+      ODManager::Instance()->mQueueNotEmptyCondLock.Unlock();
    }
    else
    {
@@ -429,15 +428,10 @@
          wxThread::Sleep(200);
          
          //signal the queue not empty condition since the ODMan thread will 
wait on the queue condition
-
-//#ifdef __WX_MAC__
          ODManager::Instance()->mQueueNotEmptyCondLock.Lock();
-//#endif
          ODManager::Instance()->mQueueNotEmptyCond->Signal();
-         
-//#ifdef __WX_MAC__
          ODManager::Instance()->mQueueNotEmptyCondLock.Unlock();
-//#endif         
+
          ODManager::Instance()->mTerminatedMutex.Lock();
       }
       ODManager::Instance()->mTerminatedMutex.Unlock();

Index: ODTask.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/ondemand/ODTask.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- ODTask.cpp  2 Jun 2009 05:03:15 -0000       1.19
+++ ODTask.cpp  7 Oct 2009 23:31:41 -0000       1.20
@@ -165,6 +165,9 @@
          }
       }
       AudacityProject::AllProjectsDeleteUnlock();
+      //signal the od task queue loop to wake up so it can remove the tasks 
from the queue and the queue if it is empty.
+      ODManager::Instance()->SignalTaskQueueLoop();
+
 
 //      printf("%s %i complete\n", GetTaskName(),GetTaskNumber());
    }

Index: ODManager.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/ondemand/ODManager.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- ODManager.h 6 Oct 2009 15:56:41 -0000       1.19
+++ ODManager.h 7 Oct 2009 23:31:41 -0000       1.20
@@ -67,6 +67,9 @@
    ///Adds a wavetrack, creates a queue member. 
    void AddNewTask(ODTask* task, bool lockMutex=true);
    
+   ///Wakes the queue loop up by signalling its condition variable.
+   void SignalTaskQueueLoop();
+   
    ///removes a wavetrack and notifies its associated tasks to stop using its 
reference. 
    void RemoveWaveTrack(WaveTrack* track);
    


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) 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/devconference
_______________________________________________
Audacity-cvs mailing list
Audacity-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to