mirror of
https://github.com/cookiengineer/audacity
synced 2026-01-23 17:25:54 +01:00
More aup import review (#656)
* More format fixes on import: beware sequences with differing format... ... It could happen. When collecting file information to be used in the second pass, record the correct format for each. Don't mistakenly use whatever was the format of the last read Sequence for all files. This only matters for the avoidance of unnecessary sample format conversions when finally appending samples to tracks. It won't affect the space ultimately occupied in the database. * Cautions against double throw in a finally block * Fix some Doxygen in ImportAUP.cpp
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
/**********************************************************************
|
/*!********************************************************************
|
||||||
|
|
||||||
Audacity: A Digital Audio Editor
|
Audacity: A Digital Audio Editor
|
||||||
|
|
||||||
ImportAUP.cpp
|
@file ImportAUP.cpp
|
||||||
|
@brief Upgrading project file formats from before version 3
|
||||||
|
|
||||||
*//****************************************************************//**
|
*//****************************************************************//**
|
||||||
|
|
||||||
\class AUPmportFileHandle
|
\class AUPImportFileHandle
|
||||||
\brief An ImportFileHandle for AUP files (pre-AUP3)
|
\brief An ImportFileHandle for AUP files (pre-AUP3)
|
||||||
|
|
||||||
*//****************************************************************//**
|
*//****************************************************************//**
|
||||||
@@ -134,14 +135,18 @@ private:
|
|||||||
bool HandleSilentBlockFile(XMLTagHandler *&handle);
|
bool HandleSilentBlockFile(XMLTagHandler *&handle);
|
||||||
bool HandlePCMAliasBlockFile(XMLTagHandler *&handle);
|
bool HandlePCMAliasBlockFile(XMLTagHandler *&handle);
|
||||||
|
|
||||||
|
// Called in first pass to collect information about blocks
|
||||||
void AddFile(sampleCount len,
|
void AddFile(sampleCount len,
|
||||||
|
sampleFormat format,
|
||||||
const FilePath &filename = wxEmptyString,
|
const FilePath &filename = wxEmptyString,
|
||||||
sampleCount origin = 0,
|
sampleCount origin = 0,
|
||||||
int channel = 0);
|
int channel = 0);
|
||||||
|
|
||||||
|
// These two use the collected file information in a second pass
|
||||||
bool AddSilence(sampleCount len);
|
bool AddSilence(sampleCount len);
|
||||||
bool AddSamples(const FilePath &filename,
|
bool AddSamples(const FilePath &filename,
|
||||||
sampleCount len,
|
sampleCount len,
|
||||||
|
sampleFormat format,
|
||||||
sampleCount origin = 0,
|
sampleCount origin = 0,
|
||||||
int channel = 0);
|
int channel = 0);
|
||||||
|
|
||||||
@@ -181,6 +186,7 @@ private:
|
|||||||
WaveClip *clip;
|
WaveClip *clip;
|
||||||
FilePath path;
|
FilePath path;
|
||||||
sampleCount len;
|
sampleCount len;
|
||||||
|
sampleFormat format;
|
||||||
sampleCount origin;
|
sampleCount origin;
|
||||||
int channel;
|
int channel;
|
||||||
} fileinfo;
|
} fileinfo;
|
||||||
@@ -341,7 +347,7 @@ ProgressResult AUPImportFileHandle::Import(WaveTrackFactory *WXUNUSED(trackFacto
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddSamples(fi.path, fi.len, fi.origin, fi.channel);
|
AddSamples(fi.path, fi.len, fi.format, fi.origin, fi.channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
processed += fi.len;
|
processed += fi.len;
|
||||||
@@ -1215,7 +1221,7 @@ bool AUPImportFileHandle::HandleSimpleBlockFile(XMLTagHandler *&handler)
|
|||||||
|
|
||||||
// Do not set the handler - already handled
|
// Do not set the handler - already handled
|
||||||
|
|
||||||
AddFile(len, filename);
|
AddFile(len, mFormat, filename);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1251,7 +1257,7 @@ bool AUPImportFileHandle::HandleSilentBlockFile(XMLTagHandler *&handler)
|
|||||||
|
|
||||||
// Do not set the handler - already handled
|
// Do not set the handler - already handled
|
||||||
|
|
||||||
AddFile(len);
|
AddFile(len, mFormat);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1329,14 +1335,15 @@ bool AUPImportFileHandle::HandlePCMAliasBlockFile(XMLTagHandler *&handler)
|
|||||||
// Do not set the handler - already handled
|
// Do not set the handler - already handled
|
||||||
|
|
||||||
if (filename.IsOk())
|
if (filename.IsOk())
|
||||||
AddFile(len, filename.GetFullPath(), start, channel);
|
AddFile(len, mFormat, filename.GetFullPath(), start, channel);
|
||||||
else
|
else
|
||||||
AddFile(len); // will add silence instead
|
AddFile(len, mFormat); // will add silence instead
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AUPImportFileHandle::AddFile(sampleCount len,
|
void AUPImportFileHandle::AddFile(sampleCount len,
|
||||||
|
sampleFormat format,
|
||||||
const FilePath &filename /* = wxEmptyString */,
|
const FilePath &filename /* = wxEmptyString */,
|
||||||
sampleCount origin /* = 0 */,
|
sampleCount origin /* = 0 */,
|
||||||
int channel /* = 0 */)
|
int channel /* = 0 */)
|
||||||
@@ -1346,6 +1353,7 @@ void AUPImportFileHandle::AddFile(sampleCount len,
|
|||||||
fi.clip = mClip;
|
fi.clip = mClip;
|
||||||
fi.path = filename;
|
fi.path = filename;
|
||||||
fi.len = len;
|
fi.len = len;
|
||||||
|
fi.format = format,
|
||||||
fi.origin = origin,
|
fi.origin = origin,
|
||||||
fi.channel = channel;
|
fi.channel = channel;
|
||||||
|
|
||||||
@@ -1374,6 +1382,7 @@ bool AUPImportFileHandle::AddSilence(sampleCount len)
|
|||||||
// import to continue.
|
// import to continue.
|
||||||
bool AUPImportFileHandle::AddSamples(const FilePath &filename,
|
bool AUPImportFileHandle::AddSamples(const FilePath &filename,
|
||||||
sampleCount len,
|
sampleCount len,
|
||||||
|
sampleFormat format,
|
||||||
sampleCount origin /* = 0 */,
|
sampleCount origin /* = 0 */,
|
||||||
int channel /* = 0 */)
|
int channel /* = 0 */)
|
||||||
{
|
{
|
||||||
@@ -1403,7 +1412,11 @@ bool AUPImportFileHandle::AddSamples(const FilePath &filename,
|
|||||||
{
|
{
|
||||||
SetWarning(XO("Error while processing %s\n\nInserting silence.").Format(filename));
|
SetWarning(XO("Error while processing %s\n\nInserting silence.").Format(filename));
|
||||||
|
|
||||||
AddSilence(len);
|
// If we are unwinding for an exception, don't do another
|
||||||
|
// potentially throwing operation
|
||||||
|
if (!std::uncaught_exception())
|
||||||
|
// If this does throw, let that propagate, don't guard the call
|
||||||
|
AddSilence(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sf)
|
if (sf)
|
||||||
@@ -1441,7 +1454,6 @@ bool AUPImportFileHandle::AddSamples(const FilePath &filename,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sampleFormat format = mFormat;
|
|
||||||
sf_count_t cnt = len.as_size_t();
|
sf_count_t cnt = len.as_size_t();
|
||||||
int channels = info.channels;
|
int channels = info.channels;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user