]> git.sesse.net Git - vlc/commitdiff
improves OSD sytem
authorYoann Peronneau <yoann@videolan.org>
Mon, 8 Dec 2003 17:48:13 +0000 (17:48 +0000)
committerYoann Peronneau <yoann@videolan.org>
Mon, 8 Dec 2003 17:48:13 +0000 (17:48 +0000)
The last OSD message is now deleted before printing new one.

include/osd.h
include/video_output.h
modules/misc/dummy/renderer.c
modules/misc/freetype.c
src/video_output/video_text.c
src/video_output/vout_subpictures.c

index b98916472a9d77a436332b990fe20e99bc1c4a45..7d0bc60063beeefeb6389a75fef6558d7c12ad82 100644 (file)
@@ -2,7 +2,7 @@
  * osd.h : Constants for use with osd modules
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: osd.h,v 1.5 2003/10/30 22:34:48 hartman Exp $
+ * $Id: osd.h,v 1.6 2003/12/08 17:48:13 yoann Exp $
  *
  * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
  *
@@ -45,6 +45,6 @@ struct text_style_t
 };
 static const text_style_t default_text_style = { 22, 0xffffff, VLC_FALSE, VLC_FALSE, VLC_FALSE };
 
-VLC_EXPORT( void, vout_ShowTextRelative, ( vout_thread_t *, char *, text_style_t *, int, int, int, mtime_t ) );
+VLC_EXPORT( subpicture_t *, vout_ShowTextRelative, ( vout_thread_t *, char *, text_style_t *, int, int, int, mtime_t ) );
 VLC_EXPORT( void,  vout_ShowTextAbsolute, ( vout_thread_t *, char *, text_style_t *, int, int, int, mtime_t, mtime_t ) );
 VLC_EXPORT( void,  vout_OSDMessage, ( vlc_object_t *, char * ) );
index dfd228db3d32e5743a560e8063abfd0a8b976bdc..387d86a66a62f199b5f9d51ee99c4c0b3049cf71 100644 (file)
@@ -2,7 +2,7 @@
  * video_output.h : video output thread
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: video_output.h,v 1.104 2003/12/07 19:09:37 jpsaman Exp $
+ * $Id: video_output.h,v 1.105 2003/12/08 17:48:13 yoann Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Samuel Hocevar <sam@via.ecp.fr>
@@ -122,6 +122,8 @@ struct vout_thread_t
     picture_t           p_picture[2*VOUT_MAX_PICTURES];        /**< pictures */
     subpicture_t        p_subpicture[VOUT_MAX_PICTURES];    /**< subpictures */
 
+    subpicture_t *      last_osd_message;
+
     /* Statistics */
     count_t          c_loops;
     count_t          c_pictures, c_late_pictures;
@@ -141,7 +143,7 @@ struct vout_thread_t
                                                            the text renderer */
     module_t *            p_text_renderer_module;  /**< text renderer module */
     /** callback used when a new string needs to be shown on the vout */
-    int ( *pf_add_string ) ( vout_thread_t *, char *, text_style_t *, int,
+    subpicture_t * ( *pf_add_string ) ( vout_thread_t *, char *, text_style_t *, int,
                              int, int, mtime_t, mtime_t );
 };
 
index 747616073f39d521685e0e88dc1c79d7e67b8837..e0178bed3d2ccb7c1d25946616f2d67cc09df31f 100644 (file)
@@ -2,7 +2,7 @@
  * renderer.c : dummy text rendering functions
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: renderer.c,v 1.3 2003/12/07 19:09:37 jpsaman Exp $
+ * $Id: renderer.c,v 1.4 2003/12/08 17:48:13 yoann Exp $
  *
  * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
  *
@@ -24,7 +24,7 @@
 #include <vlc/vlc.h>
 #include <vlc/vout.h>
 
-static int  AddText   ( vout_thread_t *, char *, text_style_t *, int,
+static subpicture_t * AddText ( vout_thread_t *, char *, text_style_t *, int,
                         int, int, mtime_t, mtime_t );
 
 int E_(OpenRenderer)( vlc_object_t *p_this )
@@ -34,7 +34,7 @@ int E_(OpenRenderer)( vlc_object_t *p_this )
     return VLC_SUCCESS;
 }
 
