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

Modified Files:
        ODDecodeBlockFile.cpp ODPCMAliasBlockFile.cpp 
Log Message:
Cleaning up comments and removing speculative TODOs.  Also changing some mutex 
access from using the raw member variable to using the interface.  Verified 
that copy and paste kind of works for FLAC and also realized that it doesn't 
refresh the screen correctly for wav as well.


Index: ODPCMAliasBlockFile.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/blockfile/ODPCMAliasBlockFile.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- ODPCMAliasBlockFile.cpp     11 Oct 2009 14:55:47 -0000      1.25
+++ ODPCMAliasBlockFile.cpp     11 Oct 2009 19:31:09 -0000      1.26
@@ -220,7 +220,7 @@
    BlockFile *newBlockFile;
    
    //mAliasedFile can change so we lock readdatamutex, which is responsible 
for it.
-   mReadDataMutex.Lock();
+   LockRead();
    //If the file has been written AND it has been saved, we create a PCM alias 
blockfile because for
    //all intents and purposes, it is the same.  
    //However, if it hasn't been saved yet, we shouldn't create one because the 
default behavior of the
@@ -243,7 +243,7 @@
       //The client code will need to schedule this blockfile for OD 
summarizing if it is going to a new track.
    }
    
-   mReadDataMutex.Unlock();
+   UnlockRead();
    
    return newBlockFile;
 }
@@ -256,7 +256,7 @@
 void ODPCMAliasBlockFile::SaveXML(XMLWriter &xmlFile)
 {
    //we lock this so that mAliasedFileName doesn't change.
-   mReadDataMutex.Lock();
+   LockRead();
    if(IsSummaryAvailable())
    {
       PCMAliasBlockFile::SaveXML(xmlFile);
@@ -267,11 +267,11 @@
       xmlFile.StartTag(wxT("odpcmaliasblockfile"));
 
       //unlock to prevent deadlock and resume lock after.
-      mReadDataMutex.Unlock();
+      UnlockRead();
       mFileNameMutex.Lock();
       xmlFile.WriteAttr(wxT("summaryfile"), mFileName.GetFullName());
       mFileNameMutex.Unlock();
-      mReadDataMutex.Lock();
+      LockRead();
       
       xmlFile.WriteAttr(wxT("aliasfile"), mAliasedFileName.GetFullPath());
       xmlFile.WriteAttr(wxT("aliasstart"), mAliasStart);
@@ -281,7 +281,7 @@
       xmlFile.EndTag(wxT("odpcmaliasblockfile"));
    }
    
-   mReadDataMutex.Unlock();
+   UnlockRead();
 }
 
 /// Constructs a ODPCMAliasBlockFile from the xml output of WriteXML.
@@ -599,13 +599,13 @@
                                 sampleCount start, sampleCount len)
 {
 
-   mReadDataMutex.Lock();
+   LockRead();
 
    SF_INFO info;
 
    if(!mAliasedFileName.IsOk()){ // intentionally silenced 
       memset(data,0,SAMPLE_SIZE(format)*len);
-      mReadDataMutex.Unlock();
+      UnlockRead();
 
          return len;
    }
@@ -635,7 +635,7 @@
 
       mSilentAliasLog=TRUE;
 
-      mReadDataMutex.Unlock();
+      UnlockRead();
       return len;
    }
 
@@ -682,7 +682,7 @@
    sf_close(sf);
    ODManager::UnlockLibSndFileMutex();
    
-   mReadDataMutex.Unlock();
+   UnlockRead();
    return framesRead;
 }
 

Index: ODDecodeBlockFile.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/blockfile/ODDecodeBlockFile.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ODDecodeBlockFile.cpp       11 Oct 2009 14:55:47 -0000      1.5
+++ ODDecodeBlockFile.cpp       11 Oct 2009 19:31:09 -0000      1.6
@@ -131,7 +131,7 @@
    }
    else
    {
-      //TODO: put some dummy value?  should we make a fake one?
+      //this should not be reached (client should check 
IsSummaryAvailable()==true before this.
       buffer = NULL;
       return true;
    }
