mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-07 15:49:42 +02:00
BlockFile.cpp does not depend on MissingAliasFileDialog.cpp ...
... instead use a hook function to call back when it is discovered that a block file is missing. This frees three files from dependency cycles
This commit is contained in:
parent
96ffc424cf
commit
ce27977ff2
@ -53,7 +53,6 @@ out.
|
||||
#include "sndfile.h"
|
||||
#include "FileException.h"
|
||||
#include "FileFormats.h"
|
||||
#include "MissingAliasFileDialog.h"
|
||||
|
||||
// msmeyer: Define this to add debug output via wxPrintf()
|
||||
//#define DEBUG_BLOCKFILE
|
||||
@ -479,6 +478,23 @@ bool BlockFile::Read64K(float *buffer,
|
||||
return result;
|
||||
}
|
||||
|
||||
namespace {
|
||||
BlockFile::MissingAliasFileFoundHook &GetMissingAliasFileFound()
|
||||
{
|
||||
static BlockFile::MissingAliasFileFoundHook theHook;
|
||||
return theHook;
|
||||
}
|
||||
}
|
||||
|
||||
auto BlockFile::SetMissingAliasFileFound( MissingAliasFileFoundHook hook )
|
||||
-> MissingAliasFileFoundHook
|
||||
{
|
||||
auto &theHook = GetMissingAliasFileFound();
|
||||
auto result = theHook;
|
||||
theHook = hook;
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t BlockFile::CommonReadData(
|
||||
bool mayThrow,
|
||||
const wxFileName &fileName, bool &mSilentLog,
|
||||
@ -537,8 +553,9 @@ size_t BlockFile::CommonReadData(
|
||||
|
||||
if (pAliasFile) {
|
||||
// Set a marker to display an error message for the silence
|
||||
if (!MissingAliasFilesDialog::ShouldShow())
|
||||
MissingAliasFilesDialog::Mark(pAliasFile);
|
||||
auto hook = GetMissingAliasFileFound();
|
||||
if (hook)
|
||||
hook( pAliasFile );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#include "ondemand/ODTaskThread.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
class XMLWriter;
|
||||
|
||||
class SummaryInfo {
|
||||
@ -49,6 +51,14 @@ inline std::shared_ptr< Result > make_blockfile (Args && ... args)
|
||||
class PROFILE_DLL_API BlockFile /* not final, abstract */ {
|
||||
public:
|
||||
|
||||
// Type of function to be called when opening of an alias block file for read
|
||||
// discovers that the other audio file it depends on is absent
|
||||
using MissingAliasFileFoundHook =
|
||||
std::function< void(const AliasBlockFile*) >;
|
||||
// Install a hook, and return the previous hook
|
||||
static MissingAliasFileFoundHook
|
||||
SetMissingAliasFileFound( MissingAliasFileFoundHook hook );
|
||||
|
||||
// Constructor / Destructor
|
||||
|
||||
/// Construct a BlockFile.
|
||||
|
@ -131,3 +131,12 @@ namespace MissingAliasFilesDialog {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Arrange callback from low levels of block file I/O to detect missing files
|
||||
static struct InstallHook{ InstallHook() {
|
||||
auto hook = [](const AliasBlockFile *pAliasFile){
|
||||
if (!MissingAliasFilesDialog::ShouldShow())
|
||||
MissingAliasFilesDialog::Mark(pAliasFile);
|
||||
};
|
||||
BlockFile::SetMissingAliasFileFound( hook );
|
||||
} } installHook;
|
||||
|
Loading…
x
Reference in New Issue
Block a user