Skip to content

llama-17925 : TextToSpeech crash, followed by black screen#6454

Open
kkarup694 wants to merge 1 commit into
rdkcentral:sprint/26Q1from
kkarup694:llama-17925
Open

llama-17925 : TextToSpeech crash, followed by black screen#6454
kkarup694 wants to merge 1 commit into
rdkcentral:sprint/26Q1from
kkarup694:llama-17925

Conversation

@kkarup694
Copy link
Copy Markdown
Contributor

Reason for change: fix for parallel pipeline set state
Test Procedure: Mentioned in ticket
Risks: Low
version: minor

Reason for change: fix for parallel pipeline set state
Test Procedure: Mentioned in ticket
Risks: Low
version: minor

Signed-off-by: kumar <kumar_Karuppiahyogarajah@comcast.com>
Copilot AI review requested due to automatic review settings February 3, 2026 10:57
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 attempts to fix a crash and black screen issue in TextToSpeech by adding mutex protection around GStreamer pipeline state changes. The changes introduce a new mutex (m_pipelineMutex) and a wrapper method (setPipelineState) that protects calls to gst_element_set_state.

Changes:

  • Added m_pipelineMutex member variable and setPipelineState method declaration in TTSSpeaker.h
  • Implemented setPipelineState method with mutex protection
  • Replaced all direct gst_element_set_state calls with setPipelineState

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
TextToSpeech/impl/TTSSpeaker.h Added mutex member and setPipelineState method declaration
TextToSpeech/impl/TTSSpeaker.cpp Implemented setPipelineState with mutex, replaced all gst_element_set_state calls

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

Comment on lines +927 to +933
if(m_pipeline)
{
std::lock_guard<std::mutex> lock(m_pipelineMutex);
gst_element_set_state(m_pipeline, state);
}
else
{
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The setPipelineState function has a time-of-check-time-of-use (TOCTOU) race condition. The m_pipeline pointer is checked for NULL before acquiring the mutex lock, but m_pipeline could be set to NULL by another thread (e.g., in destroyPipeline at line 975 or createPipeline at line 910) between the check and the lock acquisition. The NULL check should be performed after acquiring the mutex lock to ensure thread safety.

Suggested change
if(m_pipeline)
{
std::lock_guard<std::mutex> lock(m_pipelineMutex);
gst_element_set_state(m_pipeline, state);
}
else
{
std::lock_guard<std::mutex> lock(m_pipelineMutex);
if (m_pipeline) {
gst_element_set_state(m_pipeline, state);
} else {

Copilot uses AI. Check for mistakes.
Comment on lines 967 to 971
if(m_pipeline) {
gst_element_set_state(m_pipeline, GST_STATE_NULL);
setPipelineState(GST_STATE_NULL);
waitForStatus(GST_STATE_NULL, 1*1000);
g_source_remove(m_busWatch);
gst_object_unref(m_pipeline);
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The gst_object_unref operation on m_pipeline is not protected by the m_pipelineMutex. This creates a race condition where another thread could be calling setPipelineState and accessing m_pipeline while it's being unreferenced and destroyed here. The unref operation and the subsequent NULL assignment should be protected by the m_pipelineMutex to ensure thread safety.

Copilot uses AI. Check for mistakes.
}
else
{
TTSLOG_ERROR("Pipeline error occured");
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

Spelling error: "occured" should be "occurred" (with two 'r's).

Copilot uses AI. Check for mistakes.
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