Audacity 3.2.0
Classes | Typedefs | Functions
Dependencies.h File Reference
#include <list>
#include "MemoryX.h"
#include "wxFileNameWrapper.h"
Include dependency graph for Dependencies.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  AliasedFile
 An audio file that is referenced (pointed into) directly from an Audacity .aup file rather than Audacity having its own copies of the data. More...
 

Typedefs

using AliasedFileArray = std::list< AliasedFile >
 

Functions

bool ShowDependencyDialogIfNeeded (AudacityProject *project, bool isSaving)
 
void FindDependencies (AudacityProject *project, AliasedFileArray &outAliasedFiles)
 

Typedef Documentation

◆ AliasedFileArray

using AliasedFileArray = std::list<AliasedFile>

Definition at line 52 of file Dependencies.h.

Function Documentation

◆ FindDependencies()

void FindDependencies ( AudacityProject project,
AliasedFileArray outAliasedFiles 
)

Definition at line 107 of file Dependencies.cpp.

109{
111
112 BlockPtrArray blocks;
113 GetAllSeqBlocks(project, &blocks);
114
115 AliasedFileHash aliasedFileHash;
116 BoolBlockFileHash blockFileHash;
117
118 for (const auto &blockFile : blocks) {
119 const auto &f = blockFile->f;
120 if (f->IsAlias() && (blockFileHash.count( &*f ) == 0))
121 {
122 // f is an alias block we have not yet counted.
123 blockFileHash[ &*f ] = true; // Don't count the same blockfile twice.
124 auto aliasBlockFile = static_cast<AliasBlockFile*>( &*f );
125 const wxFileName &fileName = aliasBlockFile->GetAliasedFileName();
126
127 // In ProjectFSCK(), if the user has chosen to
128 // "Replace missing audio with silence", the code there puts in an empty wxFileName.
129 // Don't count those in dependencies.
130 if (!fileName.IsOk())
131 continue;
132
133 const wxString &fileNameStr = fileName.GetFullPath();
134 auto blockBytes = (SAMPLE_SIZE(format) *
135 aliasBlockFile->GetLength());
136 if (aliasedFileHash.count(fileNameStr) > 0)
137 // Already put this AliasBlockFile in aliasedFileHash.
138 // Update block count.
139 aliasedFileHash[fileNameStr]->mByteCount += blockBytes;
140 else
141 {
142 // Haven't counted this AliasBlockFile yet.
143 // Add to return array and internal hash.
144
145 // PRL: do this in two steps so that we move instead of copying.
146 // We don't have a moving push_back in all compilers.
147 outAliasedFiles.push_back(AliasedFile{});
148 outAliasedFiles.back() =
150 wxFileNameWrapper { fileName },
151 wxLongLong(blockBytes), fileName.FileExists()
152 };
153 aliasedFileHash[fileNameStr] = &outAliasedFiles.back();
154 }
155 }
156 }
157}
std::unordered_map< BlockFile *, bool > BoolBlockFileHash
static void GetAllSeqBlocks(AudacityProject *project, BlockPtrArray *outBlocks)
std::unordered_map< wxString, AliasedFile * > AliasedFileHash
sampleFormat
The ordering of these values with operator < agrees with the order of increasing bit width.
Definition: SampleFormat.h:30
#define SAMPLE_SIZE(SampleFormat)
Definition: SampleFormat.h:52
std::deque< SeqBlock * > BlockPtrArray
Definition: Sequence.h:51
const auto project
An audio file that is referenced (pointed into) directly from an Audacity .aup file rather than Audac...
Definition: Dependencies.h:24
PROJECT_RATE_API sampleFormat SampleFormatChoice()

References anonymous_namespace{ExportPCM.cpp}::format, GetAllSeqBlocks(), project, SAMPLE_SIZE, and QualitySettings::SampleFormatChoice().

Referenced by ShowDependencyDialogIfNeeded().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShowDependencyDialogIfNeeded()

bool ShowDependencyDialogIfNeeded ( AudacityProject project,
bool  isSaving 
)

Definition at line 600 of file Dependencies.cpp.

602{
603 auto pWindow = FindProjectFrame( project );
604 AliasedFileArray aliasedFiles;
605 FindDependencies(project, aliasedFiles);
606
607 if (aliasedFiles.empty()) {
608 if (!isSaving)
609 {
610 auto msg =
611XO("Your project is self-contained; it does not depend on any external audio files. \
612\n\nSome older Audacity projects may not be self-contained, and care \n\
613is needed to keep their external dependencies in the right place.\n\
614New projects will be self-contained and are less risky.");
616 msg,
617 XO("Dependency Check"),
618 wxOK | wxICON_INFORMATION,
619 pWindow);
620 }
621 return true; // Nothing to do.
622 }
623
624 if (isSaving)
625 {
626 RemoveDependencies(project, aliasedFiles);
627 return true;
628 }
629
630 DependencyDialog dlog(pWindow, -1, project, aliasedFiles, isSaving);
631 int returnCode = dlog.ShowModal();
632 if (returnCode == wxID_CANCEL)
633 return false;
634 else if (returnCode == wxID_YES)
635 RemoveDependencies(project, aliasedFiles);
636
637 return true;
638}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
static void RemoveDependencies(AudacityProject *project, AliasedFileArray &aliasedFiles)
void FindDependencies(AudacityProject *project, AliasedFileArray &outAliasedFiles)
std::list< AliasedFile > AliasedFileArray
Definition: Dependencies.h:52
XO("Cut/Copy/Paste")
wxFrame * FindProjectFrame(AudacityProject *project)
Get a pointer to the window associated with a project, or null if the given pointer is null,...
DependencyDialog shows dependencies of an AudacityProject on AliasedFile s.

References AudacityMessageBox(), FindDependencies(), FindProjectFrame(), project, RemoveDependencies(), and XO().

Here is the call graph for this function: