Skip to content

Fix reattaching audio source at dynamic audio codec change. (#530)#537

Merged
smudri85 merged 1 commit into
release/v0.22.1from
RDKEMW-17771_8.6
Jun 23, 2026
Merged

Fix reattaching audio source at dynamic audio codec change. (#530)#537
smudri85 merged 1 commit into
release/v0.22.1from
RDKEMW-17771_8.6

Conversation

@smudri85

Copy link
Copy Markdown
Contributor

Summary: Fix reattaching audio source at dynamic audio codec change.
Type: Fix
Test Plan: UT/CT, Fullstack
Jira: RDKEMW-17771


Summary: Fix reattaching audio source at dynamic audio codec change.
Type: Fix
Test Plan: UT/CT, Fullstack
Jira: RDKEMW-17771

---------

Co-authored-by: Marcin Wojciechowski <marcin.wojciechowski@sky.uk>
Co-authored-by: Sasa Mudri <Sasa_Mudri@comcast.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 22, 2026 08:05
@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.

@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 addresses failures when reattaching the audio source during a dynamic audio codec change by introducing explicit “remove source” handling on the GStreamer player side and by gating audio data/underflow behavior while the audio source is considered removed.

Changes:

  • Add IGstGenericPlayer::removeSource() and a new tasks::generic::RemoveSource task to reset audio-stream state on removal.
  • Prevent audio data requests and audio underflow notifications while audioSourceRemoved is set; ensure reattach re-enables data flow.
  • Extend unit tests/mocks and task-factory coverage to validate the new remove/reattach behavior.

Reviewed changes

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

Show a summary per file
File Description
tests/unittests/media/server/mocks/gstplayer/GstGenericPlayerPrivateMock.h Minor mock header cleanup.
tests/unittests/media/server/mocks/gstplayer/GstGenericPlayerMock.h Add removeSource() mock for new player API.
tests/unittests/media/server/mocks/gstplayer/GenericPlayerTaskFactoryMock.h Add createRemoveSource() factory mock method.
tests/unittests/media/server/main/mediaPipeline/SourceTest.cpp Assert server-side removeSource() triggers Gst player removal.
tests/unittests/media/server/gstplayer/genericPlayer/tasksTests/RemoveSourceTest.cpp New task-level tests for RemoveSource behavior.
tests/unittests/media/server/gstplayer/genericPlayer/tasksTests/NeedDataTest.cpp Add test for NeedData behavior when audio source is removed.
tests/unittests/media/server/gstplayer/genericPlayer/tasksTests/GenericPlayerTaskFactoryTest.cpp Validate factory can create RemoveSource task.
tests/unittests/media/server/gstplayer/genericPlayer/tasksTests/AttachSourceTest.cpp Update reattach tests to require “removed” state + data request.
tests/unittests/media/server/gstplayer/genericPlayer/GstGenericPlayerTest.cpp Add test for GstGenericPlayer::removeSource() scheduling.
tests/unittests/media/server/gstplayer/genericPlayer/GstGenericPlayerPrivateTest.cpp Update/extend underflow scheduling tests with audioSourceRemoved.
tests/unittests/media/server/gstplayer/genericPlayer/common/GenericTasksTestsBase.h Add helpers for removed-source and RemoveSource task testing.
tests/unittests/media/server/gstplayer/genericPlayer/common/GenericTasksTestsBase.cpp Implement new test helpers + trigger RemoveSource task execution.
tests/unittests/media/server/gstplayer/CMakeLists.txt Register new RemoveSource unit test.
media/server/main/source/MediaPipelineServerInternal.cpp Invoke Gst player removeSource(type) during pipeline source removal.
media/server/gstplayer/source/tasks/generic/RemoveSource.cpp New task to reset audio-stream state/buffers/EOS info on removal.
media/server/gstplayer/source/tasks/generic/NeedData.cpp Skip requesting audio data from client when audio source is removed.
media/server/gstplayer/source/tasks/generic/GenericPlayerTaskFactory.cpp Add factory creation of RemoveSource task.
media/server/gstplayer/source/tasks/generic/CheckAudioUnderflow.cpp Disable audio underflow handling when audio source is removed.
media/server/gstplayer/source/tasks/generic/AttachSource.cpp On audio reattach, re-enable data-needed and request more audio data.
media/server/gstplayer/source/GstGenericPlayer.cpp Add removeSource() and gate underflow scheduling on removed-audio flag.
media/server/gstplayer/interface/IGstGenericPlayer.h Add removeSource() API (doc requires alignment with implementation).
media/server/gstplayer/include/tasks/IGenericPlayerTaskFactory.h Add createRemoveSource() to task factory interface.
media/server/gstplayer/include/tasks/generic/RemoveSource.h New RemoveSource task header.
media/server/gstplayer/include/tasks/generic/GenericPlayerTaskFactory.h Declare createRemoveSource() override.
media/server/gstplayer/include/GstGenericPlayer.h Declare removeSource() on concrete player.
media/server/gstplayer/include/GenericPlayerContext.h Add audioSourceRemoved flag to player context.
media/server/gstplayer/CMakeLists.txt Build system: compile new RemoveSource task into gstplayer library.

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

Comment on lines +92 to +97
/**
* @brief Removes a source from gstreamer.
*
* @param[in] mediaSourceType : The media source type.
*
*/
Comment on lines 1700 to 1707
void GstGenericPlayer::scheduleAudioUnderflow()
{
if (m_workerThread)
{
bool underflowEnabled = m_context.isPlaying;
bool underflowEnabled = m_context.isPlaying && !m_context.audioSourceRemoved;
m_workerThread->enqueueTask(
m_taskFactory->createUnderflow(m_context, *this, underflowEnabled, MediaSourceType::AUDIO));
}
Comment on lines +210 to +214
/**
* @brief Flag used to check, if audio source has been recently removed
*
* Flag can be used only in worker thread
*/
@github-actions

Copy link
Copy Markdown

Coverage statistics of your commit:
Congratulations, your commit improved lines coverage from: 0.0% to 84.2%
Congratulations, your commit improved functions coverage from: 0.0% to 92.6%

@smudri85 smudri85 merged commit cb5f80b into release/v0.22.1 Jun 23, 2026
32 of 35 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants