WaveClip does not depend on ondemand files besides ODTaskThread...
... Lifting the specification of factory function arguments for Sequence even higher This frees ODPCMAliasBlockFile from cycles
This commit is contained in:
parent
91a2ff2560
commit
f1b04c79d8
|
@ -1448,51 +1448,17 @@ void WaveClip::Append(samplePtr buffer, sampleFormat format,
|
|||
}
|
||||
}
|
||||
|
||||
#include "blockfile/ODPCMAliasBlockFile.h"
|
||||
void WaveClip::AppendAlias(const FilePath &fName, sampleCount start,
|
||||
size_t len, int channel,bool useOD)
|
||||
void WaveClip::AppendBlockFile( const BlockFileFactory &factory, size_t len)
|
||||
// STRONG-GUARANTEE
|
||||
{
|
||||
// use STRONG-GUARANTEE
|
||||
mSequence->AppendBlockFile(
|
||||
[&]( wxFileNameWrapper filePath, size_t len ) {
|
||||
return useOD
|
||||
? make_blockfile<ODPCMAliasBlockFile>(
|
||||
std::move(filePath), wxFileNameWrapper{ fName },
|
||||
start, len, channel)
|
||||
: make_blockfile<PCMAliasBlockFile>(
|
||||
std::move(filePath), wxFileNameWrapper{ fName },
|
||||
start, len, channel);
|
||||
},
|
||||
len
|
||||
);
|
||||
mSequence->AppendBlockFile( factory, len );
|
||||
|
||||
// use NOFAIL-GUARANTEE
|
||||
UpdateEnvelopeTrackLen();
|
||||
MarkChanged();
|
||||
}
|
||||
|
||||
#include "blockfile/ODDecodeBlockFile.h"
|
||||
void WaveClip::AppendCoded(const FilePath &fName, sampleCount start,
|
||||
size_t len, int channel, int decodeType)
|
||||
// STRONG-GUARANTEE
|
||||
{
|
||||
// use STRONG-GUARANTEE
|
||||
mSequence->AppendBlockFile(
|
||||
[&]( wxFileNameWrapper filePath, size_t len ) {
|
||||
return make_blockfile<ODDecodeBlockFile>(
|
||||
std::move(filePath), wxFileNameWrapper{ fName },
|
||||
start, len, channel, decodeType);
|
||||
},
|
||||
len
|
||||
) ;
|
||||
|
||||
// use NOFAIL-GUARANTEE
|
||||
UpdateEnvelopeTrackLen();
|
||||
MarkChanged();
|
||||
}
|
||||
|
||||
|
||||
void WaveClip::Flush()
|
||||
// NOFAIL-GUARANTEE that the clip will be in a flushed state.
|
||||
// PARTIAL-GUARANTEE in case of exceptions:
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include <vector>
|
||||
|
||||
class BlockArray;
|
||||
class BlockFile;
|
||||
using BlockFilePtr = std::shared_ptr<BlockFile>;
|
||||
class DirManager;
|
||||
class Envelope;
|
||||
class ProgressDialog;
|
||||
|
@ -32,6 +34,7 @@ class Sequence;
|
|||
class SpectrogramSettings;
|
||||
class WaveCache;
|
||||
class WaveTrackCache;
|
||||
class wxFileNameWrapper;
|
||||
|
||||
class SpecCache {
|
||||
public:
|
||||
|
@ -281,11 +284,9 @@ public:
|
|||
/// Flush must be called after last Append
|
||||
void Flush();
|
||||
|
||||
void AppendAlias(const FilePath &fName, sampleCount start,
|
||||
size_t len, int channel,bool useOD);
|
||||
|
||||
void AppendCoded(const FilePath &fName, sampleCount start,
|
||||
size_t len, int channel, int decodeType);
|
||||
using BlockFileFactory =
|
||||
std::function< BlockFilePtr( wxFileNameWrapper, size_t /* len */ ) >;
|
||||
void AppendBlockFile( const BlockFileFactory &factory, size_t len);
|
||||
|
||||
/// This name is consistent with WaveTrack::Clear. It performs a "Cut"
|
||||
/// operation (but without putting the cutted audio to the clipboard)
|
||||
|
|
|
@ -1506,20 +1506,6 @@ void WaveTrack::Append(samplePtr buffer, sampleFormat format,
|
|||
blockFileLog);
|
||||
}
|
||||
|
||||
void WaveTrack::AppendAlias(const FilePath &fName, sampleCount start,
|
||||
size_t len, int channel,bool useOD)
|
||||
// STRONG-GUARANTEE
|
||||
{
|
||||
RightmostOrNewClip()->AppendAlias(fName, start, len, channel, useOD);
|
||||
}
|
||||
|
||||
void WaveTrack::AppendCoded(const FilePath &fName, sampleCount start,
|
||||
size_t len, int channel, int decodeType)
|
||||
// STRONG-GUARANTEE
|
||||
{
|
||||
RightmostOrNewClip()->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.
|
||||
#include "blockfile/ODDecodeBlockFile.h"
|
||||
unsigned int WaveTrack::GetODFlags() const
|
||||
|
|
|
@ -220,16 +220,6 @@ private:
|
|||
/// Flush must be called after last Append
|
||||
void Flush();
|
||||
|
||||
void AppendAlias(const FilePath &fName, sampleCount start,
|
||||
size_t len, int channel,bool useOD);
|
||||
|
||||
///for use with On-Demand decoding of compressed files.
|
||||
///decodeType should be an enum from ODDecodeTask that specifies what
|
||||
///Type of encoded file this is, such as eODFLAC
|
||||
//vvv Why not use the ODTypeEnum typedef to enforce that for the parameter?
|
||||
void AppendCoded(const FilePath &fName, sampleCount start,
|
||||
size_t 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() const;
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@ Licensed under the GNU General Public License v2 or later
|
|||
#include <wx/wxprec.h>
|
||||
|
||||
#include "../FFmpeg.h" // which brings in avcodec.h, avformat.h
|
||||
#include "../WaveClip.h"
|
||||
#include "../blockfile/ODDecodeBlockFile.h"
|
||||
#include "../ondemand/ODManager.h"
|
||||
#ifndef WX_PRECOMP
|
||||
// Include your minimal set of headers here, or wx.h
|
||||
|
@ -596,7 +598,14 @@ ProgressResult FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
|
|||
const auto blockLen =
|
||||
limitSampleBufferSize( maxBlockSize, sampleDuration - i );
|
||||
|
||||
t->AppendCoded(mFilename, i, blockLen, c, ODTask::eODFFMPEG);
|
||||
t->RightmostOrNewClip()->AppendBlockFile(
|
||||
[&]( wxFileNameWrapper filePath, size_t len ) {
|
||||
return make_blockfile<ODDecodeBlockFile>(
|
||||
std::move(filePath), wxFileNameWrapper{ mFilename },
|
||||
i, len, c, ODTask::eODFFMPEG);
|
||||
},
|
||||
blockLen
|
||||
);
|
||||
|
||||
// This only works well for single streams since we assume
|
||||
// each stream is of the same duration and channels
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
#include "ImportPlugin.h"
|
||||
|
||||
#include "../Tags.h"
|
||||
#include "../WaveClip.h"
|
||||
#include "../blockfile/ODDecodeBlockFile.h"
|
||||
#include "../prefs/QualityPrefs.h"
|
||||
#include "../widgets/ProgressDialog.h"
|
||||
|
||||
|
@ -483,7 +485,14 @@ ProgressResult FLACImportFileHandle::Import(TrackFactory *trackFactory,
|
|||
|
||||
auto iter = mChannels.begin();
|
||||
for (size_t c = 0; c < mNumChannels; ++c, ++iter)
|
||||
iter->get()->AppendCoded(mFilename, i, blockLen, c, ODTask::eODFLAC);
|
||||
iter->get()->RightmostOrNewClip()->AppendBlockFile(
|
||||
[&]( wxFileNameWrapper filePath, size_t len ) {
|
||||
return make_blockfile<ODDecodeBlockFile>(
|
||||
std::move(filePath), wxFileNameWrapper{ mFilename },
|
||||
i, len, c, ODTask::eODFLAC);
|
||||
},
|
||||
blockLen
|
||||
);
|
||||
|
||||
mUpdateResult = mProgress->Update(
|
||||
i.as_long_long(),
|
||||
|
|
|
@ -36,8 +36,10 @@
|
|||
|
||||
#include "sndfile.h"
|
||||
|
||||
#include "../WaveClip.h"
|
||||
#include "../ondemand/ODManager.h"
|
||||
#include "../ondemand/ODComputeSummaryTask.h"
|
||||
#include "../blockfile/ODPCMAliasBlockFile.h"
|
||||
#include "../prefs/QualityPrefs.h"
|
||||
#include "../widgets/ProgressDialog.h"
|
||||
|
||||
|
@ -407,7 +409,18 @@ ProgressResult PCMImportFileHandle::Import(TrackFactory *trackFactory,
|
|||
|
||||
auto iter = channels.begin();
|
||||
for (int c = 0; c < mInfo.channels; ++iter, ++c)
|
||||
iter->get()->AppendAlias(mFilename, i, blockLen, c,useOD);
|
||||
iter->get()->RightmostOrNewClip()->AppendBlockFile(
|
||||
[&]( wxFileNameWrapper filePath, size_t len ) {
|
||||
return useOD
|
||||
? make_blockfile<ODPCMAliasBlockFile>(
|
||||
std::move(filePath), wxFileNameWrapper{ mFilename },
|
||||
i, len, c)
|
||||
: make_blockfile<PCMAliasBlockFile>(
|
||||
std::move(filePath), wxFileNameWrapper{ mFilename },
|
||||
i, len, c);
|
||||
},
|
||||
blockLen
|
||||
);
|
||||
|
||||
if (++updateCounter == 50) {
|
||||
updateResult = mProgress->Update(
|
||||
|
|
Loading…
Reference in New Issue