Commit 53195e9f authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Kill stupid VOUT_SNAPSHOT control.

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.
parent 003d86fa
...@@ -705,7 +705,6 @@ enum output_query_e ...@@ -705,7 +705,6 @@ enum output_query_e
VOUT_SET_SIZE, /* arg1= unsigned int, arg2= unsigned int, res= */ VOUT_SET_SIZE, /* arg1= unsigned int, arg2= unsigned int, res= */
VOUT_SET_STAY_ON_TOP, /* arg1= bool res= */ VOUT_SET_STAY_ON_TOP, /* arg1= bool res= */
VOUT_REPARENT, VOUT_REPARENT,
VOUT_SNAPSHOT,
VOUT_CLOSE, VOUT_CLOSE,
VOUT_SET_FOCUS, /* arg1= bool res= */ VOUT_SET_FOCUS, /* arg1= bool res= */
VOUT_SET_VIEWPORT, /* arg1= view rect, arg2=clip rect, res= */ VOUT_SET_VIEWPORT, /* arg1= view rect, arg2=clip rect, res= */
......
...@@ -244,7 +244,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -244,7 +244,7 @@ static void Run( intf_thread_t *p_intf )
/* Video Output actions */ /* Video Output actions */
else if( i_action == ACTIONID_SNAPSHOT ) 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 ) else if( i_action == ACTIONID_TOGGLE_FULLSCREEN )
{ {
......
...@@ -1125,7 +1125,7 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars, ...@@ -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 ); vout_thread_t *p_vout = input_GetVout( p_sys->p_input );
if( p_vout ) if( p_vout )
{ {
vout_Control( p_vout, VOUT_SNAPSHOT ); vout_TriggerCallback( p_vout, "video-snapshot" );
vlc_object_release( p_vout ); vlc_object_release( p_vout );
msg_Dbg( p_intf, "requested snapshot" ); msg_Dbg( p_intf, "requested snapshot" );
} }
......
...@@ -446,7 +446,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -446,7 +446,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
- (void)snapshot - (void)snapshot
{ {
vout_Control( p_real_vout, VOUT_SNAPSHOT ); var_TriggerCallback( p_real_vout, "video-snapshot" );
} }
- (void)manage - (void)manage
......
...@@ -232,7 +232,7 @@ void snapshot_cb( GtkMenuItem *menuitem, gpointer user_data ) ...@@ -232,7 +232,7 @@ void snapshot_cb( GtkMenuItem *menuitem, gpointer user_data )
return; 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 ), hildon_banner_show_information( GTK_WIDGET( p_intf->p_sys->p_main_window ),
NULL, NULL,
"Snapshot taken" ); "Snapshot taken" );
......
...@@ -127,7 +127,7 @@ void ActionsManager::snapshot() ...@@ -127,7 +127,7 @@ void ActionsManager::snapshot()
vout_thread_t *p_vout = THEMIM->getVout(); vout_thread_t *p_vout = THEMIM->getVout();
if( p_vout ) if( p_vout )
{ {
vout_Control( p_vout, VOUT_SNAPSHOT ); var_TriggerCallback( p_vout, "video-snapshot" );
vlc_object_release( p_vout ); vlc_object_release( p_vout );
} }
} }
......
...@@ -34,7 +34,7 @@ void CmdSnapshot::execute() ...@@ -34,7 +34,7 @@ void CmdSnapshot::execute()
if( pVout ) if( pVout )
{ {
// Take a snapshot // Take a snapshot
vout_Control( pVout, VOUT_SNAPSHOT ); var_TriggerCallback( pVout, "video-snapshot" );
vlc_object_release( pVout ); vlc_object_release( pVout );
} }
} }
......
...@@ -628,9 +628,6 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args ) ...@@ -628,9 +628,6 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
switch( i_query ) switch( i_query )
{ {
case VOUT_SNAPSHOT:
return vout_vaControlDefault( p_vout, i_query, args );
default: default:
if( p_sys->p_vout->pf_control ) if( p_sys->p_vout->pf_control )
return p_sys->p_vout->pf_control( p_sys->p_vout, i_query, args ); return p_sys->p_vout->pf_control( p_sys->p_vout, i_query, args );
......
...@@ -336,9 +336,6 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args ) ...@@ -336,9 +336,6 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
switch( i_query ) switch( i_query )
{ {
case VOUT_SNAPSHOT:
return vout_vaControlDefault( p_vout, i_query, args );
default: default:
if( p_sys->p_vout->pf_control ) if( p_sys->p_vout->pf_control )
return p_sys->p_vout->pf_control( p_sys->p_vout, i_query, args ); return p_sys->p_vout->pf_control( p_sys->p_vout, i_query, args );
......
...@@ -102,7 +102,7 @@ mediacontrol_snapshot( mediacontrol_Instance *self, ...@@ -102,7 +102,7 @@ mediacontrol_snapshot( mediacontrol_Instance *self,
NULL (in case of error) or a pointer to valid data. */ NULL (in case of error) or a pointer to valid data. */
p_snapshot->p_data = ( char* )p_snapshot; 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 ) while ( p_snapshot->p_data == ( char* )p_snapshot )
{ {
vlc_cond_wait( &p_snapshot->p_condvar, &p_snapshot->p_mutex ); vlc_cond_wait( &p_snapshot->p_condvar, &p_snapshot->p_mutex );
......
...@@ -132,7 +132,7 @@ libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, char *psz_filepath, ...@@ -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-path", psz_filepath );
var_SetString( p_vout, "snapshot-format", "png" ); var_SetString( p_vout, "snapshot-format", "png" );
vout_Control( p_vout, VOUT_SNAPSHOT ); var_TriggerCallback( p_vout, "video-snapshot" );
vlc_object_release( p_vout ); vlc_object_release( p_vout );
} }
......
...@@ -906,10 +906,6 @@ int vout_vaControlDefault( vout_thread_t *p_vout, int i_query, va_list args ) ...@@ -906,10 +906,6 @@ int vout_vaControlDefault( vout_thread_t *p_vout, int i_query, va_list args )
(void)args; (void)args;
switch( i_query ) switch( i_query )
{ {
case VOUT_SNAPSHOT:
p_vout->p->b_snapshot = true;
return VLC_SUCCESS;
default: default:
msg_Dbg( p_vout, "control query not supported" ); msg_Dbg( p_vout, "control query not supported" );
} }
...@@ -1270,10 +1266,12 @@ static int FullscreenCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -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, static int SnapshotCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data ) 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(psz_cmd); VLC_UNUSED(oldval);
VLC_UNUSED(newval); VLC_UNUSED(p_data); 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; return VLC_SUCCESS;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment