Skip to content

Added deepelement signal disconnect#502

Open
balasaraswathy-n wants to merge 1 commit into
masterfrom
feature/RDKEMW-18594
Open

Added deepelement signal disconnect#502
balasaraswathy-n wants to merge 1 commit into
masterfrom
feature/RDKEMW-18594

Conversation

@balasaraswathy-n
Copy link
Copy Markdown

No description provided.

Copilot AI review requested due to automatic review settings May 19, 2026 13:19
@github-actions
Copy link
Copy Markdown

Pull request must be merged with a description containing the required fields,

Summary:
Type: Feature/Fix/Cleanup
Test Plan:
Jira:

If there is no jira releated to this change, please put 'Jira: NO-JIRA'.

Description can be changed by editing the top comment on your pull request and making a new commit.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to prevent late/async deep-element-added GStreamer callbacks from interacting with a tearing-down GstGenericPlayer, by tracking the signal handler ID, disconnecting it during destruction, and adding synchronization around worker-thread access.

Changes:

  • Store the deep-element-added signal handler ID and disconnect it during GstGenericPlayer destruction.
  • Add a shutdown fence (m_isShuttingDown) and guard deepElementAdded() against late callbacks.
  • Add a mutex to serialize worker-thread access between callbacks and teardown.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
media/server/gstplayer/source/GstGenericPlayer.cpp Track/disconnect deep-element-added, add shutdown guard and mutex usage in callback + worker teardown.
media/server/gstplayer/include/GstGenericPlayer.h Add new members for shutdown fencing, mutex protection, and handler ID storage.
Comments suppressed due to low confidence (1)

media/server/gstplayer/source/GstGenericPlayer.cpp:299

  • resetWorkerThread() now guards writes to m_workerThread with m_workerThreadMutex, and deepElementAdded() guards reads with the same mutex. However other GStreamer signal callbacks in this file (e.g. setupSource() / setupElement()) still read m_workerThread without taking this mutex, so concurrent teardown can still cause a C++ data race/UB. To actually make this thread-safe, the same synchronization (mutex and/or m_isShuttingDown check) needs to be applied consistently to all callbacks/threads that access m_workerThread.
void GstGenericPlayer::resetWorkerThread()
{
    std::lock_guard<std::mutex> lock{m_workerThreadMutex};

    if (!m_workerThread)
    {
        return;
    }

    // Shutdown task thread
    m_workerThread->enqueueTask(m_taskFactory->createShutdown(*this));
    m_workerThread->join();
    m_workerThread.reset();
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +228 to +233
// Disconnect deep-element callback before worker teardown.
if (m_context.pipeline && m_deepElementAddedHandlerId != 0)
{
g_signal_handler_disconnect(m_context.pipeline, m_deepElementAddedHandlerId);
m_deepElementAddedHandlerId = 0;
}
@github-actions
Copy link
Copy Markdown

Coverage statistics of your commit:
Lines coverage stays unchanged and is: 84.2%
Functions coverage stays unchanged and is: 92.6%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants