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

Modified Files:
        ODDecodeBlockFile.cpp ODDecodeBlockFile.h 
        ODPCMAliasBlockFile.cpp 
Log Message:
Checking in saving ability for FLAC on-demand loading.


Index: ODPCMAliasBlockFile.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/blockfile/ODPCMAliasBlockFile.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- ODPCMAliasBlockFile.cpp     9 Oct 2009 14:28:48 -0000       1.24
+++ ODPCMAliasBlockFile.cpp     11 Oct 2009 14:55:47 -0000      1.25
@@ -277,10 +277,6 @@
       xmlFile.WriteAttr(wxT("aliasstart"), mAliasStart);
       xmlFile.WriteAttr(wxT("aliaslen"), mLen);
       xmlFile.WriteAttr(wxT("aliaschannel"), mAliasChannel);
-      //these have not been computed yet.
-      //xmlFile.WriteAttr(wxT("min"), mMin);
-      //xmlFile.WriteAttr(wxT("max"), mMax);
-     // xmlFile.WriteAttr(wxT("rms"), mRMS);
 
       xmlFile.EndTag(wxT("odpcmaliasblockfile"));
    }
@@ -299,8 +295,6 @@
    float rms=0;
    long nValue;
 
-
-
    while(*attrs)
    {
       const wxChar *attr =  *attrs++;
@@ -341,14 +335,6 @@
             aliasLen = nValue;
          else if( !wxStricmp(attr, wxT("aliaschannel")) )
             aliasChannel = nValue;
-            
-         //The folowing attributes don't exist yet - not quite sure what to do 
with them yet.
-//         else if( !wxStricmp(attr, wxT("min")) )
-//            min = nValue;
-//         else if( !wxStricmp(attr, wxT("max")) )
-//            max = nValue;
-//         else if( !wxStricmp(attr, wxT("rms")) )
-//            rms = nValue;
       }
    }
 
@@ -357,7 +343,6 @@
          !XMLValueChecker::IsGoodFileName(aliasFileName.GetFullName(), 
aliasFileName.GetPath(wxPATH_GET_VOLUME)) || 
          (aliasLen <= 0) || (aliasLen < 0.0) || 
!XMLValueChecker::IsValidChannel(aliasChannel) || (rms < 0.0))
       return NULL;
-
    
    return new ODPCMAliasBlockFile(summaryFileName, aliasFileName,
                                 aliasStart, aliasLen, aliasChannel);

Index: ODDecodeBlockFile.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/blockfile/ODDecodeBlockFile.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ODDecodeBlockFile.cpp       9 Oct 2009 14:28:48 -0000       1.4
+++ ODDecodeBlockFile.cpp       11 Oct 2009 14:55:47 -0000      1.5
@@ -39,7 +39,7 @@
 
    /// Create a disk file and write summary and sample data to it
 ODDecodeBlockFile::ODDecodeBlockFile(wxFileName baseFileName,wxFileName 
audioFileName, sampleCount aliasStart,
-                     sampleCount aliasLen, int aliasChannel, int decodeType):
+                     sampleCount aliasLen, int aliasChannel,unsigned int 
decodeType):
    SimpleBlockFile(baseFileName,NULL,aliasLen,floatSample,true,true), 
//floatSample has no effect.  last two bools - bypass writing of blockfile and 
cache
 
    mAliasStart(aliasStart),
@@ -52,15 +52,15 @@
    
 /// Create the memory structure to refer to the given block file
 ODDecodeBlockFile::ODDecodeBlockFile(wxFileName existingFile, wxFileName 
audioFileName, sampleCount aliasStart,
-                     sampleCount aliasLen, int aliasChannel, int decodeType,
-                   float min, float max, float rms):
+                     sampleCount aliasLen, int aliasChannel, unsigned int 
decodeType,
+                   float min, float max, float rms, bool dataAvailable):
    SimpleBlockFile(existingFile,aliasLen,min,max,rms),
    
    mAliasStart(aliasStart),
    mAliasChannel(aliasChannel),
    mType(decodeType)
 {
-   mDataAvailable=false;
+   mDataAvailable=dataAvailable;
    mAudioFileName = audioFileName;
 }
 
