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

Method PlayCurrentRegionAndWait

src/TransportUtilities.cpp:28–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26#include "WaveTrack.h"
27
28void TransportUtilities::PlayCurrentRegionAndWait(
29 const CommandContext &context,
30 bool newDefault,
31 bool cutpreview)
32{
33 auto &project = context.project;
34 auto &projectAudioManager = ProjectAudioManager::Get(project);
35
36 const auto &playRegion = ViewInfo::Get(project).playRegion;
37 double t0 = playRegion.GetStart();
38 double t1 = playRegion.GetEnd();
39
40 projectAudioManager.PlayCurrentRegion(newDefault, cutpreview);
41
42 if (project.mBatchMode > 0 && t0 != t1 && !newDefault) {
43 wxYieldIfNeeded();
44
45 /* i18n-hint: This title appears on a dialog that indicates the progress
46 in doing something.*/
47 ProgressDialog progress(XO("Progress"), XO("Playing"), pdlgHideCancelButton);
48 auto gAudioIO = AudioIO::Get();
49
50 while (projectAudioManager.Playing()) {
51 ProgressResult result = progress.Update(gAudioIO->GetStreamTime() - t0, t1 - t0);
52 if (result != ProgressResult::Success) {
53 projectAudioManager.Stop();
54 if (result != ProgressResult::Stopped) {
55 context.Error(wxT("Playing interrupted"));
56 }
57 break;
58 }
59
60 using namespace std::chrono;
61 std::this_thread::sleep_for(100ms);
62 wxYieldIfNeeded();
63 }
64
65 projectAudioManager.Stop();
66 wxYieldIfNeeded();
67 }
68}
69
70void TransportUtilities::PlayPlayRegionAndWait(
71 const CommandContext &context,

Callers

nothing calls this directly

Calls 7

GetFunction · 0.85
PlayCurrentRegionMethod · 0.80
PlayingMethod · 0.80
GetStreamTimeMethod · 0.80
UpdateMethod · 0.45
StopMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected