Modified the way title is updated (msw).
authorLaurent Aimar <fenrir@videolan.org>
Mon, 28 Sep 2009 18:50:46 +0000 (20:50 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Mon, 28 Sep 2009 18:50:46 +0000 (20:50 +0200)
modules/video_output/msw/direct3d.c
modules/video_output/msw/directx.c
modules/video_output/msw/events.c
modules/video_output/msw/glwin32.c
modules/video_output/msw/vout.h
modules/video_output/msw/wingdi.c

index c4384b2..f6ecbfc 100644 (file)
@@ -275,7 +275,7 @@ static int Init( vout_thread_t *p_vout )
     }
 
     /* Change the window title bar text */
     }
 
     /* Change the window title bar text */
-    PostMessage( p_vout->p_sys->hwnd, WM_VLC_CHANGE_TEXT, 0, 0 );
+    EventThreadUpdateTitle( p_vout->p_sys->p_event, VOUT_TITLE " (Direct3D output)" );
 
     p_vout->fmt_out.i_chroma = p_vout->output.i_chroma;
     return VLC_SUCCESS;
 
     p_vout->fmt_out.i_chroma = p_vout->output.i_chroma;
     return VLC_SUCCESS;
index 5af1c0d..ae27d9e 100644 (file)
@@ -385,10 +385,18 @@ static int Init( vout_thread_t *p_vout )
         NewPictureVec( p_vout, p_vout->p_picture );
     }
 
         NewPictureVec( p_vout, p_vout->p_picture );
     }
 
+    p_vout->fmt_out.i_chroma = p_vout->output.i_chroma;
+
     /* Change the window title bar text */
     /* Change the window title bar text */
-    PostMessage( p_vout->p_sys->hwnd, WM_VLC_CHANGE_TEXT, 0, 0 );
+    const char *psz_fallback;
+    if( p_vout->p_sys->b_using_overlay )
+        psz_fallback = VOUT_TITLE " (hardware YUV overlay DirectX output)";
+    else if( p_vout->p_sys->b_hw_yuv )
+        psz_fallback = VOUT_TITLE " (hardware YUV DirectX output)";
+    else
+        psz_fallback = VOUT_TITLE " (software RGB DirectX output)";
+    EventThreadUpdateTitle( p_vout->p_sys->p_event, psz_fallback );
 
 
-    p_vout->fmt_out.i_chroma = p_vout->output.i_chroma;
     return VLC_SUCCESS;
 }
 
     return VLC_SUCCESS;
 }
 
index 6702835..2104dce 100644 (file)
@@ -330,50 +330,30 @@ static void *EventThread( void *p_this )
             break;
 
         case WM_VLC_CHANGE_TEXT:
             break;
 
         case WM_VLC_CHANGE_TEXT:
-            var_Get( p_vout, "video-title", &val );
-            if( !val.psz_string || !*val.psz_string ) /* Default video title */
-            {
-                free( val.psz_string );
-
-#ifdef MODULE_NAME_IS_wingdi
-                val.psz_string = strdup( VOUT_TITLE " (WinGDI output)" );
-#endif
-#ifdef MODULE_NAME_IS_wingapi
-                val.psz_string = strdup( VOUT_TITLE " (WinGAPI output)" );
-#endif
-#ifdef MODULE_NAME_IS_glwin32
-                val.psz_string = strdup( VOUT_TITLE " (OpenGL output)" );
-#endif
-#ifdef MODULE_NAME_IS_direct3d
-                val.psz_string = strdup( VOUT_TITLE " (Direct3D output)" );
-#endif
-#ifdef MODULE_NAME_IS_directx
-                if( p_event->p_vout->p_sys->b_using_overlay ) val.psz_string =
-                    strdup( VOUT_TITLE " (hardware YUV overlay DirectX output)" );
-                else if( p_event->p_vout->p_sys->b_hw_yuv ) val.psz_string =
-                    strdup( VOUT_TITLE " (hardware YUV DirectX output)" );
-                else val.psz_string =
-                    strdup( VOUT_TITLE " (software RGB DirectX output)" );
-#endif
-            }
-
+        {
+            vlc_mutex_lock( &p_event->lock );
+            wchar_t *pwz_title = NULL;
+            if( p_event->psz_title )
             {
             {
-                wchar_t *psz_title = malloc( strlen(val.psz_string) * 2 + 2 );
-                if( psz_title )
+                const size_t i_length = strlen(p_event->psz_title);
+                pwz_title = malloc( 2 * (i_length + 1) );
+                if( pwz_title )
                 {
                 {
-                    mbstowcs( psz_title, val.psz_string, strlen(val.psz_string)*2);
-                    psz_title[strlen(val.psz_string)] = 0;
-                    free( val.psz_string ); val.psz_string = (char *)psz_title;
+                    mbstowcs( pwz_title, p_event->psz_title, 2 * i_length );
+                    pwz_title[i_length] = 0;
                 }
             }
                 }
             }
+            vlc_mutex_unlock( &p_event->lock );
 
 
-            SetWindowText( p_event->p_vout->p_sys->hwnd,
-                           (LPCTSTR)val.psz_string );
-            if( p_event->p_vout->p_sys->hfswnd )
-                SetWindowText( p_event->p_vout->p_sys->hfswnd,
-                               (LPCTSTR)val.psz_string );
-            free( val.psz_string );
+            if( pwz_title )
+            {
+                SetWindowText( p_vout->p_sys->hwnd, (LPCTSTR)pwz_title );
+                if( p_vout->p_sys->hfswnd )
+                    SetWindowText( p_vout->p_sys->hfswnd, (LPCTSTR)pwz_title );
+                free( pwz_title );
+            }
             break;
             break;
+        }
 
         default:
             /* Messages we don't handle directly are dispatched to the
 
         default:
             /* Messages we don't handle directly are dispatched to the
@@ -913,6 +893,21 @@ void EventThreadMouseAutoHide( event_thread_t *p_event )
         }
     }
 }
         }
     }
 }
+void EventThreadUpdateTitle( event_thread_t *p_event, const char *psz_fallback )
+{
+    char *psz_title = var_GetNonEmptyString( p_event->p_vout, "video-title" );
+    if( !psz_title )
+        psz_title = strdup( psz_fallback );
+    if( !psz_title )
+        return;
+
+    vlc_mutex_lock( &p_event->lock );
+    free( p_event->psz_title );
+    p_event->psz_title = psz_title;
+    vlc_mutex_unlock( &p_event->lock );
+
+    PostMessage( p_event->p_vout->p_sys->hwnd, WM_VLC_CHANGE_TEXT, 0, 0 );
+}
 
 event_thread_t *EventThreadCreate( vout_thread_t *p_vout )
 {
 
 event_thread_t *EventThreadCreate( vout_thread_t *p_vout )
 {
@@ -936,12 +931,14 @@ event_thread_t *EventThreadCreate( vout_thread_t *p_vout )
     p_event->i_lastmoved          = mdate();
     p_event->i_mouse_hide_timeout =
         var_GetInteger(p_vout, "mouse-hide-timeout") * 1000;
     p_event->i_lastmoved          = mdate();
     p_event->i_mouse_hide_timeout =
         var_GetInteger(p_vout, "mouse-hide-timeout") * 1000;
+    p_event->psz_title = NULL;
    
     return p_event;
 }
 
 void EventThreadDestroy( event_thread_t *p_event )
 {
    
     return p_event;
 }
 
 void EventThreadDestroy( event_thread_t *p_event )
 {
+    free( p_event->psz_title );
     vlc_cond_destroy( &p_event->wait );
     vlc_mutex_destroy( &p_event->lock );
     free( p_event );
     vlc_cond_destroy( &p_event->wait );
     vlc_mutex_destroy( &p_event->lock );
     free( p_event );
index 5b92bce..46226fa 100644 (file)
@@ -123,7 +123,7 @@ static int Init( vout_thread_t *p_vout )
     int iFormat;
 
     /* Change the window title bar text */
     int iFormat;
 
     /* Change the window title bar text */
-    PostMessage( p_vout->p_sys->hwnd, WM_VLC_CHANGE_TEXT, 0, 0 );
+    EventThreadUpdateTitle( p_vout->p_sys->p_event, VOUT_TITLE " (OpenGL output)" );
 
     p_vout->p_sys->hGLDC = GetDC( p_vout->p_sys->hvideownd );
 
 
     p_vout->p_sys->hGLDC = GetDC( p_vout->p_sys->hvideownd );
 
index 3697c03..6a974ed 100644 (file)
@@ -42,6 +42,9 @@ typedef struct
     volatile mtime_t i_lastmoved;
     mtime_t          i_mouse_hide_timeout;
 
     volatile mtime_t i_lastmoved;
     mtime_t          i_mouse_hide_timeout;
 
+    /* Title */
+    char *psz_title;
+
 } event_thread_t;
 
 #ifdef MODULE_NAME_IS_wingapi
 } event_thread_t;
 
 #ifdef MODULE_NAME_IS_wingapi
@@ -263,6 +266,7 @@ int             EventThreadStart( event_thread_t * );
 void            EventThreadStop( event_thread_t * );
 
 void            EventThreadMouseAutoHide( event_thread_t * );
 void            EventThreadStop( event_thread_t * );
 
 void            EventThreadMouseAutoHide( event_thread_t * );
+void            EventThreadUpdateTitle( event_thread_t *, const char *psz_fallback );
 
 /*****************************************************************************
  * Prototypes from common.c
 
 /*****************************************************************************
  * Prototypes from common.c
index 0078c4f..86185d9 100644 (file)
@@ -270,7 +270,11 @@ static int Init( vout_thread_t *p_vout )
     PP_OUTPUTPICTURE[ I_OUTPUTPICTURES++ ] = p_pic;
 
     /* Change the window title bar text */
     PP_OUTPUTPICTURE[ I_OUTPUTPICTURES++ ] = p_pic;
 
     /* Change the window title bar text */
-    PostMessage( p_vout->p_sys->hwnd, WM_VLC_CHANGE_TEXT, 0, 0 );
+#ifdef MODULE_NAME_IS_wingapi
+    EventThreadUpdateTitle( p_vout->p_sys->p_event, VOUT_TITLE " (WinGAPI output)" );
+#else
+    EventThreadUpdateTitle( p_vout->p_sys->p_event, VOUT_TITLE " (WinGDI output)" );
+#endif
     UpdateRects( p_vout, true );
 
     return VLC_SUCCESS;
     UpdateRects( p_vout, true );
 
     return VLC_SUCCESS;