@@ -168,15 +168,14 @@
    }
    else
    {
-      //TODO:do the correct constructor thingthing for this one.
-      //Also, this one needs to be scheduled for loading as well ... what to 
do?
-      newBlockFile  = NULL; // new ODPCMAliasBlockFile(newFileName,
-                              //                     mAliasedFileName, 
mAliasStart,
-                                //                   mLen, mAliasChannel,
-                                  //                 mMin, mMax, mRMS);
-      //TODO:add to the ODManager Task list so this one loads itself.  It's 
wasteful to do this twice, but lets be simple and naieve
-      //just this once,.
-   }
+      //Summary File might exist in this case, but it probably (99.999% of the 
time) won't.
+      newBlockFile  = new ODDecodeBlockFile(newFileName,
+                                                   mAudioFileName, mAliasStart,
+                                                   mLen, mAliasChannel, mType,
+                                                   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();
    
@@ -184,112 +183,104 @@
 }
 
 
-/// Writes the xml as a PCMAliasBlockFile if we can (if we have a summary file)
+/// Writes the xml as a SimpleBlockFile if we can (if we have a summary file)
 /// Otherwise writes XML as a subset of attributes with 'odpcmaliasblockfile 
as the start tag.
 /// Most notably, the summaryfile attribute refers to a file that does not 
