MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
DelayAwaiters.cpp
Go to the documentation of this file.
1#include "DelayAwaiters.hpp"
2
3namespace MayaFlux::Kriya {
4
5void SampleDelay::await_suspend(std::coroutine_handle<promise_handle> h) noexcept
6{
7 if constexpr (std::is_same_v<promise_handle, Vruta::audio_promise>) {
8 h.promise().next_sample += samples_to_wait;
9 h.promise().active_delay_context = Vruta::DelayContext::SAMPLE_BASED;
10 } else {
11 if constexpr (requires { h.promise().domain_mismatch_error("", ""); }) {
12 h.promise().domain_mismatch_error("SampleDelay",
13 "This awaitable is not compatible with the current coroutine promise type.");
14 }
15 }
16}
17
18void FrameDelay::await_suspend(std::coroutine_handle<Vruta::graphics_promise> h) noexcept
19{
20 if constexpr (std::is_same_v<promise_handle, Vruta::graphics_promise>) {
21 if constexpr (requires { h.promise().next_frame; }) {
22 h.promise().next_frame += frames_to_wait;
23 h.promise().active_delay_context = Vruta::DelayContext::FRAME_BASED;
24 }
25 } else {
26 if constexpr (requires { h.promise().domain_mismatch_error("", ""); }) {
27 h.promise().domain_mismatch_error("FrameDelay",
28 "This awaitable is not compatible with the current coroutine promise type.");
29 }
30 }
31}
32
33void MultiRateDelay::await_suspend(std::coroutine_handle<Vruta::cross_promise> h) noexcept
34{
35 auto& promise = h.promise();
36 promise.next_sample.fetch_add(samples_to_wait, std::memory_order_relaxed);
37 promise.next_frame.fetch_add(frames_to_wait, std::memory_order_relaxed);
38 promise.sample_delay_amount = samples_to_wait;
39 promise.frame_delay_amount = frames_to_wait;
40 promise.active_delay_context.store(
41 Vruta::DelayContext::MULTIPLE, std::memory_order_release);
42}
43
44}
uint32_t h
Definition InkPress.cpp:28
@ MULTIPLE
Armed on both sample and frame clocks; first to arrive resumes (CrossRoutine)
@ FRAME_BASED
Frame-rate delay (Graphics domain)
@ SAMPLE_BASED
Sample-accurate delay (audio domain)
void await_suspend(std::coroutine_handle< Vruta::graphics_promise > h) noexcept
void await_suspend(std::coroutine_handle< Vruta::cross_promise > h) noexcept
void await_suspend(std::coroutine_handle< promise_handle > h) noexcept
Schedules the coroutine to resume after the delay.