Skip to content
Open
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
25 changes: 14 additions & 11 deletions src/platform/linux/pipewire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,12 @@ namespace pipewire {

~pipewire_t() {
BOOST_LOG(debug) << "[pipewire] Destroying pipewire_t"sv;
if (loop) {
BOOST_LOG(debug) << "[pipewire] Stop PW thread loop"sv;
pw_thread_loop_stop(loop);
}
try {
cleanup_stream();
} catch (const std::exception &e) {
BOOST_LOG(error) << "[pipewire] Standard exception caught in ~pipewire_t: "sv << e.what();
BOOST_LOG(error) << "[pipewire] Standard exception caught in ~pipewire_t cleanup_stream: "sv << e.what();
} catch (...) {
BOOST_LOG(error) << "[pipewire] Unknown exception caught in ~pipewire_t"sv;
BOOST_LOG(error) << "[pipewire] Unknown exception caught in ~pipewire_t cleanup_stream"sv;
}

pw_thread_loop_lock(loop);
Expand Down Expand Up @@ -420,8 +416,13 @@ namespace pipewire {
};

static void on_stream_state_changed(void *user_data, enum pw_stream_state old, enum pw_stream_state state, const char *err_msg) {
BOOST_LOG(debug) << "[pipewire] PipeWire stream state: " << pw_stream_state_as_string(old)
<< " -> " << pw_stream_state_as_string(state);
if (err_msg != nullptr) {
BOOST_LOG(info) << "[pipewire] PipeWire stream error '" << err_msg << "' on state: " << pw_stream_state_as_string(old)
<< " -> " << pw_stream_state_as_string(state);
} else {
BOOST_LOG(info) << "[pipewire] PipeWire stream state: " << pw_stream_state_as_string(old)
<< " -> " << pw_stream_state_as_string(state);
}

auto *d = static_cast<stream_data_t *>(user_data);

Expand Down Expand Up @@ -853,18 +854,20 @@ namespace pipewire {
case platf::capture_e::timeout:
if (!pull_free_image_cb(img_out)) {
// Detect if shutdown is pending
BOOST_LOG(debug) << "[pipewire] PipeWire: timeout -> interrupt nudge";
BOOST_LOG(debug) << "[pipewire] PipeWire: timeout -> shutdown pending -> interrupt nudge";
pipewire.frame_cv().notify_all();
return platf::capture_e::interrupted;
}
if (!push_captured_image_cb(std::move(img_out), false)) {
BOOST_LOG(debug) << "[pipewire] PipeWire: !push_captured_image_cb -> ok";
BOOST_LOG(debug) << "[pipewire] PipeWire: timeout -> !push_captured_image_cb -> ok";
std::this_thread::sleep_for(10us); // Workaround: delay OK to avoid video stream freezing
return platf::capture_e::ok;
}
break;
case platf::capture_e::ok:
if (!push_captured_image_cb(std::move(img_out), true)) {
BOOST_LOG(debug) << "[pipewire] PipeWire: !push_captured_image_cb -> ok";
BOOST_LOG(debug) << "[pipewire] PipeWire: ok -> !push_captured_image_cb -> ok";
std::this_thread::sleep_for(10us); // Workaround: delay OK to avoid video stream freezing
return platf::capture_e::ok;
}
break;
Expand Down
Loading