]> git.sesse.net Git - vlc/commitdiff
Kill stupid VOUT_SNAPSHOT control.
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 14 Feb 2009 17:58:03 +0000 (19:58 +0200)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 14 Feb 2009 18:02:31 +0000 (20:02 +0200)
Calling vout_Control() after vlc_object_find() or input_GetVouts is not
valid. It cannot be. There is no warranty that pf_control is valid (the
video output plugin could be initializing or deinitializing). Even if
there were a lock without the pf_control implementation (as with X11),
it still wouldn't work.

Anyway, in this particular case, we already have video-snapshot to do
the exact same thing in a safe manner.

There remain some issues with snapshots:
 - there is no synchronization of b_snapshoy with the video thread,
 - there is no/incomplete error handling,
 - there is no protection against multiple concurrent snapshot reqs.

12 files changed:
include/vlc_vout.h
modules/control/hotkeys.c
modules/control/http/rpn.c
modules/gui/macosx/vout.m
modules/gui/maemo/maemo_callbacks.c
modules/gui/qt4/actions_manager.cpp
modules/gui/skins2/commands/cmd_snapshot.cpp
modules/video_output/opengl.c
modules/video_output/opengllayer.m
src/control/mediacontrol_audio_video.c
src/control/video.c
src/video_output/vout_intf.c

index 9744319f5967c63a840ef8456d3a4c5dd165a993..2effe42939fc12db79a9c00f27bd21ae8ad9a0f0 100644 (file)
@@ -705,7 +705,6 @@ enum output_query_e
     VOUT_SET_SIZE,         /* arg1= unsigned int, arg2= unsigned int, res= */
     VOUT_SET_STAY_ON_TOP,  /* arg1= bool       res=    */
     VOUT_REPARENT,
-    VOUT_SNAPSHOT,
     VOUT_CLOSE,
     VOUT_SET_FOCUS,         /* arg1= bool       res=    */
     VOUT_SET_VIEWPORT,      /* arg1= view rect, arg2=clip rect, res= */
index b4e52711ad1b329b4be3a5bcf2b644986de69804..74cf5a19e4767751ae921cd96cba26707e9ffe2b 100644 (file)
@@ -244,7 +244,7 @@ static void Run( intf_thread_t *p_intf )
         /* Video Output actions */
         else if( i_action == ACTIONID_SNAPSHOT )
         {
-            if( p_vout ) vout_Control( p_vout, VOUT_SNAPSHOT );
+            if( p_vout ) var_TriggerCallback( p_vout, "video-snapshot" );
         }
         else if( i_action == ACTIONID_TOGGLE_FULLSCREEN )
         {
index e4689ffc6c5c20382622a7b6fd17540e24d951b1..73aee512df102a9c9cccae0a6b3c3e531097d400 100644 (file)
@@ -1125,7 +1125,7 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
                 vout_thread_t *p_vout = input_GetVout( p_sys->p_input );
                 if( p_vout )
                 {
-                    vout_Control( p_vout, VOUT_SNAPSHOT );
+                    vout_TriggerCallback( p_vout, "video-snapshot" );
                     vlc_object_release( p_vout );
                     msg_Dbg( p_intf, "requested snapshot" );
                 }
index 645bc3d84e38bc55dca327d7896c3766adb34c44..4654777cd679b45847ba2bfc807ed5ce785b64a0 100644 (file)
@@ -446,7 +446,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
 - (void)snapshot
 {
-    vout_Control( p_real_vout, VOUT_SNAPSHOT );
+    var_TriggerCallback( p_real_vout, "video-snapshot" );
 }
 
 - (void)manage
index 97ee4dfa84999216da830d34548baabca591dd34..c14435c010b15fc43ac6149f4cd3ca5c117bc61e 100644 (file)
@@ -232,7 +232,7 @@ void snapshot_cb( GtkMenuItem *menuitem, gpointer user_data )
         return;
     }
 
-    vout_Control( p_intf->p_sys->p_vout, VOUT_SNAPSHOT );
+    var_TriggerCallback( p_intf->p_sys->p_vout, "video-snapshot" );
     hildon_banner_show_information( GTK_WIDGET( p_intf->p_sys->p_main_window ),
                                     NULL,
                                     "Snapshot taken" );
