Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 27, 2025

When gst_element_link or gst_element_link_many failed after elements were added to the pipeline bin, the code returned early without removing them. This left orphaned elements in the bin with null/uninitialized member pointers.

Changes

  • Added cleanup on link failures: Both error paths now call gst_bin_remove_many() to remove elements from the bin before returning, allowing RAII wrappers to properly destroy them
  • Extracted cleanup logic: Introduced cleanup_on_error lambda to eliminate code duplication across error paths
// Helper lambda to clean up elements from bin on error
auto cleanup_on_error = [&]() {
    gst_bin_remove_many(
        GST_BIN(pipeline),
        appsrcLocal.get(),
        decodebinLocal.get(),
        convLocal.get(),
        postLocal.get(),
        sinkLocal.get(),
        nullptr);
};

// --- Link appsrc -> decodebin ---
if (!gst_element_link(appsrcLocal.get(), decodebinLocal.get()))
{
    GST_ERROR("gst_element_link(appsrc->decodebin) failed");
    cleanup_on_error();
    return;
}

This ensures the bin releases its references, preventing memory leaks and maintaining consistent state between bin ownership and member pointers.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

pstroffolino and others added 7 commits December 27, 2025 12:33
Reason for Change: additional seek refactoring

Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com>
Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com>
Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com>
Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com>
Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com>
Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI self-assigned this Dec 27, 2025
Copilot AI and others added 2 commits December 27, 2025 23:50
Remove elements from pipeline bin when linking fails to prevent orphaned elements.
Previously, when gst_element_link or gst_element_link_many failed, elements
remained in the bin but member pointers were set to null or uninitialized,
creating an inconsistent state. Now properly removes elements from bin on
failure, allowing RAII wrappers to clean up correctly.

Addresses feedback: #803 (comment)

Co-authored-by: pstroffolino <20442081+pstroffolino@users.noreply.github.com>
Introduced a cleanup_on_error lambda to consolidate the repeated
gst_bin_remove_many calls in both error paths. This improves
maintainability and ensures consistency.

Co-authored-by: pstroffolino <20442081+pstroffolino@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP addressing feedback on VPLAY-12259 refactoring Fix incomplete error handling in MediaStream::Configure Dec 27, 2025
Copilot AI requested a review from pstroffolino December 27, 2025 23:55
Base automatically changed from feature/VPLAY-12259_refactoring2 to dev_sprint_25_2 December 28, 2025 02:29
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