From cd2a4de82f4e634cc96863c59b0fad1c35b4d0a0 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 26 Mar 2024 18:53:59 +0200 Subject: [PATCH] plugins/screencast: Rename ScreenCastStream::stop() to close() This is to help disambiguating between the code that shuts down the stream completely and one that pauses/resumes the stream. --- src/plugins/screencast/screencastmanager.cpp | 4 +-- src/plugins/screencast/screencaststream.cpp | 32 ++++++++++---------- src/plugins/screencast/screencaststream.h | 6 ++-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/plugins/screencast/screencastmanager.cpp b/src/plugins/screencast/screencastmanager.cpp index 12326560e4..1b515ad03b 100644 --- a/src/plugins/screencast/screencastmanager.cpp +++ b/src/plugins/screencast/screencastmanager.cpp @@ -121,8 +121,8 @@ void ScreencastManager::streamRegion(ScreencastStreamV1Interface *waylandStream, void ScreencastManager::integrateStreams(ScreencastStreamV1Interface *waylandStream, ScreenCastStream *stream) { - connect(waylandStream, &ScreencastStreamV1Interface::finished, stream, &ScreenCastStream::stop); - connect(stream, &ScreenCastStream::stopStreaming, waylandStream, [stream, waylandStream] { + connect(waylandStream, &ScreencastStreamV1Interface::finished, stream, &ScreenCastStream::close); + connect(stream, &ScreenCastStream::closed, waylandStream, [stream, waylandStream] { waylandStream->sendClosed(); stream->deleteLater(); }); diff --git a/src/plugins/screencast/screencaststream.cpp b/src/plugins/screencast/screencaststream.cpp index b8d373b9aa..4b06c130d8 100644 --- a/src/plugins/screencast/screencaststream.cpp +++ b/src/plugins/screencast/screencaststream.cpp @@ -76,7 +76,7 @@ static spa_video_format drmFourCCToSpaVideoFormat(quint32 format) void ScreenCastStream::onStreamStateChanged(pw_stream_state old, pw_stream_state state, const char *error_message) { qCDebug(KWIN_SCREENCAST) << objectName() << "state changed" << pw_stream_state_as_string(old) << " -> " << pw_stream_state_as_string(state) << error_message; - if (m_stopped) { + if (m_closed) { return; } @@ -100,7 +100,7 @@ void ScreenCastStream::onStreamStateChanged(pw_stream_state old, pw_stream_state case PW_STREAM_STATE_CONNECTING: break; case PW_STREAM_STATE_UNCONNECTED: - stop(); + close(); break; } } @@ -156,7 +156,7 @@ void ScreenCastStream::newStreamParams() void ScreenCastStream::onStreamParamChanged(uint32_t id, const struct spa_pod *format) { - if (m_stopped) { + if (m_closed) { return; } @@ -221,7 +221,7 @@ void ScreenCastStream::onStreamParamChanged(uint32_t id, const struct spa_pod *f void ScreenCastStream::onStreamAddBuffer(pw_buffer *buffer) { - if (m_stopped) { + if (m_closed) { return; } @@ -307,14 +307,14 @@ void ScreenCastStream::onStreamRemoveBuffer(pw_buffer *buffer) struct spa_buffer *spa_buffer = buffer->buffer; struct spa_data *spa_data = spa_buffer->datas; if (spa_data && spa_data->type == SPA_DATA_MemFd) { - munmap(spa_data->data, spa_data->maxsize); - close(spa_data->fd); + ::munmap(spa_data->data, spa_data->maxsize); + ::close(spa_data->fd); } } void ScreenCastStream::onStreamRenegotiateFormat(uint64_t) { - if (m_stopped) { + if (m_closed) { return; } @@ -331,7 +331,7 @@ ScreenCastStream::ScreenCastStream(ScreenCastSource *source, std::shared_ptrtextureSize()) { connect(source, &ScreenCastSource::frame, this, &ScreenCastStream::recordFrame); - connect(source, &ScreenCastSource::closed, this, &ScreenCastStream::stop); + connect(source, &ScreenCastSource::closed, this, &ScreenCastStream::close); m_pwStreamEvents.version = PW_VERSION_STREAM_EVENTS; m_pwStreamEvents.add_buffer = [](void *data, struct pw_buffer *buffer) { @@ -359,7 +359,7 @@ ScreenCastStream::ScreenCastStream(ScreenCastSource *source, std::shared_ptrpause(); - Q_EMIT stopStreaming(); + Q_EMIT closed(); } void ScreenCastStream::recordFrame(const QRegion &_damagedRegion) { QRegion damagedRegion = _damagedRegion; - Q_ASSERT(!m_stopped); + Q_ASSERT(!m_closed); if (!m_streaming) { m_pendingDamages += damagedRegion; @@ -690,7 +690,7 @@ void ScreenCastStream::invalidateCursor() void ScreenCastStream::recordCursor() { - Q_ASSERT(!m_stopped); + Q_ASSERT(!m_closed); if (!m_streaming) { return; } diff --git a/src/plugins/screencast/screencaststream.h b/src/plugins/screencast/screencaststream.h index 9b35fa1c34..9ea30772b8 100644 --- a/src/plugins/screencast/screencaststream.h +++ b/src/plugins/screencast/screencaststream.h @@ -59,7 +59,7 @@ public: return m_error; } - void stop(); + void close(); /** * Renders @p frame into the current framebuffer into the stream @@ -76,7 +76,7 @@ public Q_SLOTS: Q_SIGNALS: void streamReady(quint32 nodeId); - void stopStreaming(); + void closed(); private: void onStreamParamChanged(uint32_t id, const struct spa_pod *format); @@ -111,7 +111,7 @@ private: uint32_t m_pwNodeId = 0; QSize m_resolution; - bool m_stopped = false; + bool m_closed = false; bool m_streaming = false; spa_video_info_raw m_videoFormat;