Changeset 238412 in webkit


Ignore:
Timestamp:
Nov 21, 2018 12:49:39 AM (5 years ago)
Author:
aboya@igalia.com
Message:

[MSE][GStreamer] Refactor AppendPipeline deinitialization
https://bugs.webkit.org/show_bug.cgi?id=191759

Reviewed by Xabier Rodriguez-Calvar.

AppendPipeline currently has a method, clearPlayerPrivate(), that the
client code uses to deinitialize most of the AppendPipeline... just
before actually destructing it in the next line of code.

Since at that point there should not be alive RefPtr's pointing to the
AppendPipeline there is no need for this kind of pre-deinitialization
in this usage pattern. Instead, we can just rely on C++ destructors,
cleaning the code a bit and removing the potential for the question
"what if clearPlayerPrivate() has been called before?": it has not.

Assertions have been added to ensure that there is only one alive
RefPtr pointing to AppendPipeline, therefore guaranteeing its immediate
destruction.

  • platform/graphics/gstreamer/mse/AppendPipeline.cpp:

(WebCore::AppendPipeline::~AppendPipeline):
(WebCore::AppendPipeline::deinitialize):
(WebCore::AppendPipeline::clearPlayerPrivate): Deleted.

  • platform/graphics/gstreamer/mse/AppendPipeline.h:
  • platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:

(WebCore::MediaPlayerPrivateGStreamerMSE::~MediaPlayerPrivateGStreamerMSE):

  • platform/graphics/gstreamer/mse/MediaSourceClientGStreamerMSE.cpp:

