Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::audio::AudioWorkgroup Class Reference

Manages real-time thread priority for audio processing threads. More...

#include <workgroup.hpp>

Public Member Functions

 AudioWorkgroup ()=default
 ~AudioWorkgroup ()
 AudioWorkgroup (const AudioWorkgroup &)=delete
AudioWorkgroup & operator= (const AudioWorkgroup &)=delete
void set_workgroup (os_workgroup_t workgroup)
 Set the workgroup from an AudioUnit or CoreAudio device.
bool join_from_audio_thread ()
 Join the audio workgroup from the current thread.
bool leave ()
 Leave on the joining thread and restore any scoped Mach scheduling change.
bool is_joined () const
 Check if the current thread has joined the workgroup.

Static Public Member Functions

static bool set_realtime_priority ()
 Set real-time thread priority without a workgroup (best-effort).
static bool set_high_priority ()
 Set high (but not real-time) thread priority.

Detailed Description

Manages real-time thread priority for audio processing threads.

On macOS 11.0+, uses os_workgroup to join the audio device's workgroup, ensuring the thread gets real-time scheduling priority aligned with the audio device's deadline.

On other platforms, falls back to setting high thread priority via platform-specific APIs.

// In your audio I/O callback setup:
wg.join_from_audio_thread(); // call once from the audio thread
// When done:
wg.leave();
bool leave()
Leave on the joining thread and restore any scoped Mach scheduling change.
Definition workgroup.hpp:83
bool join_from_audio_thread()
Join the audio workgroup from the current thread.
Definition workgroup.hpp:58

Constructor & Destructor Documentation

◆ AudioWorkgroup() [1/2]

pulp::audio::AudioWorkgroup::AudioWorkgroup ( )
default

◆ ~AudioWorkgroup()

pulp::audio::AudioWorkgroup::~AudioWorkgroup ( )
inline

◆ AudioWorkgroup() [2/2]

pulp::audio::AudioWorkgroup::AudioWorkgroup ( const AudioWorkgroup & )
delete

Member Function Documentation

◆ is_joined()

bool pulp::audio::AudioWorkgroup::is_joined ( ) const
inline

Check if the current thread has joined the workgroup.

◆ join_from_audio_thread()

bool pulp::audio::AudioWorkgroup::join_from_audio_thread ( )
inline

Join the audio workgroup from the current thread.

Call this once from the audio processing thread.

Returns
True if successfully joined.

◆ leave()

bool pulp::audio::AudioWorkgroup::leave ( )
inline

Leave on the joining thread and restore any scoped Mach scheduling change.

Returns
False if restoration failed; state is retained so leave can be retried.

◆ operator=()

AudioWorkgroup & pulp::audio::AudioWorkgroup::operator= ( const AudioWorkgroup & )
delete

◆ set_high_priority()

bool pulp::audio::AudioWorkgroup::set_high_priority ( )
inlinestatic

Set high (but not real-time) thread priority.

◆ set_realtime_priority()

bool pulp::audio::AudioWorkgroup::set_realtime_priority ( )
inlinestatic

Set real-time thread priority without a workgroup (best-effort).

Useful when a workgroup is not available (standalone apps).

◆ set_workgroup()

void pulp::audio::AudioWorkgroup::set_workgroup ( os_workgroup_t workgroup)
inline

Set the workgroup from an AudioUnit or CoreAudio device.

Parameters
workgroupAn os_workgroup_t obtained from the audio device.

The documentation for this class was generated from the following file:
  • /home/runner/work/pulp/pulp/core/audio/include/pulp/audio/workgroup.hpp