ref:c4b30655b832466a0e94fc4732f7aaedccf2e6e1

refactor(linux): remove leftovers from portalgrab -> pipewire split (#5039)

SHA: c4b30655b832466a0e94fc4732f7aaedccf2e6e1
Author: Conn O'Griofa <connogriofa@gmail.com>
Date: 2026-04-23 00:25
Parents: 1ba440e
2 files changed +2 -97
Type
src/platform/linux/pipewire.cpp +2 −22
@@ -3,15 +3,7 @@
* @brief Shared classes for pipewire-based capture methods.
*/
// standard includes
#include <array>
#include <fcntl.h>
#include <format>
#include <fstream>
#include <memory>
#include <mutex>
#include <string.h>
#include <string_view>
#include <thread>
// lib includes
#include <gio/gio.h>
@@ -32,12 +24,6 @@
#include "vulkan_encode.h"
#include "wayland.h"
#if !defined(__FreeBSD__)
// platform includes
#include <sys/capability.h>
#include <sys/prctl.h>
#endif
namespace {
// Buffer and limit constants
constexpr int SPA_POD_BUFFER_SIZE = 4096;
@@ -60,12 +46,6 @@
{0, 0},
}};
struct dbus_response_t {
GMainLoop *loop;
GVariant *response;
guint subscription_id;
};
struct shared_state_t {
std::atomic<int> negotiated_width {0};
std::atomic<int> negotiated_height {0};
@@ -698,12 +678,12 @@
}
if (pipewire.init(pipewire_fd, pipewire_node, shared_state) < 0) {
BOOST_LOG(error) << "[pipewire] Failed to init pipewire. portal_t::init() failed.";
BOOST_LOG(error) << "[pipewire] Failed to init pipewire. pipewire_t::init() failed.";
return -1;
}
// Start PipeWire now so format negotiation can proceed before capture start
if (pipewire.ensure_stream(mem_type, width, height, framerate, dmabuf_infos.data(), n_dmabuf_infos, display_is_nvidia) < 0) {
BOOST_LOG(error) << "[pipewire] Failed to ensure pipewire stream. pipewire_t::init() failed.";
BOOST_LOG(error) << "[pipewire] Failed to ensure pipewire stream. portal_t::init() failed.";
return -1;
}
src/platform/linux/portalgrab.cpp +0 −75
@@ -2,36 +2,8 @@
* @file src/platform/linux/portalgrab.cpp
* @brief Definitions for XDG portal grab.
*/
// standard includes
#include <array>
#include <fcntl.h>
#include <format>
#include <fstream>
#include <memory>
#include <mutex>
#include <string.h>
#include <string_view>
#include <thread>
// lib includes
#include <gio/gio.h>
#include <gio/gunixfdlist.h>
#include <libdrm/drm_fourcc.h>
#include <pipewire/pipewire.h>
#include <spa/param/video/format-utils.h>
#include <spa/param/video/type-info.h>
#include <spa/pod/builder.h>
// local includes
#include "cuda.h"
#include "graphics.h"
#include "pipewire.cpp"
#include "src/main.h"
#include "src/platform/common.h"
#include "src/video.h"
#include "vaapi.h"
#include "vulkan_encode.h"
#include "wayland.h"
namespace {
// Portal configuration constants
@@ -108,57 +80,10 @@
}
};
struct format_map_t {
uint64_t fourcc;
int32_t pw_format;
};
static constexpr std::array<format_map_t, 3> format_map = {{
{DRM_FORMAT_ARGB8888, SPA_VIDEO_FORMAT_BGRA},
{DRM_FORMAT_XRGB8888, SPA_VIDEO_FORMAT_BGRx},
{0, 0},
}};
struct dbus_response_t {
GMainLoop *loop;
GVariant *response;
guint subscription_id;
};
struct shared_state_t {
std::atomic<int> negotiated_width {0};
std::atomic<int> negotiated_height {0};
std::atomic<bool> stream_dead {false};
};
struct stream_data_t {
struct pw_stream *stream;
struct spa_hook stream_listener;
struct spa_video_info format;
struct pw_buffer *current_buffer;
uint64_t drm_format;
std::shared_ptr<shared_state_t> shared;
std::mutex frame_mutex;
std::condition_variable frame_cv;
size_t local_stride = 0;
bool frame_ready = false;
// Two distinct memory pools
std::vector<uint8_t> buffer_a;
std::vector<uint8_t> buffer_b;
// Points to the buffer currently owned by fill_img
std::vector<uint8_t> *front_buffer;
// Points to the buffer currently being written by on_process
std::vector<uint8_t> *back_buffer;
stream_data_t():
front_buffer(&buffer_a),
back_buffer(&buffer_b) {}
};
struct dmabuf_format_info_t {
int32_t format;
uint64_t *modifiers;
int n_modifiers;
};
struct pipewire_streaminfo_t {