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

Method PlayPlayRegion

src/ProjectAudioManager.cpp:293–469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

291}
292
293int ProjectAudioManager::PlayPlayRegion(const SelectedRegion &selectedRegion,
294 const AudioIOStartStreamOptions &options,
295 PlayMode mode,
296 bool backwards /* = false */)
297{
298 auto &projectAudioManager = *this;
299 bool canStop = projectAudioManager.CanStopAudioStream();
300
301 if ( !canStop )
302 return -1;
303
304 auto &pStartTime = options.pStartTime;
305
306 bool nonWaveToo = options.playNonWaveTracks;
307
308 // Uncomment this for laughs!
309 // backwards = true;
310
311 double t0 = selectedRegion.t0();
312 double t1 = selectedRegion.t1();
313 // SelectedRegion guarantees t0 <= t1, so we need another boolean argument
314 // to indicate backwards play.
315 const bool newDefault = (mode == PlayMode::loopedPlay);
316
317 if (backwards)
318 std::swap(t0, t1);
319
320 projectAudioManager.SetLooping( mode == PlayMode::loopedPlay );
321 projectAudioManager.SetCutting( mode == PlayMode::cutPreviewPlay );
322
323 bool success = false;
324
325 auto gAudioIO = AudioIO::Get();
326 if (gAudioIO->IsBusy())
327 return -1;
328
329 const bool cutpreview = mode == PlayMode::cutPreviewPlay;
330 if (cutpreview && t0==t1)
331 return -1; /* msmeyer: makes no sense */
332
333 AudacityProject *p = &mProject;
334
335 auto &tracks = TrackList::Get(*p);
336
337 mLastPlayMode = mode;
338
339 bool hasaudio;
340 if (nonWaveToo)
341 hasaudio = ! tracks.Any<PlayableTrack>().empty();
342 else
343 hasaudio = ! tracks.Any<WaveTrack>().empty();
344
345 double latestEnd = tracks.GetEndTime();
346
347 if (!hasaudio)
348 return -1; // No need to continue without audio tracks
349
350#if defined(EXPERIMENTAL_SEEK_BEHIND_CURSOR)

Callers 5

PlayPlayRegionAndWaitMethod · 0.80
StartQPPlayMethod · 0.80
MaybeStartScrubbingMethod · 0.80
PlayAtSpeedMethod · 0.80

Calls 15

GetFunction · 0.85
maxFunction · 0.85
ShowErrorDialogFunction · 0.85
ProjectFramePlacementFunction · 0.85
CanStopAudioStreamMethod · 0.80
IsBusyMethod · 0.80
emplaceMethod · 0.80
StartStreamMethod · 0.80
SetAudioIOTokenMethod · 0.80
MakeTransportTracksFunction · 0.70
swapFunction · 0.50
minFunction · 0.50

Tested by

no test coverage detected