index ee5bcb6adb30f7da82f39ecfca1c85b62c6c0ed4..edddb1a0a512816ae4b02642774d9fd2d2148cf9 100644 (file)
@@ -127,7 +127,7 @@ void ActionsManager::snapshot()
     vout_thread_t *p_vout = THEMIM->getVout();
     if( p_vout )
     {
-        vout_Control( p_vout, VOUT_SNAPSHOT );
+        var_TriggerCallback( p_vout, "video-snapshot" );
         vlc_object_release( p_vout );
     }
 }
index 80d12ca310944c314d3bddf7e31f102e0f485500..bc2b0208688c388d71344ae338f463c72ff807fa 100644 (file)
@@ -34,7 +34,7 @@ void CmdSnapshot::execute()
     if( pVout )
     {
         // Take a snapshot
-        vout_Control( pVout, VOUT_SNAPSHOT );
+        var_TriggerCallback( pVout, "video-snapshot" );
         vlc_object_release( pVout );
     }
 }
index c8a1cc04e07bb35c17129bd85573b4ac43fc5880..2147d0c20430e95eda32a18cc66be19efe09e9bb 100644 (file)
@@ -628,9 +628,6 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
 
     switch( i_query )
     {
-    case VOUT_SNAPSHOT:
-        return vout_vaControlDefault( p_vout, i_query, args );
-
     default:
         if( p_sys->p_vout->pf_control )
             return p_sys->p_vout->pf_control( p_sys->p_vout, i_query, args );
index 8536cd015524389dbf4b936e9b40475abfdf699d..4884eef09a476b5ab3f5f045740047a5b0ec534d 100644 (file)
@@ -336,9 +336,6 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
 
     switch( i_query )
     {
-    case VOUT_SNAPSHOT:
-        return vout_vaControlDefault( p_vout, i_query, args );
-
     default:
         if( p_sys->p_vout->pf_control )
             return p_sys->p_vout->pf_control( p_sys->p_vout, i_query, args );
index 3e022637f8b849d5ec0fa6f9623a902ba9b312a3..23027d3a2ab75fbcec1df41d51ecbf775e23ca2e 100644 (file)
@@ -102,7 +102,7 @@ mediacontrol_snapshot( mediacontrol_Instance *self,
        NULL (in case of error) or a pointer to valid data. */
     p_snapshot->p_data = ( char* )p_snapshot;
 
-    vout_Control( p_vout, VOUT_SNAPSHOT );
+    var_TriggerCallback( p_vout, "video-snapshot" );
     while ( p_snapshot->p_data == ( char* )p_snapshot )
     {
         vlc_cond_wait( &p_snapshot->p_condvar, &p_snapshot->p_mutex );
index 44eb252f8b0a1e8c306cbbb913b6ed5edd59e09f..ef081c6911978b93deedf615380b261d02fcdf86 100644 (file)
@@ -132,7 +132,7 @@ libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, char *psz_filepath,
     var_SetString( p_vout, "snapshot-path", psz_filepath );
     var_SetString( p_vout, "snapshot-format", "png" );
 
-    vout_Control( p_vout, VOUT_SNAPSHOT );
+    var_TriggerCallback( p_vout, "video-snapshot" );
     vlc_object_release( p_vout );
 }
 
index 9794eeeda2678f8d4551797d49e098579f72d13f..6cb8459bdc17a61c3a8d90f2c6b236e9044612af 100644 (file)
@@ -906,10 +906,6 @@ int vout_vaControlDefault( vout_thread_t *p_vout, int i_query, va_list args )
     (void)args;
     switch( i_query )
     {
-    case VOUT_SNAPSHOT:
-        p_vout->p->b_snapshot = true;
-        return VLC_SUCCESS;
-
     default:
         msg_Dbg( p_vout, "control query not supported" );
     }
@@ -1270,10 +1266,12 @@ static int FullscreenCallback( vlc_object_t *p_this, char const *psz_cmd,
 static int SnapshotCallback( vlc_object_t *p_this, char const *psz_cmd,
                        vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    vout_thread_t *p_vout = (vout_thread_t *)p_this;
+
+    /* FIXME: this is definitely not thread-safe */
+    p_vout->p->b_snapshot = true;
     VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
     VLC_UNUSED(newval); VLC_UNUSED(p_data);
-    vout_thread_t *p_vout = (vout_thread_t *)p_this;
-    vout_Control( p_vout, VOUT_SNAPSHOT );
     return VLC_SUCCESS;
 }