mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-25 15:53:52 +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:
@@ -53,7 +53,6 @@ out.
|
|||||||
#include "sndfile.h"
|
#include "sndfile.h"
|
||||||
#include "FileException.h"
|
#include "FileException.h"
|
||||||
#include "FileFormats.h"
|
#include "FileFormats.h"
|
||||||
#include "MissingAliasFileDialog.h"
|
|
||||||
|
|
||||||
// msmeyer: Define this to add debug output via wxPrintf()
|
// msmeyer: Define this to add debug output via wxPrintf()
|
||||||
//#define DEBUG_BLOCKFILE
|
//#define DEBUG_BLOCKFILE
|
||||||
@@ -479,6 +478,23 @@ bool BlockFile::Read64K(float *buffer,
|
|||||||
return result;
|
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(
|
size_t BlockFile::CommonReadData(
|
||||||
bool mayThrow,
|
bool mayThrow,
|
||||||
const wxFileName &fileName, bool &mSilentLog,
|
const wxFileName &fileName, bool &mSilentLog,
|
||||||
@@ -537,8 +553,9 @@ size_t BlockFile::CommonReadData(
|
|||||||
|
|
||||||
if (pAliasFile) {
|
if (pAliasFile) {
|
||||||
// Set a marker to display an error message for the silence
|
// Set a marker to display an error message for the silence
|
||||||
if (!MissingAliasFilesDialog::ShouldShow())
|
auto hook = GetMissingAliasFileFound();
|
||||||
MissingAliasFilesDialog::Mark(pAliasFile);
|
if (hook)
|
||||||
|
hook( pAliasFile );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "ondemand/ODTaskThread.h"
|
#include "ondemand/ODTaskThread.h"
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
class XMLWriter;
|
class XMLWriter;
|
||||||
|
|
||||||
class SummaryInfo {
|
class SummaryInfo {
|
||||||
@@ -49,6 +51,14 @@ inline std::shared_ptr< Result > make_blockfile (Args && ... args)
|
|||||||
class PROFILE_DLL_API BlockFile /* not final, abstract */ {
|
class PROFILE_DLL_API BlockFile /* not final, abstract */ {
|
||||||
public:
|
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
|
// Constructor / Destructor
|
||||||
|
|
||||||
/// Construct a BlockFile.
|
/// 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;
|
||||||
|
|||||||
Reference in New Issue
Block a user