MCPcopy Create free account
hub / github.com/audacity/audacity / OnTimerRecord

Function OnTimerRecord

src/TimerRecordDialog.cpp:1186–1325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1184
1185namespace {
1186void OnTimerRecord(const CommandContext &context)
1187{
1188 auto &project = context.project;
1189 const auto &settings = ProjectSettings::Get( project );
1190 auto &undoManager = UndoManager::Get( project );
1191 auto &window = GetProjectFrame(project);
1192
1193 // MY: Due to improvements in how Timer Recording saves and/or exports
1194 // it is now safer to disable Timer Recording when there is more than
1195 // one open project.
1196 if (AllProjects{}.size() > 1) {
1197 AudacityMessageBox(
1198 XO(
1199"Timer Recording cannot be used with more than one open project.\n\nPlease close any additional projects and try again."),
1200 XO("Timer Recording"),
1201 wxICON_INFORMATION | wxOK);
1202 return;
1203 }
1204
1205 // MY: If the project has unsaved changes then we no longer allow access
1206 // to Timer Recording. This decision has been taken as the safest approach
1207 // preventing issues surrounding "dirty" projects when Automatic Save/Export
1208 // is used in Timer Recording.
1209 if ((undoManager.UnsavedChanges()) && (!TrackList::Get(project).empty() )) {
1210 AudacityMessageBox(
1211 XO(
1212"Timer Recording cannot be used while you have unsaved changes.\n\nPlease save or close this project and try again."),
1213 XO("Timer Recording"),
1214 wxICON_INFORMATION | wxOK);
1215 return;
1216 }
1217
1218 // We check the selected tracks to see if there is enough of them to accommodate
1219 // all input channels and all of them have the same sampling rate.
1220 // Those checks will be later performed by recording function anyway,
1221 // but we want to warn the user about potential problems from the very start.
1222 const auto selectedTracks{ GetPropertiesOfSelected(project) };
1223 const int rateOfSelected{ selectedTracks.rateOfSelected };
1224 const bool anySelected{ selectedTracks.anySelected };
1225 const bool allSameRate{ selectedTracks.allSameRate };
1226
1227 if (!allSameRate) {
1228 AudacityMessageBox(XO("The tracks selected "
1229 "for recording must all have the same sampling rate"),
1230 XO("Mismatched Sampling Rates"),
1231 wxICON_ERROR | wxCENTRE);
1232
1233 return;
1234 }
1235
1236 // Only need the size
1237 const auto existingTracks =
1238 ProjectAudioManager::ChooseExistingRecordingTracks(project, true,
1239 rateOfSelected);
1240 if (existingTracks.empty()) {
1241 if (anySelected && rateOfSelected !=
1242 ProjectRate::Get(project).GetRate()) {
1243 AudacityMessageBox(XO(

Callers

nothing calls this directly

Calls 14

GetFunction · 0.85
AudacityMessageBoxFunction · 0.85
UnsavedChangesMethod · 0.80
RewindMethod · 0.80
RunWaitDialogMethod · 0.80
RollbackStateMethod · 0.80
GetPropertiesOfSelectedFunction · 0.70
sizeMethod · 0.45
emptyMethod · 0.45
GetRateMethod · 0.45
IsModifiedMethod · 0.45

Tested by

no test coverage detected