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:
VOUT_SET_SIZE, /* arg1= unsigned int, arg2= unsigned int, res= */
VOUT_SET_STAY_ON_TOP, /* arg1= bool res= */
VOUT_REPARENT,
VOUT_SET_SIZE, /* arg1= unsigned int, arg2= unsigned int, res= */
VOUT_SET_STAY_ON_TOP, /* arg1= bool res= */
VOUT_REPARENT,
VOUT_CLOSE,
VOUT_SET_FOCUS, /* arg1= bool res= */
VOUT_SET_VIEWPORT, /* arg1= view rect, arg2=clip rect, res= */
VOUT_CLOSE,
VOUT_SET_FOCUS, /* arg1= bool res= */
VOUT_SET_VIEWPORT, /* arg1= view rect, arg2=clip rect, res= */
/* Video Output actions */
else if( i_action == ACTIONID_SNAPSHOT )
{
/* 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 )
{
}
else if( i_action == ACTIONID_TOGGLE_FULLSCREEN )
{
vout_thread_t *p_vout = input_GetVout( p_sys->p_input );
if( p_vout )
{
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" );
}
vlc_object_release( p_vout );
msg_Dbg( p_intf, "requested snapshot" );
}
- vout_Control( p_real_vout, VOUT_SNAPSHOT );
+ var_TriggerCallback( p_real_vout, "video-snapshot" );
- 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" );
hildon_banner_show_information( GTK_WIDGET( p_intf->p_sys->p_main_window ),
NULL,
"Snapshot taken" );
vout_thread_t *p_vout = THEMIM->getVout();
if( p_vout )
{
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 );
}
}
vlc_object_release( p_vout );
}
}
if( pVout )
{
// Take a snapshot
if( pVout )
{
// Take a snapshot
- vout_Control( pVout, VOUT_SNAPSHOT );
+ var_TriggerCallback( pVout, "video-snapshot" );
vlc_object_release( pVout );
}
}
vlc_object_release( pVout );
}
}
- 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 );
default:
if( p_sys->p_vout->pf_control )
return p_sys->p_vout->pf_control( p_sys->p_vout, i_query, args );
- 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 );
default:
if( p_sys->p_vout->pf_control )
return p_sys->p_vout->pf_control( p_sys->p_vout, i_query, args );
NULL (in case of error) or a pointer to valid data. */
p_snapshot->p_data = ( char* )p_snapshot;
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 );
while ( p_snapshot->p_data == ( char* )p_snapshot )
{
vlc_cond_wait( &p_snapshot->p_condvar, &p_snapshot->p_mutex );
var_SetString( p_vout, "snapshot-path", psz_filepath );
var_SetString( p_vout, "snapshot-format", "png" );
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 );
}
vlc_object_release( p_vout );
}
(void)args;
switch( i_query )
{
(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" );
}
default:
msg_Dbg( p_vout, "control query not supported" );
}
static int SnapshotCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
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);
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 );