Skip to content

bin: Fix bin won't post async done message to parent while nothing pending in state changing.

Chao Guo requested to merge ChaoGuo/gstreamer:bin-async-done into main
  • Problem Description:
      When we run Cheese camera on our imx platform, Cheese preview freeze at first frame.

  • Cheese Version:
      41.1

  • Trouble Shooting:
      Figure 1 shows the camerabin pipeline that is used in Cheese 41.1. In this pipeline, a decodebin is added in camera_source to support some USB cameras with encoded output. We find that the pipeline may freeze in an intermediate state during camerabin changing state from NULL to PLAYING.

    Camerabin pipeline

    Figure 1. Camerabin pipeline

      During state changing form READY to PAUSED, bin18 in camera_source sequentially sets its children's state to PAUSED from downstream. Decodebin will perform asynchronous state changing and v4l2src will perform state changing with no preroll. After v4l2src completes the state changing, bin18 will ignore decodebin and commit the state to PAUSED, which will turn its pending state from PAUSED to VOID_PENDING.

      When v4l2src change its state to PAUSED, it will start a new thread to do negotiation and send caps event downstream, which makes decodebin do autoplugging. After exposing pads, decodebin will commit state to PAUSED and send ASYNC_DONE message to bin18. At this time, the pending state of bin18 may be VOID_PENDING. The timeline is shown in the figure 2.

    timeline
    Figure 2. Timeline

      In this case, bin18 will not send ASYNC_DONE message to parent bin, which makes camerabin think that there are still elements in state changing. When videosink do preroll, it will commit its state to PAUSED and wait for camerabin to set its state to PLAYING. However, camerabin is waiting for bin18 to send it an ASYNC_DONE message, which causes the pipeline to stop in the intermediate state.

  • Trouble Fix:
      This commit modifies the bin_handle_async_done() function. When the bin, whose pending state is VOIDING_PENDING, receives the ASYNC_DONE message, it will also post this message to its parent bin. After modification, Cheese can run normally after modification.

Merge request reports