| 496 | } |
| 497 | |
| 498 | bool RealtimeEffectState::ProcessStart(bool running) |
| 499 | { |
| 500 | // Get state changes from the main thread |
| 501 | // Note that it is only here that the answer of IsActive() may be changed, |
| 502 | // and it is important that for each state the answer is unchanging in one |
| 503 | // processing scope. |
| 504 | if (auto pAccessState = TestAccessState()) |
| 505 | pAccessState->WorkerRead(); |
| 506 | |
| 507 | // Detect transitions of activity state |
| 508 | auto pInstance = mwInstance.lock(); |
| 509 | bool active = IsActive() && running; |
| 510 | if (active != mLastActive) { |
| 511 | if (pInstance) { |
| 512 | bool success = active |
| 513 | ? pInstance->RealtimeResume() |
| 514 | : pInstance->RealtimeSuspend(); |
| 515 | if (!success) |
| 516 | return false; |
| 517 | } |
| 518 | mLastActive = active; |
| 519 | } |
| 520 | |
| 521 | bool result = false; |
| 522 | if (pInstance) { |
| 523 | // Consume messages even if not processing |
| 524 | // (issue #3855: plain UI for VST 2 effects) |
| 525 | |
| 526 | // Assuming we are in a processing scope, use the worker settings |
| 527 | EffectInstance::MessagePackage package{ |
| 528 | mWorkerSettings.settings, mMovedMessage.get() |
| 529 | }; |
| 530 | result = pInstance->RealtimeProcessStart(package); |
| 531 | } |
| 532 | |
| 533 | if (!pInstance || !active) |
| 534 | return false; |
| 535 | else |
| 536 | return result; |
| 537 | } |
| 538 | |
| 539 | #define stackAllocate(T, count) static_cast<T*>(alloca(count * sizeof(T))) |
| 540 |
no test coverage detected