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

#include <device.hpp>

Public Types

using DeviceChangeCallback = std::function<void()>
 Register a callback for device list changes (hotplug/unplug).

Public Member Functions

virtual ~AudioSystem ()=default
virtual std::vector< DeviceInfo > enumerate_devices ()=0
virtual std::unique_ptr< AudioDevice > create_device (const std::string &device_id="")=0
virtual DeviceInfo default_output_device ()=0
virtual DeviceInfo default_input_device ()=0
virtual void set_device_change_callback (DeviceChangeCallback cb)
 Default implementation stores the callback in a base-class slot.
void fire_device_change ()
 Dispatch a stored device-change callback.
bool has_device_change_callback () const
 Observe whether a caller registered a callback.

Member Typedef Documentation

◆ DeviceChangeCallback

using pulp::audio::AudioSystem::DeviceChangeCallback = std::function<void()>

Register a callback for device list changes (hotplug/unplug).

The callback may fire on an OS thread — callers should dispatch to the main/UI thread if needed. Pass nullptr to unregister.

Constructor & Destructor Documentation

◆ ~AudioSystem()

virtual pulp::audio::AudioSystem::~AudioSystem ( )
virtualdefault

Member Function Documentation

◆ create_device()

virtual std::unique_ptr< AudioDevice > pulp::audio::AudioSystem::create_device ( const std::string & device_id = "")
pure virtual

◆ default_input_device()

virtual DeviceInfo pulp::audio::AudioSystem::default_input_device ( )
pure virtual

◆ default_output_device()

virtual DeviceInfo pulp::audio::AudioSystem::default_output_device ( )
pure virtual

◆ enumerate_devices()

virtual std::vector< DeviceInfo > pulp::audio::AudioSystem::enumerate_devices ( )
pure virtual

◆ fire_device_change()

void pulp::audio::AudioSystem::fire_device_change ( )
inline

Dispatch a stored device-change callback.

Safe to call from any thread; the callback itself is responsible for UI-thread marshalling. The callback is retained before invocation so it may unregister or replace itself during dispatch without invalidating the in-flight call.

Must be public, not protected. Platform notifiers (WasapiNotificationClient, Win32 MIDI DeviceWatcher, ALSA seq monitor, etc.) are NOT AudioSystem subclasses — they own a pointer to an AudioSystem and invoke this method from an OS callback thread. C++ protected would require the access to go through the notifier's own derived-class this, which doesn't apply here. MSVC enforces this strictly; making this public matches the design intent of the platform notifier callbacks.

◆ has_device_change_callback()

bool pulp::audio::AudioSystem::has_device_change_callback ( ) const
inline

Observe whether a caller registered a callback.

◆ set_device_change_callback()

virtual void pulp::audio::AudioSystem::set_device_change_callback ( DeviceChangeCallback cb)
inlinevirtual

Default implementation stores the callback in a base-class slot.

Platform hotplug notifiers such as WASAPI IMMNotificationClient, ALSA udev monitors, Win32 MIDI DeviceWatcher, and ALSA seq monitors call fire_device_change() when a change is detected. Backends with richer semantics can still override this entirely.


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