yet, so when the project file is read back in
 /// 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)
 {
-/* TODO:
    if(IsSummaryAvailable())
    {
-      PCMAliasBlockFile::SaveXML(xmlFile);
+      SimpleBlockFile::SaveXML(xmlFile);
    }
    else
    {
-      xmlFile.StartTag(wxT("ODDecodeBlockFile"));
-
+      xmlFile.StartTag(wxT("oddecodeblockfile"));
+       //unlock to prevent deadlock and resume lock after.
+      mReadDataMutex.Unlock();
+      mFileNameMutex.Lock();
       xmlFile.WriteAttr(wxT("summaryfile"), mFileName.GetFullName());
-      xmlFile.WriteAttr(wxT("aliasfile"), mAliasedFileName.GetFullPath());
+      mFileNameMutex.Unlock();
+      mReadDataMutex.Lock();
+      xmlFile.WriteAttr(wxT("audiofile"), mAudioFileName.GetFullPath());
       xmlFile.WriteAttr(wxT("aliasstart"), mAliasStart);
       xmlFile.WriteAttr(wxT("aliaslen"), mLen);
       xmlFile.WriteAttr(wxT("aliaschannel"), mAliasChannel);
-      //these have not been computed yet.
-      //xmlFile.WriteAttr(wxT("min"), mMin);
-      //xmlFile.WriteAttr(wxT("max"), mMax);
-     // xmlFile.WriteAttr(wxT("rms"), mRMS);
+      xmlFile.WriteAttr(wxT("decodetype"), (size_t)mType);
 
-      xmlFile.EndTag(wxT("odpcmaliasblockfile"));
+      xmlFile.EndTag(wxT("oddecodeblockfile"));
    }
-*/
 }
 
 /// Constructs a ODPCMAliasBlockFile from the xml output of WriteXML.
 /// Also schedules the ODPCMAliasBlockFile for OD loading.
 BlockFile *ODDecodeBlockFile::BuildFromXML(DirManager &dm, const wxChar 
**attrs)
-{//TODO:
-//   wxFileName summaryFileName;
-//   wxFileName aliasFileName;
-//   sampleCount aliasStart=0, aliasLen=0;
-//   int aliasChannel=0;
-//   float min=0, max=0, rms=0;
-//   long nValue;
-//
-//
-//
-//   while(*attrs)
-//   {
-//      const wxChar *attr =  *attrs++;
-//      const wxChar *value = *attrs++;
-//      if (!value) 
-//         break;
-//
-//      const wxString strValue = value;
-//      if( !wxStricmp(attr, wxT("summaryfile")) )
-//      {
-//      
-//         // Can't use XMLValueChecker::IsGoodFileName here, but do part of 
its test.
-//         if (!XMLValueChecker::IsGoodFileString(strValue))
-//            return NULL;
-//
-//         #ifdef _WIN32
-//            if (strValue.Length() + 1 + dm.GetProjectDataDir().Length() > 
MAX_PATH)
-//               return NULL;
-//         #endif
-//
-//         dm.AssignFile(summaryFileName,value,FALSE);
-//      }
-//      else if( !wxStricmp(attr, wxT("aliasfile")) )
-//      {
-//         if (XMLValueChecker::IsGoodPathName(strValue))
-//            aliasFileName.Assign(strValue);
-//         else if (XMLValueChecker::IsGoodFileName(strValue, 
dm.GetProjectDataDir()))
-//            // Allow fallback of looking for the file name, located in the 
data directory.
-//            aliasFileName.Assign(dm.GetProjectDataDir(), strValue);
-//         else 
-//            return NULL;
-//      }
-//      else if (XMLValueChecker::IsGoodInt(strValue) && 
strValue.ToLong(&nValue)) 
-//      { // integer parameters
-//         if( !wxStricmp(attr, wxT("aliasstart")) )
-//            aliasStart = nValue;
-//         else if( !wxStricmp(attr, wxT("aliaslen")) )
-//            aliasLen = nValue;
-//         else if( !wxStricmp(attr, wxT("aliaschannel")) )
-//            aliasChannel = nValue;
-//            
-//         //The folowing attributes don't exist yet - not quite sure what to 
do with them yet.
-////         else if( !wxStricmp(attr, wxT("min")) )
-////            min = nValue;
-////         else if( !wxStricmp(attr, wxT("max")) )
-////            max = nValue;
-////         else if( !wxStricmp(attr, wxT("rms")) )
-////            rms = nValue;
-//      }
-//   }
-//
-//   //file doesn't exist, but IsGoodFileName Checks that it does - maybe we 
should have a different method to check for valid names?
-//   if ( /*!XMLValueChecker::IsGoodFileName(summaryFileName.GetFullName(), 
summaryFileName.GetPath(wxPATH_GET_VOLUME)) || */
-//         !XMLValueChecker::IsGoodFileName(aliasFileName.GetFullName(), 
aliasFileName.GetPath(wxPATH_GET_VOLUME)) || 
-//         (aliasLen <= 0) || (aliasLen < 0.0) || 
!XMLValueChecker::IsValidChannel(aliasChannel) || (rms < 0.0))
-//      return NULL;
-//
-//
-//   //TODO: schedule for OD Loading
-//   
-//   return new ODPCMAliasBlockFile(summaryFileName, aliasFileName,
-//                                aliasStart, aliasLen, aliasChannel);
-return NULL;
+{
+
+   wxFileName summaryFileName;
+   wxFileName audioFileName;
+   sampleCount aliasStart=0, aliasLen=0;
+   int aliasChannel=0;
+   long nValue;
+   unsigned int   decodeType=0;
+   float rms=0.0f;
+
+
+
+   while(*attrs)
+   {
+      const wxChar *attr =  *attrs++;
+      const wxChar *value = *attrs++;
+      if (!value) 
+         break;
+
+      const wxString strValue = value;
+      if( !wxStricmp(attr, wxT("summaryfile")) )
+      {
+      
+         // Can't use XMLValueChecker::IsGoodFileName here, but do part of its 
test.
+         if (!XMLValueChecker::IsGoodFileString(strValue))
+            return NULL;
+
+         #ifdef _WIN32
+            if (strValue.Length() + 1 + dm.GetProjectDataDir().Length() > 
MAX_PATH)
+               return NULL;
+         #endif
+
+         dm.AssignFile(summaryFileName,value,FALSE);
+      }
+      else if( !wxStricmp(attr, wxT("audiofile")) )
+      {
+         if (XMLValueChecker::IsGoodPathName(strValue))
+            audioFileName.Assign(strValue);
+         else if (XMLValueChecker::IsGoodFileName(strValue, 
dm.GetProjectDataDir()))
+            // Allow fallback of looking for the file name, located in the 
data directory.
+            audioFileName.Assign(dm.GetProjectDataDir(), strValue);
+         else 
+            return NULL;
+      }
+      else if (XMLValueChecker::IsGoodInt(strValue) && 
strValue.ToLong(&nValue)) 
+      { // integer parameters
+         if( !wxStricmp(attr, wxT("aliasstart")) )
+            aliasStart = nValue;
+         else if( !wxStricmp(attr, wxT("aliaslen")) )
+            aliasLen = nValue;
+         else if( !wxStricmp(attr, wxT("aliaschannel")) )
+            aliasChannel = nValue;
+         else if( !wxStricmp(attr, wxT("decodetype")) )
+            decodeType = nValue;
+      }
+   }
+
+   //file doesn't exist, but IsGoodFileName Checks that it does - maybe we 
should have a different method to check for valid names?
+   if ( /*!XMLValueChecker::IsGoodFileName(summaryFileName.GetFullName(), 
summaryFileName.GetPath(wxPATH_GET_VOLUME)) || */
+         !XMLValueChecker::IsGoodFileName(audioFileName.GetFullName(), 
audioFileName.GetPath(wxPATH_GET_VOLUME)) || 
+         (aliasLen <= 0) || (aliasLen < 0.0) || 
!XMLValueChecker::IsValidChannel(aliasChannel) || (rms < 0.0))
+      return NULL;
+   
+   return new ODDecodeBlockFile(summaryFileName, audioFileName,
+                                aliasStart, aliasLen, aliasChannel,decodeType);
+
 }
 
 

