| 755 | } |
| 756 | |
| 757 | bool ProjectAudioManager::DoRecord(AudacityProject &project, |
| 758 | const TransportSequences &sequences, |
| 759 | double t0, double t1, |
| 760 | bool altAppearance, |
| 761 | const AudioIOStartStreamOptions &options) |
| 762 | { |
| 763 | auto &projectAudioManager = *this; |
| 764 | |
| 765 | CommandFlag flags = AlwaysEnabledFlag; // 0 means recalc flags. |
| 766 | |
| 767 | // NB: The call may have the side effect of changing flags. |
| 768 | bool allowed = CommandManager::Get(project).TryToMakeActionAllowed( |
| 769 | flags, |
| 770 | AudioIONotBusyFlag() | CanStopAudioStreamFlag()); |
| 771 | |
| 772 | if (!allowed) |
| 773 | return false; |
| 774 | // ...end of code from CommandHandler. |
| 775 | |
| 776 | auto gAudioIO = AudioIO::Get(); |
| 777 | if (gAudioIO->IsBusy()) |
| 778 | return false; |
| 779 | |
| 780 | projectAudioManager.SetAppending(!altAppearance); |
| 781 | |
| 782 | bool success = false; |
| 783 | |
| 784 | auto transportSequences = sequences; |
| 785 | |
| 786 | // Will replace any given capture tracks with temporaries |
| 787 | transportSequences.captureSequences.clear(); |
| 788 | |
| 789 | const auto p = &project; |
| 790 | auto &trackList = TrackList::Get(project); |
| 791 | |
| 792 | bool appendRecord = !sequences.captureSequences.empty(); |
| 793 | |
| 794 | auto insertEmptyInterval = |
| 795 | [&](WaveTrack &track, double t0, bool placeholder) { |
| 796 | wxString name; |
| 797 | for (auto i = 1; ; ++i) { |
| 798 | //i18n-hint a numerical suffix added to distinguish otherwise like-named clips when new record started |
| 799 | name = XC("%s.%d", "clip name template") |
| 800 | .Format(track.GetName(), i).Translation(); |
| 801 | if (!track.HasClipNamed(name)) |
| 802 | break; |
| 803 | } |
| 804 | |
| 805 | auto clip = track.CreateClip(t0, name); |
| 806 | // So that the empty clip is not skipped for insertion: |
| 807 | clip->SetIsPlaceholder(true); |
| 808 | track.InsertInterval(clip, true); |
| 809 | if (!placeholder) |
| 810 | clip->SetIsPlaceholder(false); |
| 811 | return clip; |
| 812 | }; |
| 813 | |
| 814 | auto &pendingTracks = PendingTracks::Get(project); |
no test coverage detected