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

Calls on_change from a background thread whenever the combined input and output list changes. More...

#include <port_change_watcher.hpp>

Public Types

using Enumerate = std::function<std::vector<MidiPortInfo>()>
using OnChange = std::function<void(const PortListDiff&)>

Public Member Functions

 PortChangePoller ()=default
 PortChangePoller (const PortChangePoller &)=delete
PortChangePoller & operator= (const PortChangePoller &)=delete
 ~PortChangePoller ()
void start (Enumerate enumerate, OnChange on_change, std::chrono::milliseconds interval=std::chrono::milliseconds(1000))
 Start polling.
void stop ()
bool running () const

Detailed Description

Calls on_change from a background thread whenever the combined input and output list changes.

enumerate returns the current ports and runs on that thread. Destruction (or stop()) joins the thread, so no callback runs afterwards. stop() may be called from on_change, in which case the thread winds down and is joined by the next stop() or the destructor.

Member Typedef Documentation

◆ Enumerate

using pulp::midi::PortChangePoller::Enumerate = std::function<std::vector<MidiPortInfo>()>

◆ OnChange

using pulp::midi::PortChangePoller::OnChange = std::function<void(const PortListDiff&)>

Constructor & Destructor Documentation

◆ PortChangePoller() [1/2]

pulp::midi::PortChangePoller::PortChangePoller ( )
default

◆ PortChangePoller() [2/2]

pulp::midi::PortChangePoller::PortChangePoller ( const PortChangePoller & )
delete

◆ ~PortChangePoller()

pulp::midi::PortChangePoller::~PortChangePoller ( )
inline

Member Function Documentation

◆ operator=()

PortChangePoller & pulp::midi::PortChangePoller::operator= ( const PortChangePoller & )
delete

◆ running()

bool pulp::midi::PortChangePoller::running ( ) const
inline

◆ start()

void pulp::midi::PortChangePoller::start ( Enumerate enumerate,
OnChange on_change,
std::chrono::milliseconds interval = std::chrono::milliseconds(1000) )
inline

Start polling.

The baseline is taken on the calling thread before the worker starts, so a change right after start() is never missed. Restarts if already running.

◆ stop()

void pulp::midi::PortChangePoller::stop ( )
inline

The documentation for this class was generated from the following file: