MayaFlux 0.2.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 || std::is_same_v<promise_handle, Vruta::complex_promise>) {
9 if constexpr (requires { h.promise().next_sample; }) {
10 h.promise().next_sample += samples_to_wait;
11 h.promise().active_delay_context = Vruta::DelayContext::SAMPLE_BASED;
12 }
13 } else {
14 if constexpr (requires { h.promise().domain_mismatch_error("", ""); }) {
15 h.promise().domain_mismatch_error("SampleDelay",
16 "This awaitable is not compatible with the current coroutine promise type.");
17 }
18 }
19}
20
21void FrameDelay::await_suspend(std::coroutine_handle<Vruta::graphics_promise> h) noexcept
22{
23 if constexpr (std::is_same_v<promise_handle, Vruta::graphics_promise>
24 || std::is_same_v<promise_handle, Vruta::complex_promise>) {
25 if constexpr (requires { h.promise().next_frame; }) {
26 h.promise().next_frame += frames_to_wait;
27 h.promise().active_delay_context = Vruta::DelayContext::FRAME_BASED;
28 }
29 } else {
30 if constexpr (requires { h.promise().domain_mismatch_error("", ""); }) {
31 h.promise().domain_mismatch_error("FrameDelay",
32 "This awaitable is not compatible with the current coroutine promise type.");
33 }
34 }
35}
36
37void MultiRateDelay::await_suspend(std::coroutine_handle<Vruta::complex_promise> h) noexcept
38{
39 if constexpr (requires { h.promise().next_sample; }) {
40 h.promise().next_sample += samples_to_wait;
41 }
42 if constexpr (requires { h.promise().next_frame; }) {
43 h.promise().next_frame += frames_to_wait;
44 }
45}
46
47}
@ 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::complex_promise > h) noexcept
void await_suspend(std::coroutine_handle< promise_handle > h) noexcept
Schedules the coroutine to resume after the delay.