MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ audio_output_tick()

MAYAFLUX_API std::shared_ptr< Vruta::BroadcastSource< bool > > MayaFlux::Kriya::audio_output_tick ( )

Create a BroadcastSource<bool> ticking once per audio output cycle.

Registers an observer with AudioBackendService and returns the source. The returned observer id is stored inside the source's shared state via a custom deleter on the shared_ptr - unregistration is automatic when the last owner drops the source.

get_event_manager()->add_event(std::make_shared<Vruta::Event>(
Kriya::on_signal(src, [ct](bool) {
ct->process_default();
})));
Vruta::Event on_signal(std::shared_ptr< Vruta::BroadcastSource< T > > source, Callback callback)
Creates an Event coroutine that fires on every signal from a BroadcastSource.
std::shared_ptr< Vruta::BroadcastSource< bool > > audio_output_tick()
Create a BroadcastSource<bool> ticking once per audio output cycle.
std::shared_ptr< Vruta::EventManager > get_event_manager()
Gets the event manager from the default engine.
Definition Chronie.cpp:27

Definition at line 10 of file BroadcastEvents.cpp.

11{
12 auto* svc = Registry::BackendRegistry::instance()
14
15 if (!svc)
16 return nullptr;
17
18 struct State {
21 uint32_t observer_id { 0 };
22 ~State()
23 {
24 if (svc)
25 svc->unregister_output_observer(observer_id);
26 }
27 };
28
29 auto state = std::make_shared<State>();
30 state->svc = svc;
31 state->observer_id = svc->register_output_observer(
32 [s = state.get()](const double*, uint32_t) {
33 s->source.signal(true);
34 });
35
36 return { state, &state->source };
37}
Awaitable single-value broadcast channel for cross-thread signal delivery.
std::function< void(uint32_t)> unregister_output_observer
Unregister a previously registered observer.
Backend audio subsystem service interface.

References MayaFlux::Registry::BackendRegistry::get_service(), MayaFlux::Registry::BackendRegistry::instance(), and MayaFlux::Registry::Service::AudioBackendService::unregister_output_observer.

+ Here is the call graph for this function: