Commit 15eb7e62 authored by Benjamin Pracht's avatar Benjamin Pracht

* Reading APIs before starting to code can allow to spare time and to avoid writing silly khludges

parent 3c0e4d35
...@@ -61,8 +61,6 @@ struct vout_sys_t ...@@ -61,8 +61,6 @@ struct vout_sys_t
NSRect s_frame; NSRect s_frame;
vlc_bool_t b_got_frame; vlc_bool_t b_got_frame;
vlc_mutex_t lock; vlc_mutex_t lock;
int i_vout_size_update_counter;
int i_x, i_y;
}; };
/***************************************************************************** /*****************************************************************************
...@@ -77,9 +75,6 @@ static void Swap ( vout_thread_t * p_vout ); ...@@ -77,9 +75,6 @@ static void Swap ( vout_thread_t * p_vout );
static int Lock ( vout_thread_t * p_vout ); static int Lock ( vout_thread_t * p_vout );
static void Unlock ( vout_thread_t * p_vout ); static void Unlock ( vout_thread_t * p_vout );
static int AspectCropCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
int E_(OpenVideoGL) ( vlc_object_t * p_this ) int E_(OpenVideoGL) ( vlc_object_t * p_this )
{ {
vout_thread_t * p_vout = (vout_thread_t *) p_this; vout_thread_t * p_vout = (vout_thread_t *) p_this;
...@@ -145,32 +140,28 @@ void E_(CloseVideoGL) ( vlc_object_t * p_this ) ...@@ -145,32 +140,28 @@ void E_(CloseVideoGL) ( vlc_object_t * p_this )
static int Init( vout_thread_t * p_vout ) static int Init( vout_thread_t * p_vout )
{ {
/* The variable is in fact changed on the parent vout */
if( !var_Type( p_vout->p_parent, "aspect-ratio" ) )
{
var_Create( p_vout->p_parent, "aspect-ratio",
VLC_VAR_STRING | VLC_VAR_DOINHERIT );
}
var_AddCallback( p_vout->p_parent, "aspect-ratio", AspectCropCallback, p_vout );
if( !var_Type( p_vout->p_parent, "crop" ) )
{
var_Create( p_vout->p_parent, "crop",
VLC_VAR_STRING | VLC_VAR_DOINHERIT );
}
var_AddCallback( p_vout->p_parent, "crop", AspectCropCallback, p_vout );
[[p_vout->p_sys->o_glview openGLContext] makeCurrentContext]; [[p_vout->p_sys->o_glview openGLContext] makeCurrentContext];
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static void End( vout_thread_t * p_vout ) static void End( vout_thread_t * p_vout )
{ {
var_DelCallback( p_vout->p_parent, "aspect-ratio", AspectCropCallback, p_vout );
var_DelCallback( p_vout->p_parent, "crop", AspectCropCallback, p_vout );
[[p_vout->p_sys->o_glview openGLContext] makeCurrentContext]; [[p_vout->p_sys->o_glview openGLContext] makeCurrentContext];
} }
static int Manage( vout_thread_t * p_vout ) static int Manage( vout_thread_t * p_vout )
{ {
if( p_vout->i_changes & VOUT_ASPECT_CHANGE )
{
[p_vout->p_sys->o_glview reshape];
p_vout->i_changes &= ~VOUT_ASPECT_CHANGE;
}
if( p_vout->i_changes & VOUT_CROP_CHANGE )
{
[p_vout->p_sys->o_glview reshape];
p_vout->i_changes &= ~VOUT_CROP_CHANGE;
}
if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE ) if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE )
{ {
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
...@@ -213,20 +204,6 @@ static int Manage( vout_thread_t * p_vout ) ...@@ -213,20 +204,6 @@ static int Manage( vout_thread_t * p_vout )
p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE; p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
} }
if( p_vout->p_sys->i_vout_size_update_counter )
{
int i_old_x = p_vout->p_sys->i_x, i_old_y = p_vout->p_sys->i_y;
[p_vout->p_sys->o_glview reshape];
if( p_vout->p_sys->i_x != i_old_x || p_vout->p_sys->i_y != i_old_y )
{
p_vout->p_sys->i_vout_size_update_counter = 0;
}
else if( p_vout->p_sys->i_vout_size_update_counter > 0 )
{
p_vout->p_sys->i_vout_size_update_counter--;
}
}
[p_vout->p_sys->o_vout_view manage]; [p_vout->p_sys->o_vout_view manage];
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -270,24 +247,6 @@ static void Unlock( vout_thread_t * p_vout ) ...@@ -270,24 +247,6 @@ static void Unlock( vout_thread_t * p_vout )
vlc_mutex_unlock( &p_vout->p_sys->lock ); vlc_mutex_unlock( &p_vout->p_sys->lock );
} }
static int AspectCropCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
/* Only update the vout size if the aspect ratio has actually been changed*/
/* We cannot change the size directly in this callback, since fmt_in
hasn't been updated yet, so do it in Manage */
if( strcmp( oldval.psz_string, newval.psz_string ) )
{
/* khludge ! Here, we are not sure that the vout size will actually
change (for instance if we go from Predefined to 4:3 on a 4:3
stream). So, to to trigger reshape endlessly, we decrease that
counter each time we call reshape. We put it to 0 directly if
we actually change the vout size. */
((vout_thread_t *)p_data)->p_sys->i_vout_size_update_counter = 2;
}
return VLC_SUCCESS;
}
/***************************************************************************** /*****************************************************************************
* VLCGLView implementation * VLCGLView implementation
*****************************************************************************/ *****************************************************************************/
...@@ -367,9 +326,6 @@ static int AspectCropCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -367,9 +326,6 @@ static int AspectCropCallback( vlc_object_t *p_this, char const *psz_cmd,
( p_vout->fmt_in.i_visible_width * p_vout->fmt_in.i_sar_num ); ( p_vout->fmt_in.i_visible_width * p_vout->fmt_in.i_sar_num );
} }
p_vout->p_sys->i_x = x;
p_vout->p_sys->i_y = y;
glViewport( ( bounds.size.width - x ) / 2, glViewport( ( bounds.size.width - x ) / 2,
( bounds.size.height - y ) / 2, x, y ); ( bounds.size.height - y ) / 2, x, y );
......
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