Update of /cvsroot/audacity/audacity-src/src/import In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv8261/import
Modified Files: ImportFLAC.cpp Log Message: Addition of OD flac support struture. This feature is off by default and a #define (EXPERIMENTAL_OD_FLAC) is used to contain it. It does not work yet, but I wanted to check in now because the code has been accumulating and the changes I have made are inert. FLACs will still import as they always have. Index: ImportFLAC.cpp =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/import/ImportFLAC.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- ImportFLAC.cpp 1 Jun 2009 15:42:50 -0000 1.37 +++ ImportFLAC.cpp 8 Oct 2009 14:32:09 -0000 1.38 @@ -77,6 +77,8 @@ #include "../Prefs.h" #include "../WaveTrack.h" #include "ImportPlugin.h" +#include "../ondemand/ODDecodeFlacTask.h" +#include "../ondemand/ODManager.h" #ifdef USE_LIBID3TAG extern "C" { @@ -91,6 +93,9 @@ #undef LEGACY_FLAC #endif + +//#define EXPERIMENTAL_OD_FLAC + class FLACImportFileHandle; class MyFLACFile : public FLAC::Decoder::File @@ -168,6 +173,7 @@ bool mStreamInfoDone; int mUpdateResult; WaveTrack **mChannels; + ODDecodeFlacTask *mDecoderTask; }; @@ -335,6 +341,30 @@ bool FLACImportFileHandle::Init() { +#ifdef EXPERIMENTAL_OD_FLAC + mDecoderTask=new ODDecodeFlacTask; + + ODFlacDecoder* odDecoder = (ODFlacDecoder*)mDecoderTask->CreateFileDecoder(mFilename); + if(odDecoder && !odDecoder->ReadHeader()) + { + //delete the task only if it failed to read - otherwise the OD man takes care of it. + delete mDecoderTask; + return false; + } + //copy the meta data over to the class + + mSampleRate=odDecoder->mSampleRate; + mNumChannels=odDecoder->mNumChannels; + mBitsPerSample=odDecoder->mBitsPerSample; + + mNumSamples=odDecoder->mNumSamples; + mBitsPerSample=odDecoder->mBitsPerSample; + mFormat=odDecoder->mFormat; + mStreamInfoDone=odDecoder->mStreamInfoDone; + + + return true; +#endif #ifdef LEGACY_FLAC bool success = mFile->set_filename(OSINPUT(mFilename)); if (!success) { @@ -429,11 +459,58 @@ } } + +//Start OD + bool useOD = false; +#ifdef EXPERIMENTAL_OD_FLAC + useOD=true; +#endif + #ifdef LEGACY_FLAC bool res = (mFile->process_until_end_of_file() != 0); #else - bool res = (mFile->process_until_end_of_stream() != 0); + bool res = true; + if(!useOD) + res = (mFile->process_until_end_of_stream() != 0); #endif + //add the task to the ODManager + if(useOD) + { + sampleCount fileTotalFrames = mNumSamples; + sampleCount maxBlockSize = mChannels[0]->GetMaxBlockSize(); + for (sampleCount i = 0; i < fileTotalFrames; i += maxBlockSize) { + sampleCount blockLen = maxBlockSize; + if (i + blockLen > fileTotalFrames) + blockLen = fileTotalFrames - i; + + for (c = 0; c < mNumChannels; c++) + mChannels[c]->AppendCoded(mFilename, i, blockLen, c); + + mUpdateResult = mProgress->Update(i, fileTotalFrames); + if (mUpdateResult != eProgressSuccess) + break; + } + + + ODDecodeFlacTask* mDecoderTask = new ODDecodeFlacTask; + + bool moreThanStereo = mNumChannels>2; + for (c = 0; c < mNumChannels; c++) + { + mDecoderTask->AddWaveTrack(mChannels[c]); + if(moreThanStereo) + { + //if we have 3 more channels, they get imported on seperate tracks, so we add individual tasks for each. + ODManager::Instance()->AddNewTask(mDecoderTask); + mDecoderTask=new ODDecodeFlacTask; //TODO: see if we need to use clone to keep the metadata. + } + } + //if we have mono or a linked track (stereo), we add ONE task for the one linked wave track + if(!moreThanStereo) + ODManager::Instance()->AddNewTask(mDecoderTask); + } +//END OD + if (mUpdateResult == eProgressFailed || mUpdateResult == eProgressCancelled) { for(c = 0; c < mNumChannels; c++) { @@ -472,8 +549,11 @@ FLACImportFileHandle::~FLACImportFileHandle() { + //don't delete mFile if we are using OD. +#ifndef EXPERIMENTAL_OD_FLAC mFile->finish(); delete mFile; +#endif } #endif /* USE_LIBFLAC */ ------------------------------------------------------------------------------ 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