]> git.sesse.net Git - vlc/blobdiff - src/video_output/display.c
win32: avoid the POSIX timer API for now
[vlc] / src / video_output / display.c
index 72b37041ce18f847526a2edcda31c140631924da..0d20a56e80ff8d325c46500e96205bd248b64c9c 100644 (file)
@@ -6,19 +6,19 @@
  *
  * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -100,7 +100,7 @@ static vout_display_t *vout_display_New(vlc_object_t *obj,
                                         vout_display_owner_t *owner)
 {
     /* */
-    vout_display_t *vd = vlc_object_create(obj, sizeof(*vd));
+    vout_display_t *vd = vlc_custom_create(obj, sizeof(*vd), "vout display" );
 
     /* */
     video_format_Copy(&vd->source, fmt);
@@ -115,6 +115,7 @@ static vout_display_t *vout_display_New(vlc_object_t *obj,
     vd->info.has_hide_mouse = false;
     vd->info.has_pictures_invalid = false;
     vd->info.has_event_thread = false;
+    vd->info.subpicture_chromas = NULL;
 
     vd->cfg = cfg;
     vd->pool = NULL;
@@ -126,8 +127,6 @@ static vout_display_t *vout_display_New(vlc_object_t *obj,
 
     vd->owner = *owner;
 
-    vlc_object_attach(vd, obj);
-
     if (load_module) {
         vd->module = module_need(vd, "vout display", module, module && *module != '\0');
         if (!vd->module) {
@@ -423,11 +422,7 @@ static void VoutDisplayCreateRender(vout_display_t *vd)
             break;
     }
     if (!filter)
-    {
-        msg_Err(vd, "VoutDisplayCreateRender FAILED");
-        /* TODO */
-        assert(0);
-    }
+        msg_Err(vd, "Failed to adapt decoder format to display");
 }
 
 static void VoutDisplayDestroyRender(vout_display_t *vd)
@@ -543,6 +538,7 @@ static void VoutDisplayEventMouse(vout_display_t *vd, int event, va_list args)
     vlc_mutex_unlock(&osys->lock);
 }
 
+VLC_NORETURN
 static void *VoutDisplayEventKeyDispatch(void *data)
 {
     vout_display_owner_sys_t *osys = data;
@@ -782,7 +778,7 @@ void vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
 
     if (hide_mouse) {
         if (!vd->info.has_hide_mouse) {
-            msg_Dbg(vd, "auto hiding mouse");
+            msg_Dbg(vd, "auto hiding mouse cursor");
             vout_display_Control(vd, VOUT_DISPLAY_HIDE_MOUSE);
         }
         vout_SendEventMouseHidden(osys->vout);
@@ -996,28 +992,26 @@ void vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
             }
             const int right_max  = osys->source.i_x_offset + osys->source.i_visible_width;
             const int bottom_max = osys->source.i_y_offset + osys->source.i_visible_height;
-#define __CLIP(v, a, b) __MAX(__MIN(v, b), a)
-            int left   = __CLIP((int)osys->source.i_x_offset + osys->crop.left,
+            int left   = VLC_CLIP((int)osys->source.i_x_offset + osys->crop.left,
                                 0, right_max - 1);
-            int top    = __CLIP((int)osys->source.i_y_offset + osys->crop.top,
+            int top    = VLC_CLIP((int)osys->source.i_y_offset + osys->crop.top,
                                 0, bottom_max - 1);
             int right, bottom;
             if (osys->crop.right <= 0)
                 right = (int)(osys->source.i_x_offset + osys->source.i_visible_width) + osys->crop.right;
             else
                 right = (int)osys->source.i_x_offset + osys->crop.right;
-            right = __CLIP(right, left + 1, right_max);
+            right = VLC_CLIP(right, left + 1, right_max);
             if (osys->crop.bottom <= 0)
                 bottom = (int)(osys->source.i_y_offset + osys->source.i_visible_height) + osys->crop.bottom;
             else
                 bottom = (int)osys->source.i_y_offset + osys->crop.bottom;
-            bottom = __CLIP(bottom, top + 1, bottom_max);
+            bottom = VLC_CLIP(bottom, top + 1, bottom_max);
 
             source.i_x_offset       = left;
             source.i_y_offset       = top;
             source.i_visible_width  = right - left;
             source.i_visible_height = bottom - top;
-#undef __CLIP
             video_format_Print(VLC_OBJECT(vd), "SOURCE ", &osys->source);
             video_format_Print(VLC_OBJECT(vd), "CROPPED", &source);
             if (vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_CROP, &source)) {
@@ -1086,6 +1080,10 @@ picture_t *vout_FilterDisplay(vout_display_t *vd, picture_t *picture)
     vout_display_owner_sys_t *osys = vd->owner.sys;
 
     assert(osys->filters);
+    if (filter_chain_GetLength(osys->filters) <= 0) {
+        picture_Release(picture);
+        return NULL;
+    }
     return filter_chain_VideoFilter(osys->filters, picture);
 }
 
@@ -1206,9 +1204,10 @@ void vout_SetDisplayCrop(vout_display_t *vd,
         osys->ch_crop = true;
     }
 }
-vout_opengl_t *vout_GetDisplayOpengl(vout_display_t *vd)
+
+struct vlc_gl_t *vout_GetDisplayOpengl(vout_display_t *vd)
 {
-    vout_opengl_t *gl;
+    struct vlc_gl_t *gl;
     if (vout_display_Control(vd, VOUT_DISPLAY_GET_OPENGL, &gl))
         return NULL;
     return gl;
@@ -1419,7 +1418,7 @@ static void SplitterEvent(vout_display_t *vd, int event, va_list args)
         break;
 
     default:
-        msg_Err(vd, "SplitterEvent TODO");
+        msg_Err(vd, "splitter event not implemented: %d", event);
         break;
     }
 }
@@ -1431,11 +1430,14 @@ static picture_pool_t *SplitterPool(vout_display_t *vd, unsigned count)
         sys->pool = picture_pool_NewFromFormat(&vd->fmt, count);
     return sys->pool;
 }
-static void SplitterPrepare(vout_display_t *vd, picture_t *picture)
+static void SplitterPrepare(vout_display_t *vd,
+                            picture_t *picture,
+                            subpicture_t *subpicture)
 {
     vout_display_sys_t *sys = vd->sys;
 
     picture_Hold(picture);
+    assert(!subpicture);
 
     if (video_splitter_Filter(sys->splitter, sys->picture, picture)) {
         for (int i = 0; i < sys->count; i++)
@@ -1448,21 +1450,25 @@ static void SplitterPrepare(vout_display_t *vd, picture_t *picture)
         if (vout_IsDisplayFiltered(sys->display[i]))
             sys->picture[i] = vout_FilterDisplay(sys->display[i], sys->picture[i]);
         if (sys->picture[i])
-            vout_display_Prepare(sys->display[i], sys->picture[i]);
+            vout_display_Prepare(sys->display[i], sys->picture[i], NULL);
     }
 }
-static void SplitterDisplay(vout_display_t *vd, picture_t *picture)
+static void SplitterDisplay(vout_display_t *vd,
+                            picture_t *picture,
+                            subpicture_t *subpicture)
 {
     vout_display_sys_t *sys = vd->sys;
 
+    assert(!subpicture);
     for (int i = 0; i < sys->count; i++) {
         if (sys->picture[i])
-            vout_display_Display(sys->display[i], sys->picture[i]);
+            vout_display_Display(sys->display[i], sys->picture[i], NULL);
     }
     picture_Release(picture);
 }
 static int SplitterControl(vout_display_t *vd, int query, va_list args)
 {
+    (void)vd; (void)query; (void)args;
     return VLC_EGENERIC;
 }
 static void SplitterManage(vout_display_t *vd)
@@ -1627,16 +1633,7 @@ void vout_SendDisplayEventMouse(vout_thread_t *vout, const vlc_mouse_t *m)
         vout_SendEventMouseMoved(vout, m->i_x, m->i_y);
     }
     if (vlc_mouse_HasButton(&vout->p->mouse, m)) {
-        static const int buttons[] = {
-            MOUSE_BUTTON_LEFT,
-            MOUSE_BUTTON_CENTER,
-            MOUSE_BUTTON_RIGHT,
-            MOUSE_BUTTON_WHEEL_UP,
-            MOUSE_BUTTON_WHEEL_DOWN,
-            -1
-        };
-        for (int i = 0; buttons[i] >= 0; i++) {
-            const int button = buttons[i];
+        for (unsigned button = 0; button < MOUSE_BUTTON_MAX; button++) {
             if (vlc_mouse_HasPressed(&vout->p->mouse, m, button))
                 vout_SendEventMousePressed(vout, button);
             else if (vlc_mouse_HasReleased(&vout->p->mouse, m, button))