Audacity  3.0.3
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 109 of file Dependencies.cpp.

111 {
113 
114  BlockPtrArray blocks;
115  GetAllSeqBlocks(project, &blocks);
116 
117  AliasedFileHash aliasedFileHash;
118  BoolBlockFileHash blockFileHash;
119 
120  for (const auto &blockFile : blocks) {
121  const auto &f = blockFile->f;
122  if (f->IsAlias() && (blockFileHash.count( &*f ) == 0))
123  {
124  // f is an alias block we have not yet counted.
125  blockFileHash[ &*f ] = true; // Don't count the same blockfile twice.
126  auto aliasBlockFile = static_cast<AliasBlockFile*>( &*f );
127  const wxFileName &fileName = aliasBlockFile->GetAliasedFileName();
128 
129  // In ProjectFSCK(), if the user has chosen to
130  // "Replace missing audio with silence", the code there puts in an empty wxFileName.
131  // Don't count those in dependencies.
132  if (!fileName.IsOk())
133  continue;
134 
135  const wxString &fileNameStr = fileName.GetFullPath();
136  auto blockBytes = (SAMPLE_SIZE(format) *
137  aliasBlockFile->GetLength());
138  if (aliasedFileHash.count(fileNameStr) > 0)
139  // Already put this AliasBlockFile in aliasedFileHash.
140  // Update block count.
141  aliasedFileHash[fileNameStr]->mByteCount += blockBytes;
142  else
143  {
144  // Haven't counted this AliasBlockFile yet.
145  // Add to return array and internal hash.
146 
147  // PRL: do this in two steps so that we move instead of copying.
148  // We don't have a moving push_back in all compilers.
149  outAliasedFiles.push_back(AliasedFile{});
150  outAliasedFiles.back() =
151  AliasedFile {
152  wxFileNameWrapper { fileName },
153  wxLongLong(blockBytes), fileName.FileExists()
154  };
155  aliasedFileHash[fileNameStr] = &outAliasedFiles.back();
156  }
157  }
158  }
159 }

References format, GetAllSeqBlocks(), 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 602 of file Dependencies.cpp.

604 {
605  auto pWindow = FindProjectFrame( project );
606  AliasedFileArray aliasedFiles;
607  FindDependencies(project, aliasedFiles);
608 
609  if (aliasedFiles.empty()) {
610  if (!isSaving)
611  {
612  auto msg =
613 XO("Your project is self-contained; it does not depend on any external audio files. \
614 \n\nSome older Audacity projects may not be self-contained, and care \n\
615 is needed to keep their external dependencies in the right place.\n\
616 New projects will be self-contained and are less risky.");
618  msg,
619  XO("Dependency Check"),
620  wxOK | wxICON_INFORMATION,
621  pWindow);
622  }
623  return true; // Nothing to do.
624  }
625 
626  if (isSaving)
627  {
628  RemoveDependencies(project, aliasedFiles);
629  return true;
630  }
631 
632  DependencyDialog dlog(pWindow, -1, project, aliasedFiles, isSaving);
633  int returnCode = dlog.ShowModal();
634  if (returnCode == wxID_CANCEL)
635  return false;
636  else if (returnCode == wxID_YES)
637  RemoveDependencies(project, aliasedFiles);
638 
639  return true;
640 }

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

Here is the call graph for this function:
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
Definition: AudacityMessageBox.cpp:17
wxFileNameWrapper
Definition: wxFileNameWrapper.h:21
GetAllSeqBlocks
static void GetAllSeqBlocks(AudacityProject *project, BlockPtrArray *outBlocks)
Definition: Dependencies.cpp:77
SAMPLE_SIZE
#define SAMPLE_SIZE(SampleFormat)
Definition: SampleFormat.h:44
XO
#define XO(s)
Definition: Internat.h:31
BlockPtrArray
std::vector< SeqBlock * > BlockPtrArray
Definition: Sequence.h:50
format
int format
Definition: ExportPCM.cpp:56
AliasedFileArray
std::list< AliasedFile > AliasedFileArray
Definition: Dependencies.h:52
DependencyDialog
DependencyDialog shows dependencies of an AudacityProject on AliasedFile s.
Definition: Dependencies.cpp:245
AliasedFile
An audio file that is referenced (pointed into) directly from an Audacity .aup file rather than Audac...
Definition: Dependencies.h:24
sampleFormat
sampleFormat
Definition: SampleFormat.h:29
QualitySettings::SampleFormatChoice
PROJECT_RATE_API sampleFormat SampleFormatChoice()
Definition: QualitySettings.cpp:38
AliasedFileHash
std::unordered_map< wxString, AliasedFile * > AliasedFileHash
Definition: Dependencies.cpp:67
FindDependencies
void FindDependencies(AudacityProject *project, AliasedFileArray &outAliasedFiles)
Definition: Dependencies.cpp:109
FindProjectFrame
wxFrame * FindProjectFrame(AudacityProject *project)
Get a pointer to the window associated with a project, or null if the given pointer is null,...
Definition: ProjectWindows.cpp:88
RemoveDependencies
static void RemoveDependencies(AudacityProject *project, AliasedFileArray &aliasedFiles)
Definition: Dependencies.cpp:164
BoolBlockFileHash
std::unordered_map< BlockFile *, bool > BoolBlockFileHash
Definition: Dependencies.cpp:72