video: remove tdm commit/vblank handlers at deletion of instance. 71/231271/2
authorSeunghun Lee <shiin.lee@samsung.com>
Tue, 21 Apr 2020 01:13:44 +0000 (10:13 +0900)
committerSeunghun Lee <shiin.lee@samsung.com>
Tue, 21 Apr 2020 01:38:16 +0000 (10:38 +0900)
this patch will fix a crash caused on handling vblank after deletion of
instance.

Change-Id: I762f2cd0d0edaa75e93a652ecb02a5222cd92c89

src/bin/video/iface/e_video_hwc_planes.c

index 6208bf4837870be6c0b99a23b7306fb87381cfaa..8bc935c0f97d443ffa036f445eaa82bdf69d2d64 100644 (file)
@@ -51,12 +51,13 @@ static Eina_Bool  _e_video_hwc_planes_buffer_commit(E_Video_Hwc_Planes *evhp, E_
 static void
 _e_video_hwc_planes_pending_buffer_commit(E_Video_Hwc_Planes *evhp)
 {
+   E_Comp_Wl_Video_Buf *vbuf;
+
    if (evhp->pending.vbuf)
      {
-        _e_video_hwc_planes_buffer_commit(evhp,
-                                          evhp->pending.vbuf,
-                                          &evhp->pending.info);
+        vbuf = evhp->pending.vbuf;
         evhp->pending.vbuf = NULL;
+        _e_video_hwc_planes_buffer_commit(evhp, vbuf, &evhp->pending.info);
      }
    else
      e_video_hwc_wait_buffer_commit((E_Video_Hwc *)evhp);
@@ -473,32 +474,6 @@ err_plane:
    return EINA_FALSE;
 }
 
-static void
-_e_video_hwc_planes_tdm_layer_unset(E_Video_Hwc_Planes *evhp)
-{
-   unsigned int usable = 1;
-
-   if (!evhp->tdm.layer) return;
-
-   _tdm_layer_usable_get(evhp->tdm.layer, &usable);
-   if (!usable && !evhp->video_plane_ready_handler)
-     {
-        VIN("stop video", evhp->base.ec);
-        _tdm_layer_buffer_unset(evhp->tdm.layer);
-        _tdm_layer_commit(evhp->tdm.layer, NULL, NULL);
-     }
-
-   VIN("release layer: %p", evhp->base.ec, evhp->tdm.layer);
-   _e_video_hwc_planes_tdm_layer_usable_set(evhp->tdm.layer, EINA_TRUE);
-   evhp->tdm.layer = NULL;
-   evhp->base.old_comp_buffer = NULL;
-
-   e_plane_video_set(evhp->e_plane, EINA_FALSE, NULL);
-   evhp->e_plane = NULL;
-
-   E_FREE_FUNC(evhp->video_plane_ready_handler, e_plane_hook_del);
-}
-
 static void
 _e_video_hwc_planes_cb_commit_handler(tdm_layer *layer, unsigned int sequence,
                                       unsigned int tv_sec, unsigned int tv_usec,
@@ -557,6 +532,37 @@ _e_video_hwc_planes_buffer_commit(E_Video_Hwc_Planes *evhp, E_Comp_Wl_Video_Buf
    E_Client_Video_Info old_info;
    tdm_error ret;
 
+   if (!evhp->tdm.layer)
+     {
+        VIN("set layer: show", evhp->base.ec);
+        if (!_e_video_hwc_planes_tdm_layer_set(evhp))
+          {
+             VER("set layer failed", evhp->base.ec);
+             return EINA_FALSE;
+          }
+     }
+
+   if (evhp->video_plane_ready_handler)
+     {
+        VIN("wait for video plane ready: Pending commit vbuf(%p)",
+            evhp->base.ec, vbuf);
+
+        if (evhp->pending.vbuf)
+          {
+             /* Cannot reach here because following buffers are supposed
+              * to be queued by 'e_video_hwc' until calling fb_update by
+              * this child module. */
+             NEVER_GET_HERE();
+
+             return EINA_FALSE;
+          }
+
+        evhp->pending.vbuf = vbuf;
+        memcpy(&evhp->pending.info, info, sizeof(E_Client_Video_Info));
+
+        return EINA_TRUE;
+     }
+
    if (evhp->tdm.prop_list)
      {
         // need call tdm property in list
@@ -601,6 +607,38 @@ _e_video_hwc_planes_buffer_commit(E_Video_Hwc_Planes *evhp, E_Comp_Wl_Video_Buf
    return EINA_TRUE;
 }
 
+static void
+_e_video_hwc_planes_tdm_layer_unset(E_Video_Hwc_Planes *evhp)
+{
+   unsigned int usable = 1;
+
+   if (!evhp->tdm.layer) return;
+
+   if (evhp->wait_flag.commit)
+     {
+        tdm_layer_remove_commit_handler(evhp->tdm.layer, _e_video_hwc_planes_cb_commit_handler, evhp);
+        evhp->wait_flag.commit = EINA_FALSE;
+     }
+
+   _tdm_layer_usable_get(evhp->tdm.layer, &usable);
+   if (!usable && !evhp->video_plane_ready_handler)
+     {
+        VIN("stop video", evhp->base.ec);
+        _tdm_layer_buffer_unset(evhp->tdm.layer);
+        _tdm_layer_commit(evhp->tdm.layer, NULL, NULL);
+     }
+
+   VIN("release layer: %p", evhp->base.ec, evhp->tdm.layer);
+   _e_video_hwc_planes_tdm_layer_usable_set(evhp->tdm.layer, EINA_TRUE);
+   evhp->tdm.layer = NULL;
+   evhp->base.old_comp_buffer = NULL;
+
+   e_plane_video_set(evhp->e_plane, EINA_FALSE, NULL);
+   evhp->e_plane = NULL;
+
+   E_FREE_FUNC(evhp->video_plane_ready_handler, e_plane_hook_del);
+}
+
 static void
 _e_video_hwc_planes_cb_evas_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
 {
@@ -682,6 +720,12 @@ _e_video_hwc_planes_destroy(E_Video_Hwc_Planes *evhp)
    if (evhp->tdm.late_prop_list)
      NEVER_GET_HERE();
 
+   if (evhp->wait_flag.vblank)
+     {
+        tdm_output_remove_vblank_handler(evhp->tdm.output, _e_video_hwc_planes_cb_vblank_handler, evhp);
+        evhp->wait_flag.vblank = EINA_FALSE;
+     }
+
    if (evhp->tdm.layer)
      {
         VIN("unset layer: destroy", evhp->base.ec);
@@ -915,37 +959,6 @@ _e_video_hwc_planes_iface_buffer_commit(E_Video_Hwc *evh, E_Comp_Wl_Video_Buf *v
         info.dst_pos.h = evhp->base.geo.tdm.output_r.h;
         info.transform = vbuf->content_t;
 
-        if (!evhp->tdm.layer)
-          {
-             VIN("set layer: show", evhp->base.ec);
-             if (!_e_video_hwc_planes_tdm_layer_set(evhp))
-               {
-                  VER("set layer failed", evhp->base.ec);
-                  return EINA_FALSE;
-               }
-          }
-
-        if (evhp->video_plane_ready_handler)
-          {
-             VIN("wait for video plane ready: Pending commit vbuf(%p)",
-                 evhp->base.ec, vbuf);
-
-             if (evhp->pending.vbuf)
-               {
-                  /* Cannot reach here because following buffers are supposed
-                   * to be queued by 'e_video_hwc' until calling fb_update by
-                   * this child module. */
-                  NEVER_GET_HERE();
-
-                  return EINA_FALSE;
-               }
-
-             evhp->pending.vbuf = vbuf;
-             memcpy(&evhp->pending.info, &info, sizeof(E_Client_Video_Info));
-
-             return EINA_TRUE;
-          }
-
         ret = _e_video_hwc_planes_buffer_commit(evhp, vbuf, &info);
      }