Index: ODDecodeBlockFile.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/blockfile/ODDecodeBlockFile.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ODDecodeBlockFile.h 9 Oct 2009 14:28:48 -0000       1.5
+++ ODDecodeBlockFile.h 11 Oct 2009 14:55:47 -0000      1.6
@@ -43,11 +43,11 @@
 
    /// Create a disk file and write summary and sample data to it
    ODDecodeBlockFile(wxFileName baseFileName,wxFileName audioFileName, 
sampleCount aliasStart,
-                     sampleCount aliasLen, int aliasChannel, int decodeType);
+                     sampleCount aliasLen, int aliasChannel, unsigned int 
decodeType);
    /// Create the memory structure to refer to the given block file
    ODDecodeBlockFile(wxFileName existingFile, wxFileName audioFileName, 
sampleCount aliasStart,
-                     sampleCount aliasLen, int aliasChannel, int decodeType,
-                   float min, float max, float rms);
+                     sampleCount aliasLen, int aliasChannel, unsigned int 
decodeType,
+                   float min, float max, float rms, bool dataAvailable);
 
    virtual ~ODDecodeBlockFile();   
    //checks to see if summary data has been computed and written to disk yet.  
Thread safe.  Blocks if we are writing summary data.
@@ -109,8 +109,8 @@
    virtual bool ReadSummary(void *data);
    
    ///Returns the type of audiofile this blockfile is loaded from.
-   virtual int GetDecodeType(){return mType;}
-   virtual void SetDecodeType(int type){mType=type;}
+   virtual unsigned int GetDecodeType(){return mType;}
+   virtual void SetDecodeType(unsigned int type){mType=type;}
    
    ///sets the amount of samples the clip associated with this blockfile is 
offset in the wavetrack (non effecting)
    void SetClipOffset(sampleCount numSamples){mClipOffset= numSamples;}
@@ -152,7 +152,7 @@
    virtual void *CalcSummary(samplePtr buffer, sampleCount len,
                              sampleFormat format);
    //The on demand type.
-   int mType;
+   unsigned int mType;
    
    ///This lock is for the filename (string) of the blockfile that contains 
summary/audio data 
    ///after decoding


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