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

Modified Files:
        DirManager.cpp Project.cpp Sequence.cpp Sequence.h 
        WaveTrack.cpp WaveTrack.h 
Log Message:
Checking in saving ability for FLAC on-demand loading.


Index: Sequence.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Sequence.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- Sequence.h  9 Oct 2009 14:28:48 -0000       1.24
+++ Sequence.h  11 Oct 2009 14:55:47 -0000      1.25
@@ -91,6 +91,9 @@
 
    bool AppendCoded(wxString fName, sampleCount start,
                             sampleCount len, int channel, int decodeType);
+                            
+   ///gets an int with OD flags so that we can determine which ODTasks should 
be run on this track after save/open, etc.
+   unsigned int GetODFlags();                            
                     
    // Append a blockfile. The blockfile pointer is then "owned" by the
    // sequence. This function is used by the recording log crash recovery

Index: WaveTrack.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/WaveTrack.h,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- WaveTrack.h 9 Oct 2009 14:28:48 -0000       1.75
+++ WaveTrack.h 11 Oct 2009 14:55:47 -0000      1.76
@@ -184,6 +184,9 @@
    ///Type of encoded file this is, such as eODFLAC
    bool AppendCoded(wxString fName, sampleCount start,
                             sampleCount len, int channel, int decodeType);
+                            
+   ///gets an int with OD flags so that we can determine which ODTasks should 
be run on this track after save/open, etc.
+   unsigned int GetODFlags();
                     
    ///Deletes all clips' wavecaches.  Careful, This may not be threadsafe.
    void DeleteWaveCaches();

Index: WaveTrack.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/WaveTrack.cpp,v
retrieving revision 1.168
retrieving revision 1.169
diff -u -d -r1.168 -r1.169
--- WaveTrack.cpp       9 Oct 2009 14:28:48 -0000       1.168
+++ WaveTrack.cpp       11 Oct 2009 14:55:47 -0000      1.169
@@ -1295,6 +1295,19 @@
    return GetLastOrCreateClip()->AppendCoded(fName, start, len, channel, 
decodeType);
 }
 
+///gets an int with OD flags so that we can determine which ODTasks should be 
run on this track after save/open, etc.
+unsigned int WaveTrack::GetODFlags()
+{
+   unsigned int ret = 0;
+   for (WaveClipList::compatibility_iterator it=GetClipIterator(); it; 
it=it->GetNext())
+   {
+      WaveClip* clip = it->GetData();
+      ret = ret | clip->GetSequence()->GetODFlags();
+   }
+   return ret;
+}
+
+
 sampleCount WaveTrack::GetBestBlockSize(sampleCount s)
 {
    sampleCount bestBlockSize = GetMaxBlockSize();

Index: DirManager.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/DirManager.cpp,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -d -r1.91 -r1.92
--- DirManager.cpp      9 Oct 2009 14:28:48 -0000       1.91
+++ DirManager.cpp      11 Oct 2009 14:55:46 -0000      1.92
@@ -884,6 +884,11 @@
       //in the ODMan and check it later.
       ODManager::MarkLoadedODFlag();
    }
+   else if( !wxStricmp(tag, wxT("oddecodeblockfile")) )
+   {
+      pBlockFile = ODDecodeBlockFile::BuildFromXML(*this, attrs);
+      ODManager::MarkLoadedODFlag();
+   }
    else if( !wxStricmp(tag, wxT("blockfile")) ||
             !wxStricmp(tag, wxT("legacyblockfile")) ) {
       // Support Audacity version 1.1.1 project files

Index: Sequence.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Sequence.cpp,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- Sequence.cpp        9 Oct 2009 14:28:48 -0000       1.59
+++ Sequence.cpp        11 Oct 2009 14:55:47 -0000      1.60
@@ -40,6 +40,7 @@
 #include "Sequence.h"
 
 #include "BlockFile.h"
+#include "ODDecodeBlockFile.h"
 #include "DirManager.h"
 
 #include "blockfile/SimpleBlockFile.h"
@@ -671,6 +672,19 @@
    return true;
 }
 
