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.
This commit is contained in:
Vlad Zahorodnii 2024-03-26 18:53:59 +02:00
parent 7894db7504
commit cd2a4de82f
3 changed files with 21 additions and 21 deletions

View file

@ -121,8 +121,8 @@ void ScreencastManager::streamRegion(ScreencastStreamV1Interface *waylandStream,
void ScreencastManager::integrateStreams(ScreencastStreamV1Interface *waylandStream, ScreenCastStream *stream) void ScreencastManager::integrateStreams(ScreencastStreamV1Interface *waylandStream, ScreenCastStream *stream)
{ {
connect(waylandStream, &ScreencastStreamV1Interface::finished, stream, &ScreenCastStream::stop); connect(waylandStream, &ScreencastStreamV1Interface::finished, stream, &ScreenCastStream::close);
connect(stream, &ScreenCastStream::stopStreaming, waylandStream, [stream, waylandStream] { connect(stream, &ScreenCastStream::closed, waylandStream, [stream, waylandStream] {
waylandStream->sendClosed(); waylandStream->sendClosed();
stream->deleteLater(); stream->deleteLater();
}); });

View file

@ -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) 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; 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; return;
} }
@ -100,7 +100,7 @@ void ScreenCastStream::onStreamStateChanged(pw_stream_state old, pw_stream_state
case PW_STREAM_STATE_CONNECTING: case PW_STREAM_STATE_CONNECTING:
break; break;
case PW_STREAM_STATE_UNCONNECTED: case PW_STREAM_STATE_UNCONNECTED:
stop(); close();
break; break;
} }
} }
@ -156,7 +156,7 @@ void ScreenCastStream::newStreamParams()
void ScreenCastStream::onStreamParamChanged(uint32_t id, const struct spa_pod *format) void ScreenCastStream::onStreamParamChanged(uint32_t id, const struct spa_pod *format)
{ {
if (m_stopped) { if (m_closed) {
return; return;
} }
@ -221,7 +221,7 @@ void ScreenCastStream::onStreamParamChanged(uint32_t id, const struct spa_pod *f
void ScreenCastStream::onStreamAddBuffer(pw_buffer *buffer) void ScreenCastStream::onStreamAddBuffer(pw_buffer *buffer)
{ {
if (m_stopped) { if (m_closed) {
return; return;
} }
@ -307,14 +307,14 @@ void ScreenCastStream::onStreamRemoveBuffer(pw_buffer *buffer)
struct spa_buffer *spa_buffer = buffer->buffer; struct spa_buffer *spa_buffer = buffer->buffer;
struct spa_data *spa_data = spa_buffer->datas; struct spa_data *spa_data = spa_buffer->datas;
if (spa_data && spa_data->type == SPA_DATA_MemFd) { if (spa_data && spa_data->type == SPA_DATA_MemFd) {
munmap(spa_data->data, spa_data->maxsize); ::munmap(spa_data->data, spa_data->maxsize);
close(spa_data->fd); ::close(spa_data->fd);
} }
} }
void ScreenCastStream::onStreamRenegotiateFormat(uint64_t) void ScreenCastStream::onStreamRenegotiateFormat(uint64_t)
{ {
if (m_stopped) { if (m_closed) {
return; return;
} }
@ -331,7 +331,7 @@ ScreenCastStream::ScreenCastStream(ScreenCastSource *source, std::shared_ptr<Pip
, m_resolution(source->textureSize()) , m_resolution(source->textureSize())
{ {
connect(source, &ScreenCastSource::frame, this, &ScreenCastStream::recordFrame); 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.version = PW_VERSION_STREAM_EVENTS;
m_pwStreamEvents.add_buffer = [](void *data, struct pw_buffer *buffer) { m_pwStreamEvents.add_buffer = [](void *data, struct pw_buffer *buffer) {
@ -359,7 +359,7 @@ ScreenCastStream::ScreenCastStream(ScreenCastSource *source, std::shared_ptr<Pip
ScreenCastStream::~ScreenCastStream() ScreenCastStream::~ScreenCastStream()
{ {
m_stopped = true; m_closed = true;
if (m_pwStream) { if (m_pwStream) {
pw_stream_destroy(m_pwStream); pw_stream_destroy(m_pwStream);
} }
@ -460,17 +460,17 @@ bool ScreenCastStream::createStream()
void ScreenCastStream::coreFailed(const QString &errorMessage) void ScreenCastStream::coreFailed(const QString &errorMessage)
{ {
m_error = errorMessage; m_error = errorMessage;
stop(); close();
} }
void ScreenCastStream::stop() void ScreenCastStream::close()
{ {
if (m_stopped) { if (m_closed) {
return; return;
} }
m_streaming = false; m_streaming = false;
m_stopped = true; m_closed = true;
m_pendingFrame.stop(); m_pendingFrame.stop();
disconnect(m_cursor.changedConnection); disconnect(m_cursor.changedConnection);
@ -480,13 +480,13 @@ void ScreenCastStream::stop()
m_source->pause(); m_source->pause();
Q_EMIT stopStreaming(); Q_EMIT closed();
} }
void ScreenCastStream::recordFrame(const QRegion &_damagedRegion) void ScreenCastStream::recordFrame(const QRegion &_damagedRegion)
{ {
QRegion damagedRegion = _damagedRegion; QRegion damagedRegion = _damagedRegion;
Q_ASSERT(!m_stopped); Q_ASSERT(!m_closed);
if (!m_streaming) { if (!m_streaming) {
m_pendingDamages += damagedRegion; m_pendingDamages += damagedRegion;
@ -690,7 +690,7 @@ void ScreenCastStream::invalidateCursor()
void ScreenCastStream::recordCursor() void ScreenCastStream::recordCursor()
{ {
Q_ASSERT(!m_stopped); Q_ASSERT(!m_closed);
if (!m_streaming) { if (!m_streaming) {
return; return;
} }

View file

@ -59,7 +59,7 @@ public:
return m_error; return m_error;
} }
void stop(); void close();
/** /**
* Renders @p frame into the current framebuffer into the stream * Renders @p frame into the current framebuffer into the stream
@ -76,7 +76,7 @@ public Q_SLOTS:
Q_SIGNALS: Q_SIGNALS:
void streamReady(quint32 nodeId); void streamReady(quint32 nodeId);
void stopStreaming(); void closed();
private: private:
void onStreamParamChanged(uint32_t id, const struct spa_pod *format); void onStreamParamChanged(uint32_t id, const struct spa_pod *format);
@ -111,7 +111,7 @@ private:
uint32_t m_pwNodeId = 0; uint32_t m_pwNodeId = 0;
QSize m_resolution; QSize m_resolution;
bool m_stopped = false; bool m_closed = false;
bool m_streaming = false; bool m_streaming = false;
spa_video_info_raw m_videoFormat; spa_video_info_raw m_videoFormat;