@@ -146,7 +146,7 @@
    }
    else
    {
-      //TODO: put some dummy value?  should we make a fake one?
+      //this should not be reached (client should check 
IsSummaryAvailable()==true before this.
       return true;
    }
 }
@@ -160,7 +160,7 @@
    BlockFile *newBlockFile;
    
    //mAliasedFile can change so we lock readdatamutex, which is responsible 
for it.
-   mReadDataMutex.Lock();
+   LockRead();
    if(IsSummaryAvailable())
    {
       //create a simpleblockfile, because once it has the summary it is a 
simpleblockfile for all intents an purposes
@@ -175,9 +175,9 @@
                                                    mMin, mMax, 
mRMS,IsSummaryAvailable());
       //The client code will need to schedule this blockfile for OD decoding 
if it is going to a new track.
       //It can do this by checking for IsDataAvailable()==false.
-  }
+   }
    
-   mReadDataMutex.Unlock();
+   UnlockRead();
    
    return newBlockFile;
 }
@@ -189,6 +189,7 @@
 /// and this object reconstructed, it needs to avoid trying to open it as well 
as schedule itself for OD loading
 void ODDecodeBlockFile::SaveXML(XMLWriter &xmlFile)
 {
+   LockRead();
    if(IsSummaryAvailable())
    {
       SimpleBlockFile::SaveXML(xmlFile);
@@ -197,11 +198,11 @@
    {
       xmlFile.StartTag(wxT("oddecodeblockfile"));
        //unlock to prevent deadlock and resume lock after.
-      mReadDataMutex.Unlock();
+      UnlockRead();
       mFileNameMutex.Lock();
       xmlFile.WriteAttr(wxT("summaryfile"), mFileName.GetFullName());
       mFileNameMutex.Unlock();
-      mReadDataMutex.Lock();
+      LockRead();
       xmlFile.WriteAttr(wxT("audiofile"), mAudioFileName.GetFullPath());
       xmlFile.WriteAttr(wxT("aliasstart"), mAliasStart);
       xmlFile.WriteAttr(wxT("aliaslen"), mLen);
@@ -210,6 +211,7 @@
 
       xmlFile.EndTag(wxT("oddecodeblockfile"));
    }
+       UnlockRead();
 }
 
 /// Constructs a ODPCMAliasBlockFile from the xml output of WriteXML.
@@ -322,7 +324,6 @@
    if(!mDecoder)
    {
       mDecoderMutex.Unlock();
-      UnlockRead();
       return;
    }
    
@@ -526,17 +527,19 @@
 int ODDecodeBlockFile::ReadData(samplePtr data, sampleFormat format,
                                 sampleCount start, sampleCount len)
 {
-   
-   
+   int ret;
+   LockRead();
    if(IsSummaryAvailable())
-      return SimpleBlockFile::ReadData(data,format,start,len);
+      ret= SimpleBlockFile::ReadData(data,format,start,len);
    else
    {
       //we should do an ODRequest to start processing the data here, and wait 
till it finishes. and just do a SimpleBlockFIle
       //ReadData.
       ClearSamples(data, format, 0, len);
-      return len;
+      ret= len;
    }
+   UnlockRead();
+   return ret;
 }
 
 /// Read the summary of this alias block from disk.  Since the audio data
@@ -546,6 +549,7 @@
 ///              be at least mSummaryInfo.totalSummaryBytes long.
 bool ODDecodeBlockFile::ReadSummary(void *data)
 {
+   //I dont think we need to add a mutex here because only the main thread 
changes filenames and calls ReadSummarz
    if(IsSummaryAvailable())
       return SimpleBlockFile::ReadSummary(data);
    


------------------------------------------------------------------------------
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