+///gets an int with OD flags so that we can determine which ODTasks should be 
run on this track after save/open, etc.
+unsigned int Sequence::GetODFlags()
+{
+   unsigned int ret = 0;
+   for (unsigned int i = 0; i < mBlock->Count(); i++){
+      if(!mBlock->Item(i)->f->IsDataAvailable())
+         ret = ret|((ODDecodeBlockFile*)mBlock->Item(i)->f)->GetDecodeType();
+      else if(!mBlock->Item(i)->f->IsSummaryAvailable())
+         ret = ret|ODTask::eODPCMSummary;
+   }
+   return ret;
+}
+
 sampleCount Sequence::GetBestBlockSize(sampleCount start) const
 {
    // This method returns a nice number of samples you should try to grab in

Index: Project.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Project.cpp,v
retrieving revision 1.459
retrieving revision 1.460
diff -u -d -r1.459 -r1.460
--- Project.cpp 10 Oct 2009 14:44:25 -0000      1.459
+++ Project.cpp 11 Oct 2009 14:55:47 -0000      1.460
@@ -130,6 +130,7 @@
 #include "ondemand/ODManager.h"
 #include "ondemand/ODTask.h"
 #include "ondemand/ODComputeSummaryTask.h"
+#include "ondemand/ODDecodeFlacTask.h"
 #include "LoadModules.h"
 
 #include "Theme.h"
@@ -2391,22 +2392,51 @@
       TrackListIterator triter(mTracks);         
       tr = triter.First();
       
-      ODComputeSummaryTask* computeTask;
-      bool odUsed = false;
+      std::vector<ODTask*> newTasks;
+      ODTask* newTask;
+      //std::vector<ODDecodeTask*> decodeTasks;
+      unsigned int createdODTasks=0;
       while (tr) {
-         if (tr->GetKind() == Track::Wave)
-         {
-            if(!odUsed)
-            {
-               computeTask=new ODComputeSummaryTask;
-               odUsed=true;
+         if (tr->GetKind() == Track::Wave) {
+            //check the track for blocks that need decoding.  
+            //There may be more than one type e.g. FLAC/FFMPEG/lame 
+            unsigned int odFlags;
+            odFlags=((WaveTrack*)tr)->GetODFlags();
+            
+            //add the track to the already created tasks that correspond to 
the od flags in the wavetrack.
+            for(unsigned int i=0;i<newTasks.size();i++) {
+               if(newTasks[i]->GetODType() & odFlags)
+                  newTasks[i]->AddWaveTrack((WaveTrack*)tr);
             }
-            computeTask->AddWaveTrack((WaveTrack*)tr);
+            
+            //create whatever new tasks we need to.
+            //we want at most one instance of each class for the project
+            while((odFlags|createdODTasks) != createdODTasks)
+            {
+               newTask=NULL;
+               if(!(createdODTasks&ODTask::eODFLAC) && odFlags & 
ODTask::eODFLAC) {
+                  newTask= new ODDecodeFlacTask;
+                  createdODTasks= createdODTasks | ODTask::eODFLAC;
+               }
+               else if(!(createdODTasks&ODTask::eODPCMSummary) && odFlags & 
ODTask::eODPCMSummary) {
+                  newTask=new ODComputeSummaryTask;
+                  createdODTasks= createdODTasks | ODTask::eODPCMSummary;
+               }
+               else {
+                  printf("unrecognized OD Flag in blockfile.\n");
+                  break;
+               }
+               if(newTask)
+               {
+                  newTask->AddWaveTrack((WaveTrack*)tr);
+                  newTasks.push_back(newTask);
+               }
+            }            
          }
          tr = triter.Next();
       }
-      if(odUsed)
-         ODManager::Instance()->AddNewTask(computeTask);
+      for(unsigned int i=0;i<newTasks.size();i++) 
+         ODManager::Instance()->AddNewTask(newTasks[i]);
          
          //release the flag.
       ODManager::UnmarkLoadedODFlag();


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