Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
audio_device_manager.hpp File Reference

AudioDeviceManager — persistence, MIDI routing, and lifecycle recovery. More...

#include <pulp/audio/device.hpp>
#include <pulp/audio/load_measurer.hpp>
#include <pulp/midi/device.hpp>
#include <pulp/midi/message.hpp>
#include <atomic>
#include <condition_variable>
#include <cstdint>
#include <functional>
#include <memory>
#include <mutex>
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>

Go to the source code of this file.

Classes

struct  pulp::audio::DeviceSelection
 Persisted audio-device selection. More...
class  pulp::audio::MidiSubscriptionToken
 RAII subscription token. More...
class  pulp::audio::AudioDeviceManager
 AudioDeviceManager — persistence + MIDI hub. More...
struct  pulp::audio::AudioDeviceManager::ResolveResult
 Resolve a stored selection against the live device list. More...
struct  pulp::audio::AudioDeviceManager::RuntimeTelemetrySnapshot
 Manager-owned runtime telemetry that combines callback load and backend xrun/overload counters for live tools. More...
struct  pulp::audio::AudioDeviceManager::DeviceChangeEvent
class  pulp::audio::AudioDeviceManager::DeviceChangeToken
 RAII subscription token for device-change events. More...
struct  pulp::audio::AudioDeviceManager::MidiEndpoint
struct  pulp::audio::AudioDeviceManager::MidiEndpointChange

Namespaces

namespace  pulp
namespace  pulp::state
 SequencerStateChannel is the audio-safe transport for a plugin's structured NON-parameter state: the bulk, observable state a step sequencer / mod-matrix / pattern engine holds outside its automatable parameter set (e.g.
namespace  pulp::audio
namespace  pulp::audio::adm_keys
 Keys used under ApplicationProperties::user_settings().

Variables

constexpr const char * pulp::audio::adm_keys::kPrefix = "audio_device_manager."
constexpr const char * pulp::audio::adm_keys::kOutputDevice = "audio_device_manager.output_device"
constexpr const char * pulp::audio::adm_keys::kInputDevice = "audio_device_manager.input_device"
constexpr const char * pulp::audio::adm_keys::kSampleRate = "audio_device_manager.sample_rate"
constexpr const char * pulp::audio::adm_keys::kBufferSize = "audio_device_manager.buffer_size"
constexpr const char * pulp::audio::adm_keys::kOutputChannelMask = "audio_device_manager.output_channel_mask"
constexpr const char * pulp::audio::adm_keys::kInputChannelMask = "audio_device_manager.input_channel_mask"
constexpr const char * pulp::audio::adm_keys::kEnabledMidiInputs = "audio_device_manager.enabled_midi_inputs"
 Newline-separated identifiers of the MIDI inputs the user enabled.

Detailed Description

AudioDeviceManager — persistence, MIDI routing, and lifecycle recovery.

Responsibilities:

  • Persists the user's selected audio device + sample rate + buffer size + I/O channel masks under audio_device_manager.* keys in pulp::state::ApplicationProperties::user_settings(). Settings survive a host restart.
  • Single source of truth for connected MIDI inputs/outputs. Dispatches incoming MIDI to subscribers. A subscription returns an RAII token whose destruction auto-unsubscribes — the typical pattern is to hold the token as a member; lifetime ends with the owning object and the manager stops calling the callback.
  • Exposes a smoothed CPU-load signal (wraps pulp::audio::AudioProcessLoadMeasurer) so a host UI can read a stable percentage without poking the realtime callback.
  • Observes an AudioSystem device-change callback and republishes structured DeviceChangeEvent notifications for hotplug, default-device changes, sample-rate changes, and xruns.
  • Tracks MIDI endpoint snapshots with set_midi_endpoints() and dispatches MidiEndpointChange events on add/remove.
  • Keeps the user's enabled MIDI inputs open across disconnection: an enabled input that disappears is closed, and reopened by itself when an input with the same identifier returns. The enabled set is saved to the settings file; disabling an input removes it there.
  • Makes shutdown explicit: latch_close() waits for in-flight dispatches to return and turns later dispatch attempts into no-ops.