libvideorender: CB2 not send frame when output removed [1/1]

PD#SWPL-139686

Problem:
on weston plugin, if wl output removed,weston can't display
any video frame,so it can't report displayed frame to client,
it cause blocking post buffer thread.afer wl output plugin again
playback can't resume

Solution:
we don't send video frame to weston when wl output removed.so post
frame thread should drop video frame,when wl output plugin again,we
send newest video frame to weston.

Verify:
ap222

Change-Id: Ia66802f6b6f466a5b5243c2fdb5e3b13831d0303
Signed-off-by: fei.deng <fei.deng@amlogic.com>
diff --git a/weston/wayland_display.cpp b/weston/wayland_display.cpp
index bd2f32b..390dee4 100644
--- a/weston/wayland_display.cpp
+++ b/weston/wayland_display.cpp
@@ -475,6 +475,10 @@
                 if (i == 0) { //primary wl_output
                     self->mOutput[i].isPrimary = true;
                 }
+                //if wl_output plugin,active sending frame
+                if (self->mOutput[self->mActiveOutput].wlOutput) {
+                    self->setRedrawingPending(false);
+                }
                 return;
             }
         }
@@ -803,14 +807,13 @@
         ERROR(mLogCategory, "display output index error,please set 0:primary or 1:extend,now:%d",output);
         return;
     }
-    if (!mOutput[output].wlOutput) {
-        ERROR(mLogCategory, "Error output index,wl_output is null,now:%d",output);
-        return;
-    }
+
     if (mActiveOutput != output) {
-        setRenderRectangle(mOutput[output].offsetX, mOutput[output].offsetY,
-                        mOutput[output].width, mOutput[output].height);
         mActiveOutput = output;
+        if (mOutput[output].wlOutput) {
+            setRenderRectangle(mOutput[output].offsetX, mOutput[output].offsetY,
+                            mOutput[output].width, mOutput[output].height);
+        }
     }
 }
 
@@ -1182,6 +1185,13 @@
     if (waylandBuf) {
         wlbuffer = waylandBuf->getWlBuffer();
     }
+    //if no wl_output, drop this buffer
+    if (mOutput[mActiveOutput].wlOutput == NULL) {
+        TRACE(mLogCategory,"No wl_output");
+        mWaylandPlugin->handleFrameDropped(buf);
+        mWaylandPlugin->handleBufferRelease(buf);
+        return;
+    }
     if (wlbuffer) {
         Tls::Mutex::Autolock _l(mRenderMutex);
         ++mCommitCnt;
diff --git a/weston/wayland_display.h b/weston/wayland_display.h
index a179594..4328563 100644
--- a/weston/wayland_display.h
+++ b/weston/wayland_display.h
@@ -91,6 +91,10 @@
     {
         return mShm;
     };
+    struct wl_output *getWlOutput()
+    {
+        return mOutput[mActiveOutput].wlOutput;
+    };
     /**
      * @brief Set the Select Display Output index
      *
diff --git a/weston/wayland_plugin.cpp b/weston/wayland_plugin.cpp
index 0c31b94..50eb3ac 100644
--- a/weston/wayland_plugin.cpp
+++ b/weston/wayland_plugin.cpp
@@ -269,6 +269,13 @@
         goto tag_next;
     }
 
+    //if weston has no wl_outout,it means weston can't display frames
+    //so we should display buffer to display to drop buffers
+    if (mDisplay->getWlOutput() == NULL) {
+        mQueue->pop((void **)&expiredFrameEntity);
+        goto tag_post;
+    }
+
     //if weston obtains a buffer rendering,we can't send buffer to weston
     if (mDisplay->isRedrawingPending()) {
         goto tag_next;