| 499 | } |
| 500 | |
| 501 | void ProjectAudioManager::Stop(bool stopStream /* = true*/) |
| 502 | { |
| 503 | AudacityProject *project = &mProject; |
| 504 | auto &projectAudioManager = *this; |
| 505 | bool canStop = projectAudioManager.CanStopAudioStream(); |
| 506 | |
| 507 | if ( !canStop ) |
| 508 | return; |
| 509 | |
| 510 | if(project) { |
| 511 | // Let scrubbing code do some appearance change |
| 512 | auto &scrubber = Scrubber::Get( *project ); |
| 513 | scrubber.StopScrubbing(); |
| 514 | } |
| 515 | |
| 516 | auto gAudioIO = AudioIO::Get(); |
| 517 | |
| 518 | auto cleanup = finally( [&]{ |
| 519 | projectAudioManager.SetStopping( false ); |
| 520 | } ); |
| 521 | |
| 522 | if (stopStream && gAudioIO->IsBusy()) { |
| 523 | // flag that we are stopping |
| 524 | projectAudioManager.SetStopping( true ); |
| 525 | // Allow UI to update for that |
| 526 | while( wxTheApp->ProcessIdle() ) |
| 527 | ; |
| 528 | } |
| 529 | |
| 530 | if(stopStream) |
| 531 | gAudioIO->StopStream(); |
| 532 | |
| 533 | projectAudioManager.SetLooping( false ); |
| 534 | projectAudioManager.SetCutting( false ); |
| 535 | |
| 536 | #ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT |
| 537 | gAudioIO->AILADisable(); |
| 538 | #endif |
| 539 | |
| 540 | projectAudioManager.SetPausedOff(); |
| 541 | //Make sure you tell gAudioIO to unpause |
| 542 | gAudioIO->SetPaused( false ); |
| 543 | |
| 544 | // So that we continue monitoring after playing or recording. |
| 545 | // also clean the MeterQueues |
| 546 | if( project ) { |
| 547 | auto &projectAudioIO = ProjectAudioIO::Get( *project ); |
| 548 | auto meter = projectAudioIO.GetPlaybackMeter(); |
| 549 | if( meter ) { |
| 550 | meter->Clear(); |
| 551 | } |
| 552 | |
| 553 | meter = projectAudioIO.GetCaptureMeter(); |
| 554 | if( meter ) { |
| 555 | meter->Clear(); |
| 556 | } |
| 557 | } |
| 558 | } |
no test coverage detected