From a790b8d7a7a7498cbddc148a320aac9bdbf029dd Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Sat, 16 Oct 2021 04:40:56 +0200 Subject: [PATCH] pipewire: allow disabling dmabuf on streams So far, it's helpful to debug this kind of streams. --- libtaskmanager/declarative/pipewiresourcestream.cpp | 8 +++++--- libtaskmanager/declarative/pipewiresourcestream.h | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libtaskmanager/declarative/pipewiresourcestream.cpp b/libtaskmanager/declarative/pipewiresourcestream.cpp index c00f60d15..a6713ae76 100644 --- a/libtaskmanager/declarative/pipewiresourcestream.cpp +++ b/libtaskmanager/declarative/pipewiresourcestream.cpp @@ -187,7 +187,7 @@ void PipeWireSourceStream::onStreamParamChanged(void *data, uint32_t id, const s uint8_t paramsBuffer[1024]; spa_pod_builder pod_builder = SPA_POD_BUILDER_INIT(paramsBuffer, sizeof(paramsBuffer)); - const auto bufferTypes = spa_pod_find_prop(format, nullptr, SPA_FORMAT_VIDEO_modifier) + const auto bufferTypes = pw->m_allowDmaBuf && spa_pod_find_prop(format, nullptr, SPA_FORMAT_VIDEO_modifier) ? (1 << SPA_DATA_DmaBuf) | (1 << SPA_DATA_MemFd) | (1 << SPA_DATA_MemPtr) : (1 << SPA_DATA_MemFd) | (1 << SPA_DATA_MemPtr); @@ -269,8 +269,10 @@ bool PipeWireSourceStream::createStream(uint nodeid) params.reserve(formats.size() * 2); const EGLDisplay display = static_cast(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("egldisplay")); for (spa_video_format format : formats) { - if (auto modifiers = queryDmaBufModifiers(display, format); modifiers.size() > 0) { - params += buildFormat(&podBuilder, format, modifiers); + if (m_allowDmaBuf) { + if (auto modifiers = queryDmaBufModifiers(display, format); modifiers.size() > 0) { + params += buildFormat(&podBuilder, format, modifiers); + } } params += buildFormat(&podBuilder, format, {}); diff --git a/libtaskmanager/declarative/pipewiresourcestream.h b/libtaskmanager/declarative/pipewiresourcestream.h index 91e0c8eb6..93133c0bb 100644 --- a/libtaskmanager/declarative/pipewiresourcestream.h +++ b/libtaskmanager/declarative/pipewiresourcestream.h @@ -64,6 +64,8 @@ public: void handleFrame(struct pw_buffer *buffer); void process(); + bool setAllowDmaBuf(bool allowed); + Q_SIGNALS: void streamReady(); void startStreaming(); @@ -85,4 +87,5 @@ private: spa_video_info_raw videoFormat; QString m_error; + bool m_allowDmaBuf = true; };