(WebCore::MediaSourceClientGStreamerMSE::removedFromMediaSource):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r238410 r238412  
     12018-11-21  Alicia Boya García  <aboya@igalia.com>
     2
     3        [MSE][GStreamer] Refactor AppendPipeline deinitialization
     4        https://bugs.webkit.org/show_bug.cgi?id=191759
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        AppendPipeline currently has a method, clearPlayerPrivate(), that the
     9        client code uses to deinitialize most of the AppendPipeline... just
     10        before actually destructing it in the next line of code.
     11
     12        Since at that point there should not be alive RefPtr's pointing to the
     13        AppendPipeline there is no need for this kind of pre-deinitialization
     14        in this usage pattern. Instead, we can just rely on C++ destructors,
     15        cleaning the code a bit and removing the potential for the question
     16        "what if `clearPlayerPrivate() has been called before?`": it has not.
     17
     18        Assertions have been added to ensure that there is only one alive
     19        RefPtr pointing to AppendPipeline, therefore guaranteeing its immediate
     20        destruction.
     21
     22        * platform/graphics/gstreamer/mse/AppendPipeline.cpp:
     23        (WebCore::AppendPipeline::~AppendPipeline):
     24        (WebCore::AppendPipeline::deinitialize):
     25        (WebCore::AppendPipeline::clearPlayerPrivate): Deleted.
     26        * platform/graphics/gstreamer/mse/AppendPipeline.h:
     27        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
     28        (WebCore::MediaPlayerPrivateGStreamerMSE::~MediaPlayerPrivateGStreamerMSE):
     29        * platform/graphics/gstreamer/mse/MediaSourceClientGStreamerMSE.cpp:
     30        (WebCore::MediaSourceClientGStreamerMSE::removedFromMediaSource):
     31
    1322018-11-20  Dean Jackson  <dino@apple.com>
    233
  • trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp

    r238287 r238412  
    226226AppendPipeline::~AppendPipeline()
    227227{
     228    GST_TRACE("Destructing AppendPipeline (%p)", this);
    228229    ASSERT(isMainThread());
    229230
     
    232233    m_taskQueue.startAborting();
    233234
    234     GST_TRACE("Destroying AppendPipeline (%p)", this);
    235 
    236     // FIXME: Maybe notify appendComplete here?
     235    // Disconnect all synchronous event handlers and probes susceptible of firing from the main thread
     236    // when changing the pipeline state.
    237237
    238238    if (m_pipeline) {
     
    241241        gst_bus_disable_sync_message_emission(m_bus.get());
    242242        gst_bus_remove_signal_watch(m_bus.get());
    243         gst_element_set_state(m_pipeline.get(), GST_STATE_NULL);
    244         m_pipeline = nullptr;
    245     }
    246 
    247     if (m_appsrc) {
     243    }
     244
     245    if (m_appsrc)
    248246        g_signal_handlers_disconnect_by_data(m_appsrc.get(), this);
    249         m_appsrc = nullptr;
    250     }
    251247
    252248    if (m_demux) {
     
    257253
    258254        g_signal_handlers_disconnect_by_data(m_demux.get(), this);
    259         m_demux = nullptr;
    260255    }
    261256
     
    272267        gst_pad_remove_probe(appsinkPad.get(), m_appsinkPadEventProbeInformation.probeId);
    273268#endif
    274         m_appsink = nullptr;
    275     }
    276 
    277     m_appsinkCaps = nullptr;
    278     m_demuxerSrcPadCaps = nullptr;
    279 };
     269    }
     270
     271    // We can tear down the pipeline safely now.
     272    if (m_pipeline)
     273        gst_element_set_state(m_pipeline.get(), GST_STATE_NULL);
     274}
    280275
    281276GstPadProbeReturn AppendPipeline::appsrcEndOfAppendCheckerProbe(GstPadProbeInfo* padProbeInfo)
     
    298293    });
    299294    return GST_PAD_PROBE_DROP;
    300 }
    301 
    302 void AppendPipeline::clearPlayerPrivate()
    303 {
    304     ASSERT(isMainThread());
    305     GST_DEBUG("cleaning private player");
    306 
    307     // Make sure that AppendPipeline won't process more data from now on and
    308     // instruct handleNewSample to abort itself from now on as well.
    309     setAppendState(AppendState::Invalid);
    310     m_taskQueue.startAborting();
    311 
    312     // And now that no handleNewSample operations will remain stalled waiting
    313     // for the main thread, stop the pipeline.
    314     if (m_pipeline)
    315         gst_element_set_state(m_pipeline.get(), GST_STATE_NULL);
    316295}
    317296
  • trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.h

    r238084 r238412  
    5151
    5252    GstFlowReturn pushNewBuffer(GstBuffer*);
    53     void clearPlayerPrivate();
    5453    void abort();
    5554    Ref<SourceBufferPrivateGStreamer> sourceBufferPrivate() { return m_sourceBufferPrivate.get(); }
  • trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp

    r238131 r238412  
    9898    GST_TRACE("destroying the player (%p)", this);
    9999
     100    // Clear the AppendPipeline map. This should cause the destruction of all the AppendPipeline's since there should
     101    // be no alive references at this point.
     102#ifndef NDEBUG
    100103    for (auto iterator : m_appendPipelinesMap)
    101         iterator.value->clearPlayerPrivate();
     104        ASSERT(iterator.value->hasOneRef());
     105#endif
     106    m_appendPipelinesMap.clear();
    102107
    103108    if (m_source) {
  • trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourceClientGStreamerMSE.cpp

    r232505 r238412  
    170170    ASSERT(m_playerPrivate->m_playbackPipeline);
    171171
    172     RefPtr<AppendPipeline> appendPipeline = m_playerPrivate->m_appendPipelinesMap.get(sourceBufferPrivate);
    173 
    174     ASSERT(appendPipeline);
    175 
    176     appendPipeline->clearPlayerPrivate();
     172    // Remove the AppendPipeline from the map. This should cause its destruction since there should be no alive
     173    // references at this point.
     174    ASSERT(m_playerPrivate->m_appendPipelinesMap.get(sourceBufferPrivate)->hasOneRef());
    177175    m_playerPrivate->m_appendPipelinesMap.remove(sourceBufferPrivate);
    178     // AppendPipeline destructor will take care of cleaning up when appropriate.
    179176
    180177    m_playerPrivate->m_playbackPipeline->removeSourceBuffer(sourceBufferPrivate);
Note: See TracChangeset for help on using the changeset viewer.