1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-27 15:53:49 +01:00

add on demand preference to library pane

This commit is contained in:
mchinen
2012-06-01 06:11:15 +00:00
parent 816b58bc08
commit 3dd37349fc
2 changed files with 51 additions and 46 deletions

View File

@@ -554,15 +554,16 @@ int FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
int res = eProgressSuccess;
#ifdef EXPERIMENTAL_OD_FFMPEG
mUsingOD = true; //TODO: for now just use it - later use a prefs
mUsingOD = false;
gPrefs->Read(wxT("/Library/FFmpegOnDemand"), &mUsingOD);
//at this point we know the file is good and that we have to load the number of channels in mScs[s]->m_stream->codec->channels;
//so for OD loading we create the tracks and releasee the modal lock after starting the ODTask.
if (mUsingOD) {
std::vector<ODDecodeFFmpegTask*> tasks;
//append blockfiles to each stream and add an individual ODDecodeTask for each one.
for (int s = 0; s < mNumStreams; s++)
{
for (int s = 0; s < mNumStreams; s++) {
ODDecodeFFmpegTask* odTask=new ODDecodeFFmpegTask(mScs,mNumStreams,mChannels,mFormatContext, s);
ODFileDecoder* odDecoder = (ODFileDecoder*)odTask->CreateFileDecoder(mFilename);
ODFileDecoder* odDecoder = odTask->CreateFileDecoder(mFilename);
//each stream has different duration. We need to know it if seeking is to be allowed.
sampleCount sampleDuration = 0;
@@ -571,18 +572,16 @@ int FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
else
sampleDuration = ((sampleCount)mFormatContext->duration *mScs[s]->m_stream->codec->sample_rate) / AV_TIME_BASE;
// printf(" OD duration samples %qi, sr %d, secs %d\n",sampleDuration, (int)mScs[s]->m_stream->codec->sample_rate,(int)sampleDuration/mScs[s]->m_stream->codec->sample_rate);
// printf(" OD duration samples %qi, sr %d, secs %d\n",sampleDuration, (int)mScs[s]->m_stream->codec->sample_rate,(int)sampleDuration/mScs[s]->m_stream->codec->sample_rate);
//for each wavetrack within the stream add coded blockfiles
for (int c = 0; c < mScs[s]->m_stream->codec->channels; c++)
{
for (int c = 0; c < mScs[s]->m_stream->codec->channels; c++) {
WaveTrack *t = mChannels[s][c];
odTask->AddWaveTrack(t);
sampleCount maxBlockSize = t->GetMaxBlockSize();
//use the maximum blockfile size to divide the sections (about 11secs per blockfile at 44.1khz)
for (sampleCount i = 0; i < sampleDuration; i += maxBlockSize)
{
for (sampleCount i = 0; i < sampleDuration; i += maxBlockSize) {
sampleCount blockLen = maxBlockSize;
if (i + blockLen > sampleDuration)
blockLen = sampleDuration - i;
@@ -600,8 +599,7 @@ int FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
tasks.push_back(odTask);
}
//Now we add the tasks and let them run, or delete them if the user cancelled
for(int i=0; i < (int)tasks.size(); i++)
{
for(int i=0; i < (int)tasks.size(); i++) {
if(res==eProgressSuccess)
ODManager::Instance()->AddNewTask(tasks[i]);
else
@@ -609,8 +607,8 @@ int FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
delete tasks[i];
}
}
#else //ifndef EXPERIMENTAL_OD_FFMPEG
} else {
#endif
streamContext *sc = NULL;
// Read next frame.
@@ -656,6 +654,8 @@ int FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
}
}
}
#ifdef EXPERIMENTAL_OD_FFMPEG
} // else -- !mUsingOD == true
#endif //EXPERIMENTAL_OD_FFMPEG
// Something bad happened - destroy everything!

View File

@@ -135,6 +135,11 @@ void LibraryPrefs::PopulateOrExchange(ShuttleGui & S)
#endif
}
S.EndTwoColumn();
#ifdef EXPERIMENTAL_OD_FFMPEG
S.TieCheckBox(_("Allow &background on-demand loading"),
wxT("/Library/FFmpegOnDemand"),
false);
#endif
}
S.EndStatic();
}