| 291 | } |
| 292 | |
| 293 | int 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) |
no test coverage detected