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:
@@ -554,15 +554,16 @@ int FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
|
|||||||
int res = eProgressSuccess;
|
int res = eProgressSuccess;
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_OD_FFMPEG
|
#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;
|
//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.
|
//so for OD loading we create the tracks and releasee the modal lock after starting the ODTask.
|
||||||
|
if (mUsingOD) {
|
||||||
std::vector<ODDecodeFFmpegTask*> tasks;
|
std::vector<ODDecodeFFmpegTask*> tasks;
|
||||||
//append blockfiles to each stream and add an individual ODDecodeTask for each one.
|
//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);
|
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.
|
//each stream has different duration. We need to know it if seeking is to be allowed.
|
||||||
sampleCount sampleDuration = 0;
|
sampleCount sampleDuration = 0;
|
||||||
@@ -571,18 +572,16 @@ int FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
|
|||||||
else
|
else
|
||||||
sampleDuration = ((sampleCount)mFormatContext->duration *mScs[s]->m_stream->codec->sample_rate) / AV_TIME_BASE;
|
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 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];
|
WaveTrack *t = mChannels[s][c];
|
||||||
odTask->AddWaveTrack(t);
|
odTask->AddWaveTrack(t);
|
||||||
|
|
||||||
sampleCount maxBlockSize = t->GetMaxBlockSize();
|
sampleCount maxBlockSize = t->GetMaxBlockSize();
|
||||||
//use the maximum blockfile size to divide the sections (about 11secs per blockfile at 44.1khz)
|
//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;
|
sampleCount blockLen = maxBlockSize;
|
||||||
if (i + blockLen > sampleDuration)
|
if (i + blockLen > sampleDuration)
|
||||||
blockLen = sampleDuration - i;
|
blockLen = sampleDuration - i;
|
||||||
@@ -600,8 +599,7 @@ int FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
|
|||||||
tasks.push_back(odTask);
|
tasks.push_back(odTask);
|
||||||
}
|
}
|
||||||
//Now we add the tasks and let them run, or delete them if the user cancelled
|
//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)
|
if(res==eProgressSuccess)
|
||||||
ODManager::Instance()->AddNewTask(tasks[i]);
|
ODManager::Instance()->AddNewTask(tasks[i]);
|
||||||
else
|
else
|
||||||
@@ -609,8 +607,8 @@ int FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
|
|||||||
delete tasks[i];
|
delete tasks[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else //ifndef EXPERIMENTAL_OD_FFMPEG
|
} else {
|
||||||
|
#endif
|
||||||
streamContext *sc = NULL;
|
streamContext *sc = NULL;
|
||||||
|
|
||||||
// Read next frame.
|
// Read next frame.
|
||||||
@@ -656,6 +654,8 @@ int FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef EXPERIMENTAL_OD_FFMPEG
|
||||||
|
} // else -- !mUsingOD == true
|
||||||
#endif //EXPERIMENTAL_OD_FFMPEG
|
#endif //EXPERIMENTAL_OD_FFMPEG
|
||||||
|
|
||||||
// Something bad happened - destroy everything!
|
// Something bad happened - destroy everything!
|
||||||
|
|||||||
@@ -135,6 +135,11 @@ void LibraryPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
S.EndTwoColumn();
|
S.EndTwoColumn();
|
||||||
|
#ifdef EXPERIMENTAL_OD_FFMPEG
|
||||||
|
S.TieCheckBox(_("Allow &background on-demand loading"),
|
||||||
|
wxT("/Library/FFmpegOnDemand"),
|
||||||
|
false);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
S.EndStatic();
|
S.EndStatic();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user