Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/libremidi/backends/pipewire/midi_in.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ class midi_in_pipewire final

assert(this->flt);
assert(this->port.valid());
// The filter can run before the local port exists (open sequence) or
// after it was removed (close sequence). With no valid port token there
// is no buffer to process; skip instead of dereferencing a null token
// (a release build with asserts compiled out would segfault).
if (!this->flt || !this->port.valid())
return;
const auto b = pw.filter_dequeue_buffer(this->port.opaque);
if (!b)
return;
Expand Down
6 changes: 6 additions & 0 deletions include/libremidi/backends/pipewire/midi_out.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ class midi_out_pipewire
int process(spa_io_position* pos)
{
m_process_clock.store(pos->clock.nsec, std::memory_order_relaxed);
// The filter can run before the local port exists (open sequence) or
// after it was removed (close sequence). With no valid port token there
// is no buffer to process; report idle instead of a null dereference
// (a release build with asserts compiled out would segfault).
if (!this->flt || !this->port.valid())
return 1;
const auto b = pw.filter_dequeue_buffer(this->port.opaque);
if (!b)
return 1;
Expand Down
6 changes: 6 additions & 0 deletions include/libremidi/backends/pipewire_ump/midi_in.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ class midi_in_pipewire final

assert(this->flt);
assert(this->port.valid());
// The filter can run before the local port exists (open sequence) or
// after it was removed (close sequence). With no valid port token there
// is no buffer to process; skip instead of dereferencing a null token
// (a release build with asserts compiled out would segfault).
if (!this->flt || !this->port.valid())
return;
const auto b = pw.filter_dequeue_buffer(this->port.opaque);
if (!b)
return;
Expand Down
6 changes: 6 additions & 0 deletions include/libremidi/backends/pipewire_ump/midi_out.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ class midi_out_pipewire
int process(spa_io_position* pos)
{
m_process_clock.store(pos->clock.nsec, std::memory_order_relaxed);
// The filter can run before the local port exists (open sequence) or
// after it was removed (close sequence). With no valid port token there
// is no buffer to process; report idle instead of a null dereference
// (a release build with asserts compiled out would segfault).
if (!this->flt || !this->port.valid())
return 1;
const auto b = pw.filter_dequeue_buffer(this->port.opaque);
if (!b)
return 1;
Expand Down