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

Modified Files:
        ODManager.cpp ODTask.cpp 
Log Message:
Fixing mutex order in ODTask.  Was causing race-condition crashes on merge 
stereo track


Index: ODManager.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/ondemand/ODManager.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- ODManager.cpp       5 Apr 2009 22:52:25 -0000       1.26
+++ ODManager.cpp       5 May 2009 16:19:04 -0000       1.27
@@ -281,21 +281,22 @@
          mCurrentThreadsMutex.Unlock();
          //remove the head
          mTasksMutex.Lock();
-         task = mTasks[0];
+         //task = mTasks[0];
          
          //the thread will add it back to the array if the job is not yet done 
at the end of the thread's run.  
-         mTasks.erase(mTasks.begin());  
+         //mTasks.erase(mTasks.begin());  
          mTasksMutex.Unlock();
          
          //detach a new thread.
-         thread = new ODTaskThread(task);
+         thread = new ODTaskThread(mTasks[0]);//task);
          
 //         thread->SetPriority(10);//default is 50.
          thread->Create();
          thread->Run();
          
-         mTasksMutex.Lock();
+         mTasks.erase(mTasks.begin()); 
          tasksInArray = mTasks.size()>0;
+         
          mTasksMutex.Unlock();
          
          mCurrentThreadsMutex.Lock();

Index: ODTask.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/ondemand/ODTask.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- ODTask.cpp  23 Aug 2008 23:14:04 -0000      1.17
+++ ODTask.cpp  5 May 2009 16:19:04 -0000       1.18
@@ -44,6 +44,7 @@
    mDemandSample=0;
 }
 
+//outside code must ensure this task is not scheduled again.
 void ODTask::TerminateAndBlock()
 {  
    //one mutex pair for the value of mTerminate
@@ -57,7 +58,7 @@
 //TODO lock mTerminate?
    mBlockUntilTerminateMutex.Unlock();
    
-   //wait till we are out of doSome() to terminate.
+   //wait till we are out of doSome() to terminate. 
    Terminate();
 }
    
@@ -82,9 +83,9 @@
    mTerminateMutex.Lock();
    if(mTerminate)
    {
-      mBlockUntilTerminateMutex.Unlock();
       mTerminateMutex.Unlock();
       SetIsRunning(false);
+      mBlockUntilTerminateMutex.Unlock();
       return;
    }  
    mTerminateMutex.Unlock();
@@ -168,9 +169,8 @@
 //      printf("%s %i complete\n", GetTaskName(),GetTaskNumber());
    }
    mTerminateMutex.Unlock();
-   mBlockUntilTerminateMutex.Unlock();
    SetIsRunning(false);
-   
+   mBlockUntilTerminateMutex.Unlock();
 }
 
 bool ODTask::IsTaskAssociatedWithProject(AudacityProject* proj)


------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to