From 054e7db91b9f4ad154af993e936f3cc94d34ae03 Mon Sep 17 00:00:00 2001 From: Jean-Paul Saman Date: Mon, 2 Mar 2009 21:32:13 +0100 Subject: [PATCH] macosx: vout drawable rework. The macosx drawable variable that used to hold the drawable window reference is splitted up in two variables "drawable-agl" (used by macosx safari/mozilla plugin) and "drawable-gl" (used by macosx interface). --- modules/gui/macosx/vout.m | 11 +++++------ modules/gui/macosx/voutgl.m | 9 +++++---- modules/video_output/opengllayer.m | 6 +++--- src/control/libvlc_internal.h | 3 ++- src/control/media_player.c | 29 +++++++++++++++++++++++++++++ src/control/video.c | 5 ++++- src/libvlc.c | 6 +++--- 7 files changed, 51 insertions(+), 18 deletions(-) diff --git a/modules/gui/macosx/vout.m b/modules/gui/macosx/vout.m index 4654777cd6..6db6e48fa7 100644 --- a/modules/gui/macosx/vout.m +++ b/modules/gui/macosx/vout.m @@ -1,7 +1,7 @@ /***************************************************************************** * vout.m: MacOS X video output module ***************************************************************************** - * Copyright (C) 2001-2008 the VideoLAN team + * Copyright (C) 2001-2009 the VideoLAN team * $Id$ * * Authors: Colin Delacroix @@ -338,7 +338,6 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, vlc_object_release( p_input ); } - - (void)setOnTop:(BOOL)b_on_top { if( b_on_top ) @@ -711,11 +710,11 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, + (id)voutView: (vout_thread_t *)p_vout subView: (NSView *)view frame: (NSRect *)s_frame { - vlc_value_t value_drawable; + int i_drawable_gl; int i_timeout; id o_return = nil; - var_Get( p_vout->p_libvlc, "drawable", &value_drawable ); + i_drawable_gl = var_GetInteger( p_vout->p_libvlc, "drawable-gl" ); var_Create( p_vout, "macosx-vdev", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_vout, "macosx-stretch", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); @@ -726,9 +725,9 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, /* We only wait for NSApp to initialise if we're not embedded (as in the * case of the Mozilla plugin). We can tell whether we're embedded or not - * by examining the "drawable" value: if it's zero, we're running in the + * by examining the "drawable-gl" value: if it's zero, we're running in the * main Mac intf; if it's non-zero, we're embedded. */ - if( value_drawable.i_int == 0 ) + if( i_drawable_gl == 0 ) { /* Wait for a MacOS X interface to appear. Timeout is 2 seconds. */ for( i_timeout = 20 ; i_timeout-- ; ) diff --git a/modules/gui/macosx/voutgl.m b/modules/gui/macosx/voutgl.m index 0704953281..1347503748 100644 --- a/modules/gui/macosx/voutgl.m +++ b/modules/gui/macosx/voutgl.m @@ -114,7 +114,7 @@ int OpenVideoGL ( vlc_object_t * p_this ) memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) ); - var_Get( p_vout->p_libvlc, "drawable", &value_drawable ); + var_Get( p_vout->p_libvlc, "drawable-agl", &value_drawable ); if( value_drawable.i_int != 0 ) { static const GLint ATTRIBUTES[] = { @@ -148,7 +148,8 @@ int OpenVideoGL ( vlc_object_t * p_this ) msg_Err( p_vout, "cannot create AGL context." ); return VLC_EGENERIC; } - else { + else + { // tell opengl not to sync buffer swap with vertical retrace (too inefficient) GLint param = 0; aglSetInteger(p_vout->p_sys->agl_ctx, AGL_SWAP_INTERVAL, ¶m); @@ -496,7 +497,7 @@ static int aglInit( vout_thread_t * p_vout ) Rect viewBounds; Rect clipBounds; - var_Get( p_vout->p_libvlc, "drawable", &val ); + var_Get( p_vout->p_libvlc, "drawable-agl", &val ); p_vout->p_sys->agl_drawable = (AGLDrawable)val.i_int; aglSetDrawable(p_vout->p_sys->agl_ctx, p_vout->p_sys->agl_drawable); @@ -616,7 +617,7 @@ static int aglManage( vout_thread_t * p_vout ) Rect viewBounds; Rect clipBounds; - var_Get( p_vout->p_libvlc, "drawable", &val ); + var_Get( p_vout->p_libvlc, "drawable-agl", &val ); p_vout->p_sys->agl_drawable = (AGLDrawable)val.i_int; aglSetDrawable(p_vout->p_sys->agl_ctx, p_vout->p_sys->agl_drawable); diff --git a/modules/video_output/opengllayer.m b/modules/video_output/opengllayer.m index 4e9c185bdd..fe7518f052 100644 --- a/modules/video_output/opengllayer.m +++ b/modules/video_output/opengllayer.m @@ -3,7 +3,7 @@ * a layer. The layer will register itself to the drawable object stored in * the "drawable" variable. ***************************************************************************** - * Copyright (C) 2004 the VideoLAN team + * Copyright (C) 2004-2009 the VideoLAN team * $Id$ * * Authors: Cyril Deguet @@ -185,8 +185,8 @@ static int Init( vout_thread_t *p_vout ) /* We do need a drawable to work properly */ vlc_value_t value_drawable; - var_Create( p_vout, "drawable", VLC_VAR_DOINHERIT ); - var_Get( p_vout, "drawable", &value_drawable ); + var_Create( p_vout, "drawable-gl", VLC_VAR_DOINHERIT ); + var_Get( p_vout, "drawable-gl", &value_drawable ); p_vout->p_sys->o_cocoa_container = (id) value_drawable.i_int; diff --git a/src/control/libvlc_internal.h b/src/control/libvlc_internal.h index d24d8a9fce..f274478102 100644 --- a/src/control/libvlc_internal.h +++ b/src/control/libvlc_internal.h @@ -2,7 +2,7 @@ * libvlc_internal.h : Definition of opaque structures for libvlc exported API * Also contains some internal utility functions ***************************************************************************** - * Copyright (C) 2005 the VideoLAN team + * Copyright (C) 2005-2009 the VideoLAN team * $Id$ * * Authors: Clément Stenac @@ -158,6 +158,7 @@ struct libvlc_media_player_t { void *hwnd; uint32_t xid; + uint32_t agl; } drawable; bool b_own_its_input_thread; diff --git a/src/control/media_player.c b/src/control/media_player.c index 8ab3b7f8de..61ed914d50 100644 --- a/src/control/media_player.c +++ b/src/control/media_player.c @@ -94,6 +94,7 @@ static void release_input_thread( libvlc_media_player_t *p_mi, bool b_input_abor var_Destroy( p_input_thread, "drawable-hwnd" ); var_Destroy( p_input_thread, "drawable-xid" ); + var_Destroy( p_input_thread, "drawable-agl" ); } vlc_object_release( p_input_thread ); @@ -274,6 +275,7 @@ libvlc_media_player_new( libvlc_instance_t * p_libvlc_instance, return NULL; } p_mi->p_md = NULL; + p_mi->drawable.agl = 0; p_mi->drawable.xid = 0; p_mi->drawable.hwnd = NULL; p_mi->p_libvlc_instance = p_libvlc_instance; @@ -615,6 +617,10 @@ void libvlc_media_player_play( libvlc_media_player_t *p_mi, p_input_thread = p_mi->p_input_thread; + var_Create( p_input_thread, "drawable-agl", VLC_VAR_INTEGER ); + if( p_mi->drawable.agl ) + var_SetInteger( p_input_thread, "drawable-agl", p_mi->drawable.agl ); + var_Create( p_input_thread, "drawable-xid", VLC_VAR_INTEGER ); if( p_mi->drawable.xid ) var_SetInteger( p_input_thread, "drawable-xid", p_mi->drawable.xid ); @@ -728,6 +734,25 @@ void libvlc_media_player_stop( libvlc_media_player_t *p_mi, } } +/************************************************************************** + * set_agl + **************************************************************************/ +void libvlc_media_player_set_agl( libvlc_media_player_t *p_mi, + uint32_t drawable, + libvlc_exception_t *p_e ) +{ + (void) p_e; + p_mi->drawable.agl = drawable; +} + +/************************************************************************** + * get_agl + **************************************************************************/ +uint32_t libvlc_media_player_get_agl( libvlc_media_player_t *p_mi ) +{ + return p_mi->drawable.agl; +} + /************************************************************************** * set_xwindow **************************************************************************/ @@ -778,6 +803,8 @@ void libvlc_media_player_set_drawable( libvlc_media_player_t *p_mi, p_mi->drawable.hwnd = (HWND)drawable; else libvlc_exception_raise(p_e, "Operation not supported"); +#elif defined(__APPLE__) + p_mi->drawable.agl = drawable; #else p_mi->drawable.xid = drawable; #endif @@ -797,6 +824,8 @@ libvlc_media_player_get_drawable ( libvlc_media_player_t *p_mi, return (libvlc_drawable_t)p_mi->drawable.hwnd; else return 0; +#elif defined(__APPLE__) + return p_mi->drawable.agl; #else return p_mi->drawable.xid; #endif diff --git a/src/control/video.c b/src/control/video.c index 6efaa6fe3b..0e3a2a6557 100644 --- a/src/control/video.c +++ b/src/control/video.c @@ -242,6 +242,8 @@ void libvlc_video_set_parent( libvlc_instance_t *p_instance, libvlc_drawable_t d return; /* BOOM! we told you not to use this function! */ val.p_address = (void *)(uintptr_t)d; var_Set( p_instance->p_libvlc_int, "drawable-hwnd", val ); +#elif defined(__APPLE__) + var_SetInteger( p_instance->p_libvlc_int, "drawable-agl", d ); #else var_SetInteger( p_instance->p_libvlc_int, "drawable-xid", d ); #endif @@ -266,12 +268,13 @@ libvlc_drawable_t libvlc_video_get_parent( libvlc_instance_t *p_instance, libvlc return 0; var_Get( p_instance->p_libvlc_int, "drawable-hwnd", &val ); return (uintptr_t)val.p_address; +#elif defined(__APPLE__) + return var_GetInteger( p_instance->p_libvlc_int, "drawable-agl" ); #else return var_GetInteger( p_instance->p_libvlc_int, "drawable-xid" ); #endif } - void libvlc_video_set_size( libvlc_instance_t *p_instance, int width, int height, libvlc_exception_t *p_e ) { diff --git a/src/libvlc.c b/src/libvlc.c index e4a1a8e780..49f4ff5082 100644 --- a/src/libvlc.c +++ b/src/libvlc.c @@ -970,9 +970,9 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, */ var_Create( p_libvlc, "drawable-xid", VLC_VAR_INTEGER ); var_Create( p_libvlc, "drawable-hwnd", VLC_VAR_ADDRESS ); -#ifdef __APPLE__ - var_Create( p_libvlc, "drawable", VLC_VAR_INTEGER ); -#endif + var_Create( p_libvlc, "drawable-agl", VLC_VAR_INTEGER ); + var_Create( p_libvlc, "drawable-gl", VLC_VAR_INTEGER ); + var_Create( p_libvlc, "drawable-view-top", VLC_VAR_INTEGER ); var_Create( p_libvlc, "drawable-view-left", VLC_VAR_INTEGER ); var_Create( p_libvlc, "drawable-view-bottom", VLC_VAR_INTEGER ); -- 2.39.2