From: Benjamin Pracht Date: Wed, 29 Mar 2006 20:03:48 +0000 (+0000) Subject: * vout.m : comment the NSLog call in windowContainsEmbedded: this method is called... X-Git-Tag: 0.9.0-test0~11719 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=acb0bedc7d7ff9e341ae9f872d581eac13e895af;p=vlc * vout.m : comment the NSLog call in windowContainsEmbedded: this method is called on something else than an NSWindow in normal operation * other: implement on the fly aspect ratio change. Only works in the ogl output at the moment --- diff --git a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib index bfb3aa61fe..a6a7ff3fda 100644 --- a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib +++ b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib @@ -229,6 +229,7 @@ "o_messages" = id; "o_mi_about" = id; "o_mi_add_intf" = id; + "o_mi_aspect_ratio" = id; "o_mi_audiotrack" = id; "o_mi_bookmarks" = id; "o_mi_bring_atf" = id; @@ -300,6 +301,7 @@ "o_msgs_btn_crashlog" = id; "o_msgs_panel" = id; "o_mu_add_intf" = id; + "o_mu_aspect_ratio" = id; "o_mu_audio" = id; "o_mu_audiotrack" = id; "o_mu_channels" = id; diff --git a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib index 48f1feb925..4bdffa955d 100644 --- a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib +++ b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib @@ -3,7 +3,7 @@ IBDocumentLocation - 35 101 478 430 0 0 1440 878 + 43 22 478 430 0 0 1024 746 IBEditorPositions 1617 @@ -11,7 +11,7 @@ 2197 422 532 596 143 0 0 1440 878 29 - 71 662 438 44 0 0 1024 746 + 76 675 438 44 0 0 1024 746 915 777 479 187 249 0 0 1440 878 @@ -21,8 +21,8 @@ IBOpenObjects + 21 1789 - 29 IBSystem Version 8H14 diff --git a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/keyedobjects.nib b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/keyedobjects.nib index 2cfbd665c3..c13179d06f 100644 Binary files a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/keyedobjects.nib and b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/keyedobjects.nib differ diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h index 39a8a787e9..797f02b37b 100644 --- a/modules/gui/macosx/intf.h +++ b/modules/gui/macosx/intf.h @@ -228,6 +228,8 @@ struct intf_sys_t IBOutlet id o_mu_videotrack; IBOutlet id o_mi_screen; IBOutlet id o_mu_screen; + IBOutlet id o_mi_aspect_ratio; + IBOutlet id o_mu_aspect_ratio; IBOutlet id o_mi_subtitle; IBOutlet id o_mu_subtitle; IBOutlet id o_mi_deinterlace; diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m index 4e06828a99..89ea595b4b 100644 --- a/modules/gui/macosx/intf.m +++ b/modules/gui/macosx/intf.m @@ -555,6 +555,8 @@ static VLCMain *_o_sharedMainInstance = nil; [o_mi_snapshot setTitle: _NS("Snapshot")]; [o_mi_videotrack setTitle: _NS("Video Track")]; [o_mu_videotrack setTitle: _NS("Video Track")]; + [o_mi_aspect_ratio setTitle: _NS("Aspect-ratio")]; + [o_mu_aspect_ratio setTitle: _NS("Aspect-ratio")]; [o_mi_screen setTitle: _NS("Video Device")]; [o_mu_screen setTitle: _NS("Video Device")]; [o_mi_subtitle setTitle: _NS("Subtitles Track")]; @@ -1150,6 +1152,9 @@ static VLCMain *_o_sharedMainInstance = nil; { vlc_object_t * p_dec_obj; + [o_controls setupVarMenuItem: o_mi_aspect_ratio target: (vlc_object_t *)[VLCVoutView getRealVout: p_vout] + var: "aspect-ratio" selector: @selector(toggleVar:)]; + [o_controls setupVarMenuItem: o_mi_screen target: (vlc_object_t *)p_vout var: "video-device" selector: @selector(toggleVar:)]; @@ -1325,6 +1330,7 @@ static VLCMain *_o_sharedMainInstance = nil; [o_mi_ffmpeg_pp setEnabled: b_enabled]; [o_mi_device setEnabled: b_enabled]; [o_mi_screen setEnabled: b_enabled]; + [o_mi_aspect_ratio setEnabled: b_enabled]; } - (void)manageVolumeSlider diff --git a/modules/gui/macosx/vout.m b/modules/gui/macosx/vout.m index f6fa113612..3bb355f64b 100644 --- a/modules/gui/macosx/vout.m +++ b/modules/gui/macosx/vout.m @@ -111,10 +111,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, - (BOOL)windowContainsEmbedded: (id)o_window { - if( ![[o_window className] isEqualToString: @"VLCWindow"] ) +/* if( ![[o_window className] isEqualToString: @"VLCWindow"] ) { NSLog( @"We were not given a VLCWindow" ); - } + }*/ return ([self getViewForWindow: o_window] == nil ? NO : YES ); } diff --git a/modules/gui/macosx/voutgl.m b/modules/gui/macosx/voutgl.m index 8b3c89ed20..e628ff5bd9 100644 --- a/modules/gui/macosx/voutgl.m +++ b/modules/gui/macosx/voutgl.m @@ -61,6 +61,7 @@ struct vout_sys_t NSRect s_frame; vlc_bool_t b_got_frame; vlc_mutex_t lock; + vlc_bool_t b_vout_size_update; }; /***************************************************************************** @@ -75,6 +76,9 @@ static void Swap ( vout_thread_t * p_vout ); static int Lock ( vout_thread_t * p_vout ); static void Unlock ( vout_thread_t * p_vout ); +static int AspectCallback( vlc_object_t *, char const *, + vlc_value_t, vlc_value_t, void * ); + int E_(OpenVideoGL) ( vlc_object_t * p_this ) { vout_thread_t * p_vout = (vout_thread_t *) p_this; @@ -140,12 +144,20 @@ void E_(CloseVideoGL) ( vlc_object_t * p_this ) 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", AspectCallback, p_vout ); [[p_vout->p_sys->o_glview openGLContext] makeCurrentContext]; return VLC_SUCCESS; } static void End( vout_thread_t * p_vout ) { + var_DelCallback( p_vout->p_parent, "aspect-ratio", AspectCallback, p_vout ); [[p_vout->p_sys->o_glview openGLContext] makeCurrentContext]; } @@ -192,6 +204,20 @@ static int Manage( vout_thread_t * p_vout ) p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE; } + + if( p_vout->p_sys->b_vout_size_update ) + { + NSRect old_bounds = [p_vout->p_sys->o_glview bounds]; + [p_vout->p_sys->o_glview reshape]; + if( [p_vout->p_sys->o_glview bounds].size.height != + old_bounds.size.height || + [p_vout->p_sys->o_glview bounds].size.width != + old_bounds.size.width); + { + p_vout->p_sys->b_vout_size_update = VLC_FALSE; + } + } + [p_vout->p_sys->o_vout_view manage]; return VLC_SUCCESS; } @@ -235,6 +261,18 @@ static void Unlock( vout_thread_t * p_vout ) vlc_mutex_unlock( &p_vout->p_sys->lock ); } +static int AspectCallback( 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*/ + + if( strcmp( oldval.psz_string, newval.psz_string ) ) + { + ((vout_thread_t *)p_data)->p_sys->b_vout_size_update = VLC_TRUE; + } + return VLC_SUCCESS; +} + /***************************************************************************** * VLCGLView implementation *****************************************************************************/ @@ -295,16 +333,21 @@ static void Unlock( vout_thread_t * p_vout ) x = bounds.size.width; y = bounds.size.height; } - else if( bounds.size.height * p_vout->render.i_aspect < - bounds.size.width * VOUT_ASPECT_FACTOR ) + else if( bounds.size.height * p_vout->render.i_aspect * + p_vout->fmt_in.i_sar_num < + bounds.size.width * VOUT_ASPECT_FACTOR * p_vout->fmt_in.i_sar_den ) { - x = bounds.size.height * p_vout->render.i_aspect / VOUT_ASPECT_FACTOR; + x = bounds.size.height * p_vout->render.i_aspect * + p_vout->fmt_in.i_sar_num / ( VOUT_ASPECT_FACTOR * + p_vout->fmt_in.i_sar_den ); y = bounds.size.height; } else { x = bounds.size.width; - y = bounds.size.width * VOUT_ASPECT_FACTOR / p_vout->render.i_aspect; + y = bounds.size.width * p_vout->fmt_in.i_sar_den * + VOUT_ASPECT_FACTOR / ( p_vout->fmt_in.i_sar_num * + p_vout->render.i_aspect ); } glViewport( ( bounds.size.width - x ) / 2,