[vlc-commits] vout thread: split out command processing function

Rafaël Carré git at videolan.org
Mon Aug 19 15:35:53 CEST 2013


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Mon Aug 19 08:18:25 2013 +0200| [ec788f2dc90eaf43af4fed6e9cc1ea982d5be0db] | committer: Rafaël Carré

vout thread: split out command processing function

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ec788f2dc90eaf43af4fed6e9cc1ea982d5be0db
---

 src/video_output/video_output.c |  175 +++++++++++++++++++--------------------
 1 file changed, 87 insertions(+), 88 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 3876ccd..4869005 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1462,6 +1462,90 @@ static int ThreadReinit(vout_thread_t *vout,
     return VLC_SUCCESS;
 }
 
+static int ThreadControl(vout_thread_t *vout, vout_control_cmd_t cmd)
+{
+    switch(cmd.type) {
+    case VOUT_CONTROL_INIT:
+        ThreadInit(vout);
+        if (!ThreadStart(vout, NULL))
+            break;
+    case VOUT_CONTROL_CLEAN:
+        ThreadStop(vout, NULL);
+        ThreadClean(vout);
+        return -1;
+    case VOUT_CONTROL_REINIT:
+        if (ThreadReinit(vout, cmd.u.cfg))
+            return -1;
+        break;
+    case VOUT_CONTROL_SUBPICTURE:
+        ThreadDisplaySubpicture(vout, cmd.u.subpicture);
+        cmd.u.subpicture = NULL;
+        break;
+    case VOUT_CONTROL_FLUSH_SUBPICTURE:
+        ThreadFlushSubpicture(vout, cmd.u.integer);
+        break;
+    case VOUT_CONTROL_OSD_TITLE:
+        ThreadDisplayOsdTitle(vout, cmd.u.string);
+        break;
+    case VOUT_CONTROL_CHANGE_FILTERS:
+        ThreadChangeFilters(vout, NULL, cmd.u.string, false);
+        break;
+    case VOUT_CONTROL_CHANGE_SUB_SOURCES:
+        ThreadChangeSubSources(vout, cmd.u.string);
+        break;
+    case VOUT_CONTROL_CHANGE_SUB_FILTERS:
+        ThreadChangeSubFilters(vout, cmd.u.string);
+        break;
+    case VOUT_CONTROL_CHANGE_SUB_MARGIN:
+        ThreadChangeSubMargin(vout, cmd.u.integer);
+        break;
+    case VOUT_CONTROL_PAUSE:
+        ThreadChangePause(vout, cmd.u.pause.is_on, cmd.u.pause.date);
+        break;
+    case VOUT_CONTROL_FLUSH:
+        ThreadFlush(vout, false, cmd.u.time);
+        break;
+    case VOUT_CONTROL_RESET:
+        ThreadReset(vout);
+        break;
+    case VOUT_CONTROL_STEP:
+        ThreadStep(vout, cmd.u.time_ptr);
+        break;
+    case VOUT_CONTROL_FULLSCREEN:
+        ThreadChangeFullscreen(vout, cmd.u.boolean);
+        break;
+    case VOUT_CONTROL_ON_TOP:
+        ThreadChangeOnTop(vout, cmd.u.boolean);
+        break;
+    case VOUT_CONTROL_DISPLAY_FILLED:
+        ThreadChangeDisplayFilled(vout, cmd.u.boolean);
+        break;
+    case VOUT_CONTROL_ZOOM:
+        ThreadChangeZoom(vout, cmd.u.pair.a, cmd.u.pair.b);
+        break;
+    case VOUT_CONTROL_ASPECT_RATIO:
+        ThreadChangeAspectRatio(vout, cmd.u.pair.a, cmd.u.pair.b);
+        break;
+    case VOUT_CONTROL_CROP_RATIO:
+        ThreadExecuteCropRatio(vout, cmd.u.pair.a, cmd.u.pair.b);
+        break;
+    case VOUT_CONTROL_CROP_WINDOW:
+        ThreadExecuteCropWindow(vout,
+                cmd.u.window.x, cmd.u.window.y,
+                cmd.u.window.width, cmd.u.window.height);
+        break;
+    case VOUT_CONTROL_CROP_BORDER:
+        ThreadExecuteCropBorder(vout,
+                cmd.u.border.left,  cmd.u.border.top,
+                cmd.u.border.right, cmd.u.border.bottom);
+        break;
+    default:
+        break;
+    }
+    vout_control_cmd_Clean(&cmd);
+    return 0;
+}
+
 /*****************************************************************************
  * Thread: video output thread
  *****************************************************************************
@@ -1481,96 +1565,11 @@ static void *Thread(void *object)
     mtime_t deadline = VLC_TS_INVALID;
     for (;;) {
         vout_control_cmd_t cmd;
-
-        /* FIXME remove thoses ugly timeouts
-         */
-        while (!vout_control_Pop(&vout->p->control, &cmd, deadline, 100000)) {
-            switch(cmd.type) {
-            case VOUT_CONTROL_INIT:
-                ThreadInit(vout);
-                if (ThreadStart(vout, NULL)) {
-                    ThreadStop(vout, NULL);
-                    ThreadClean(vout);
-                    return NULL;
-                }
-                break;
-            case VOUT_CONTROL_CLEAN:
-                ThreadStop(vout, NULL);
-                ThreadClean(vout);
+        /* FIXME remove thoses ugly timeouts */
+        while (!vout_control_Pop(&vout->p->control, &cmd, deadline, 100000))
+            if (ThreadControl(vout, cmd))
                 return NULL;
-            case VOUT_CONTROL_REINIT:
-                if (ThreadReinit(vout, cmd.u.cfg))
-                    return NULL;
-                break;
-            case VOUT_CONTROL_SUBPICTURE:
-                ThreadDisplaySubpicture(vout, cmd.u.subpicture);
-                cmd.u.subpicture = NULL;
-                break;
-            case VOUT_CONTROL_FLUSH_SUBPICTURE:
-                ThreadFlushSubpicture(vout, cmd.u.integer);
-                break;
-            case VOUT_CONTROL_OSD_TITLE:
-                ThreadDisplayOsdTitle(vout, cmd.u.string);
-                break;
-            case VOUT_CONTROL_CHANGE_FILTERS:
-                ThreadChangeFilters(vout, NULL, cmd.u.string, false);
-                break;
-            case VOUT_CONTROL_CHANGE_SUB_SOURCES:
-                ThreadChangeSubSources(vout, cmd.u.string);
-                break;
-            case VOUT_CONTROL_CHANGE_SUB_FILTERS:
-                ThreadChangeSubFilters(vout, cmd.u.string);
-                break;
-            case VOUT_CONTROL_CHANGE_SUB_MARGIN:
-                ThreadChangeSubMargin(vout, cmd.u.integer);
-                break;
-            case VOUT_CONTROL_PAUSE:
-                ThreadChangePause(vout, cmd.u.pause.is_on, cmd.u.pause.date);
-                break;
-            case VOUT_CONTROL_FLUSH:
-                ThreadFlush(vout, false, cmd.u.time);
-                break;
-            case VOUT_CONTROL_RESET:
-                ThreadReset(vout);
-                break;
-            case VOUT_CONTROL_STEP:
-                ThreadStep(vout, cmd.u.time_ptr);
-                break;
-            case VOUT_CONTROL_FULLSCREEN:
-                ThreadChangeFullscreen(vout, cmd.u.boolean);
-                break;
-            case VOUT_CONTROL_ON_TOP:
-                ThreadChangeOnTop(vout, cmd.u.boolean);
-                break;
-            case VOUT_CONTROL_DISPLAY_FILLED:
-                ThreadChangeDisplayFilled(vout, cmd.u.boolean);
-                break;
-            case VOUT_CONTROL_ZOOM:
-                ThreadChangeZoom(vout, cmd.u.pair.a, cmd.u.pair.b);
-                break;
-            case VOUT_CONTROL_ASPECT_RATIO:
-                ThreadChangeAspectRatio(vout, cmd.u.pair.a, cmd.u.pair.b);
-                break;
-           case VOUT_CONTROL_CROP_RATIO:
-                ThreadExecuteCropRatio(vout, cmd.u.pair.a, cmd.u.pair.b);
-                break;
-            case VOUT_CONTROL_CROP_WINDOW:
-                ThreadExecuteCropWindow(vout,
-                                        cmd.u.window.x, cmd.u.window.y,
-                                        cmd.u.window.width, cmd.u.window.height);
-                break;
-            case VOUT_CONTROL_CROP_BORDER:
-                ThreadExecuteCropBorder(vout,
-                                        cmd.u.border.left,  cmd.u.border.top,
-                                        cmd.u.border.right, cmd.u.border.bottom);
-                break;
-            default:
-                break;
-            }
-            vout_control_cmd_Clean(&cmd);
-        }
 
         ThreadManage(vout, &deadline, &interlacing);
     }
 }
-



More information about the vlc-commits mailing list