]> git.sesse.net Git - vlc/blobdiff - src/video_output/display.c
vout: remove flag is_sleeping from vout_control_t
[vlc] / src / video_output / display.c
index 67092cd089014d4985997ddfad663ab0bf67eb65..906bca084aaa6cb36eec37dd8c1dfaded5a1254f 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);
@@ -127,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) {
@@ -303,8 +301,8 @@ struct vout_display_owner_sys_t {
 
     bool ch_zoom;
     struct {
-        int  num;
-        int  den;
+        unsigned num;
+        unsigned den;
     } zoom;
 
     bool ch_wm_state;
@@ -540,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;
@@ -756,7 +755,7 @@ static void VoutDisplayCropRatio(int *left, int *top, int *right, int *bottom,
     }
 }
 
-void vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
+bool vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
 {
     vout_display_owner_sys_t *osys = vd->owner.sys;
 
@@ -779,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);
@@ -993,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)) {
@@ -1058,6 +1055,8 @@ void vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
     }
     if (reset_render)
         VoutDisplayResetRender(vd);
+
+    return reset_render;
 }
 
 bool vout_AreDisplayPicturesInvalid(vout_display_t *vd)
@@ -1142,10 +1141,17 @@ void vout_SetDisplayFilled(vout_display_t *vd, bool is_filled)
     }
 }
 
-void vout_SetDisplayZoom(vout_display_t *vd, int num, int den)
+void vout_SetDisplayZoom(vout_display_t *vd, unsigned num, unsigned den)
 {
     vout_display_owner_sys_t *osys = vd->owner.sys;
 
+    if (num > 0 && den > 0) {
+        vlc_ureduce(&num, &den, num, den, 0);
+    } else {
+        num = 1;
+        den = 1;
+    }
+
     if (osys->is_display_filled ||
         osys->zoom.num != num || osys->zoom.den != den) {
         osys->ch_zoom = true;
@@ -1217,7 +1223,7 @@ struct vlc_gl_t *vout_GetDisplayOpengl(vout_display_t *vd)
 }
 
 static vout_display_t *DisplayNew(vout_thread_t *vout,
-                                  const video_format_t *source_org,
+                                  const video_format_t *source,
                                   const vout_display_state_t *state,
                                   const char *module,
                                   bool is_wrapper, vout_display_t *wrapper,
@@ -1234,7 +1240,7 @@ static vout_display_t *DisplayNew(vout_thread_t *vout,
     osys->sar_initial.num = state->sar.num;
     osys->sar_initial.den = state->sar.den;
     vout_display_GetDefaultDisplaySize(&cfg->display.width, &cfg->display.height,
-                                       source_org, cfg);
+                                       source, cfg);
 
     osys->vout = vout;
     osys->is_wrapper = is_wrapper;
@@ -1259,7 +1265,7 @@ static vout_display_t *DisplayNew(vout_thread_t *vout,
         cfg_windowed.display.height = 0;
         vout_display_GetDefaultDisplaySize(&osys->width_saved,
                                            &osys->height_saved,
-                                           source_org, &cfg_windowed);
+                                           source, &cfg_windowed);
     }
     osys->zoom.num = cfg->zoom.num;
     osys->zoom.den = cfg->zoom.den;
@@ -1267,7 +1273,7 @@ static vout_display_t *DisplayNew(vout_thread_t *vout,
     osys->fit_window = 0;
     osys->event.fifo = NULL;
 
-    osys->source = *source_org;
+    osys->source = *source;
     osys->crop.left   = 0;
     osys->crop.top    = 0;
     osys->crop.right  = 0;
@@ -1277,8 +1283,8 @@ static vout_display_t *DisplayNew(vout_thread_t *vout,
     osys->crop.num = 0;
     osys->crop.den = 0;
 
-    osys->sar.num = osys->sar_initial.num ? osys->sar_initial.num : source_org->i_sar_num;
-    osys->sar.den = osys->sar_initial.den ? osys->sar_initial.den : source_org->i_sar_den;
+    osys->sar.num = osys->sar_initial.num ? osys->sar_initial.num : source->i_sar_num;
+    osys->sar.den = osys->sar_initial.den ? osys->sar_initial.den : source->i_sar_den;
 #ifdef ALLOW_DUMMY_VOUT
     vlc_mouse_Init(&osys->vout_mouse);
 #endif
@@ -1293,17 +1299,9 @@ static vout_display_t *DisplayNew(vout_thread_t *vout,
     }
     owner.sys = osys;
 
-    /* */
-    video_format_t source = *source_org;
-
-    source.i_x_offset = 0;
-    source.i_y_offset = 0;
-    source.i_visible_width  = source.i_width;
-    source.i_visible_height = source.i_height;
-
     vout_display_t *p_display = vout_display_New(VLC_OBJECT(vout),
                                                  module, !is_wrapper,
-                                                 &source, cfg, &owner);
+                                                 source, cfg, &owner);
     if (!p_display) {
         free(osys);
         return NULL;
@@ -1312,16 +1310,11 @@ static vout_display_t *DisplayNew(vout_thread_t *vout,
     VoutDisplayCreateRender(p_display);
 
     /* Setup delayed request */
-    if (osys->sar.num != source.i_sar_num ||
-        osys->sar.den != source.i_sar_den)
+    if (osys->sar.num != source->i_sar_num ||
+        osys->sar.den != source->i_sar_den)
         osys->ch_sar = true;
     if (osys->wm_state != osys->wm_state_initial)
         osys->ch_wm_state = true;
-    if (source.i_x_offset       != source_org->i_x_offset ||
-        source.i_y_offset       != source_org->i_y_offset ||
-        source.i_visible_width  != source_org->i_visible_width ||
-        source.i_visible_height != source_org->i_visible_height)
-        osys->ch_crop = true;
 
     return p_display;
 }
@@ -1421,7 +1414,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;
     }
 }
@@ -1471,6 +1464,7 @@ static void SplitterDisplay(vout_display_t *vd,
 }
 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)