-static int  AddText   ( vout_thread_t *p_vout, char *psz_string,
+static subpicture_t * AddText ( vout_thread_t *p_vout, char *psz_string,
                         text_style_t *p_style , int i_flags, int i_x_margin,
                         int i_y_margin, mtime_t i_start, mtime_t i_stop )
 {
index c42731e0da9541b3e2953f34726a5977912ce962..63166b7b10929a6cd85ff06d5b37842be0c489ae 100644 (file)
@@ -2,7 +2,7 @@
  * freetype.c : Put text on the video, using freetype2
  *****************************************************************************
  * Copyright (C) 2002, 2003 VideoLAN
- * $Id: freetype.c,v 1.37 2003/12/07 19:00:33 jpsaman Exp $
+ * $Id: freetype.c,v 1.38 2003/12/08 17:48:13 yoann Exp $
  *
  * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
  *
@@ -77,8 +77,8 @@ static void RenderYUY2( vout_thread_t *, picture_t *,
                         const subpicture_t * );
 static void RenderRV32( vout_thread_t *, picture_t *,
                         const subpicture_t * );
-static int  AddText   ( vout_thread_t *, char *, text_style_t *, int,
-                        int, int, mtime_t, mtime_t );
+static subpicture_t *AddText ( vout_thread_t *, char *, text_style_t *, int,
+                               int, int, mtime_t, mtime_t );
 
 static void FreeString( subpicture_t * );
 
@@ -634,7 +634,7 @@ static void RenderRV32( vout_thread_t *p_vout, picture_t *p_pic,
  * needed glyphs into memory. It is used as pf_add_string callback in
  * the vout method by this module
  */
-static int AddText ( vout_thread_t *p_vout, char *psz_string,
+static subpicture_t *AddText ( vout_thread_t *p_vout, char *psz_string,
                      text_style_t *p_style, int i_flags, int i_hmargin,
                      int i_vmargin, mtime_t i_start, mtime_t i_stop )
 {
@@ -654,7 +654,7 @@ static int AddText ( vout_thread_t *p_vout, char *psz_string,
     /* Sanity check */
     if ( !psz_string || !*psz_string )
     {
-        return VLC_EGENERIC;
+        return NULL;
     }
 
     result.x = 0;
@@ -672,7 +672,7 @@ static int AddText ( vout_thread_t *p_vout, char *psz_string,
     p_subpic = vout_CreateSubPicture( p_vout, MEMORY_SUBPICTURE );
     if ( p_subpic == NULL )
     {
-        return VLC_EGENERIC;
+        return NULL;
     }
     p_subpic->p_sys = 0;
     p_subpic->pf_render = Render;
@@ -851,7 +851,7 @@ static int AddText ( vout_thread_t *p_vout, char *psz_string,
     p_string->i_height = result.y;
     p_string->i_width = result.x;
     vout_DisplaySubPicture( p_vout, p_subpic );
-    return VLC_SUCCESS;
+    return p_subpic;
 
 #undef face
 #undef glyph
@@ -859,7 +859,7 @@ static int AddText ( vout_thread_t *p_vout, char *psz_string,
  error:
     FreeString( p_subpic );
     vout_DestroySubPicture( p_vout, p_subpic );
-    return VLC_EGENERIC;
+    return NULL;
 }
 
 static void FreeString( subpicture_t *p_subpic )
index 371627f7263f7b574815ece94f617399a3ee6ec5..3bac695120eed6ada37bb924adc9e2e54a1df6a3 100644 (file)
@@ -2,7 +2,7 @@
  * video_text.c : text manipulation functions
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: video_text.c,v 1.46 2003/10/30 22:34:48 hartman Exp $
+ * $Id: video_text.c,v 1.47 2003/12/08 17:48:13 yoann Exp $
  *
  * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
  *
  * \param i_vmargin vertical margin in pixels
  * \param i_duration Amount of time the text is to be shown.
  */
-void vout_ShowTextRelative( vout_thread_t *p_vout, char *psz_string, 
+subpicture_t *vout_ShowTextRelative( vout_thread_t *p_vout, char *psz_string, 
                              text_style_t *p_style, int i_flags, 
                              int i_hmargin, int i_vmargin, 
                              mtime_t i_duration )
 {
+    subpicture_t *p_subpic = NULL;
     mtime_t i_now = mdate();
+
     if ( p_vout->pf_add_string )
     {
-       p_vout->pf_add_string( p_vout, psz_string, p_style, i_flags, i_hmargin,
-                              i_vmargin, i_now, i_now + i_duration );
+           p_subpic = p_vout->pf_add_string( p_vout, psz_string, p_style, i_flags, 
+                             i_hmargin, i_vmargin, i_now, i_now + i_duration );
     }
     else
     {
-       msg_Warn( p_vout, "No text renderer found" );
+           msg_Warn( p_vout, "No text renderer found" );
     }
+    
+    return p_subpic;
 }
 
 /**
@@ -70,12 +74,12 @@ void vout_ShowTextAbsolute( vout_thread_t *p_vout, char *psz_string,
 {
     if ( p_vout->pf_add_string )
     {
-       p_vout->pf_add_string( p_vout, psz_string, p_style, i_flags, i_hmargin,
+           p_vout->pf_add_string( p_vout, psz_string, p_style, i_flags, i_hmargin,
                               i_vmargin, i_start, i_stop );
     }
     else
     {
-       msg_Warn( p_vout, "No text renderer found" );
+           msg_Warn( p_vout, "No text renderer found" );
     }
 }
 
@@ -96,9 +100,13 @@ void vout_OSDMessage( vlc_object_t *p_caller, char *psz_string )
 
     if( p_vout )
     {
-        vout_ShowTextRelative( p_vout, psz_string, NULL,
-                               OSD_ALIGN_TOP|OSD_ALIGN_RIGHT,
-                               30,20,1000000 );
+        if( p_vout->last_osd_message )
+        {
+            vout_DestroySubPicture( p_vout, p_vout->last_osd_message );
+            p_vout->last_osd_message = NULL;
+        }
+        p_vout->last_osd_message = vout_ShowTextRelative( p_vout, psz_string, 
+                        NULL, OSD_ALIGN_TOP|OSD_ALIGN_RIGHT, 30,20,1000000 );
         vlc_object_release( p_vout );
     }
 }
index b0ea423823cde06d0e3abb2d5dfc930a5e327cb5..89dd7388eaa1305aa44e678255f3fe7a251139f0 100644 (file)
@@ -2,7 +2,7 @@
  * vout_subpictures.c : subpicture management functions
  *****************************************************************************
  * Copyright (C) 2000 VideoLAN
- * $Id: vout_subpictures.c,v 1.21 2003/07/15 18:12:05 sigmunau Exp $
+ * $Id: vout_subpictures.c,v 1.22 2003/12/08 17:48:13 yoann Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -163,6 +163,11 @@ void vout_DestroySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
         p_subpic->pf_destroy( p_subpic );
     }
 
+    if( p_subpic == p_vout->last_osd_message )
+    {
+        p_vout->last_osd_message = NULL;
+    }
+
     p_subpic->i_status = FREE_SUBPICTURE;
 
     vlc_mutex_unlock( &p_vout->subpicture_lock );