From: Clément Stenac Date: Sun, 17 Sep 2006 09:33:59 +0000 (+0000) Subject: * Move all notifications plugins to misc/notify X-Git-Tag: 0.9.0-test0~10273 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=1fa9ce8dc234947c947a400b6d0f884afb75d11c;p=vlc * Move all notifications plugins to misc/notify * Don't find playlist * Fix a few bugs in notification plugins Todo: find a way to get rid of this mostly redundant code and rewrite the XOSD plugin --- diff --git a/configure.ac b/configure.ac index 5371af611a..dc0183f938 100644 --- a/configure.ac +++ b/configure.ac @@ -5637,6 +5637,7 @@ AC_CONFIG_FILES([ modules/misc/dummy/Makefile modules/misc/memcpy/Makefile modules/misc/network/Makefile + modules/misc/notify/Makefile modules/misc/testsuite/Makefile modules/misc/playlist/Makefile modules/misc/xml/Makefile diff --git a/modules/misc/Modules.am b/modules/misc/Modules.am index 2f23e17bfd..ef00194de3 100644 --- a/modules/misc/Modules.am +++ b/modules/misc/Modules.am @@ -10,7 +10,4 @@ SOURCES_logger = logger.c SOURCES_vod_rtsp = rtsp.c SOURCES_gnutls = gnutls.c SOURCES_svg = svg.c -SOURCES_msn = msn.c -SOURCES_growl = growl.c -SOURCES_notify = notify.c SOURCES_profile_parser = profile_parser.c diff --git a/modules/misc/notify/Modules.am b/modules/misc/notify/Modules.am new file mode 100644 index 0000000000..9931df5d48 --- /dev/null +++ b/modules/misc/notify/Modules.am @@ -0,0 +1,4 @@ +SOURCES_msn = msn.c +SOURCES_growl = growl.c +SOURCES_notify = notify.c +SOURCES_xosd = xosd.c diff --git a/modules/misc/growl.c b/modules/misc/notify/growl.c similarity index 98% rename from modules/misc/growl.c rename to modules/misc/notify/growl.c index 6e9749df5f..d4a58c0725 100644 --- a/modules/misc/growl.c +++ b/modules/misc/notify/growl.c @@ -126,18 +126,15 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, vlc_value_t oldval, vlc_value_t newval, void *param ) { char psz_tmp[GROWL_MAX_LENGTH]; - playlist_t *p_playlist; char *psz_title = NULL; char *psz_artist = NULL; char *psz_album = NULL; input_thread_t *p_input; - - p_playlist = (playlist_t *)vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); - if( !p_playlist ) return VLC_EGENERIC; + playlist_t *p_playlist = pl_Yield( p_this ); p_input = p_playlist->p_input; vlc_object_release( p_playlist ); + if( !p_input ) return VLC_SUCCESS; vlc_object_yield( p_input ); diff --git a/modules/misc/msn.c b/modules/misc/notify/msn.c similarity index 85% rename from modules/misc/msn.c rename to modules/misc/notify/msn.c index 9d4423964b..42e3494de0 100644 --- a/modules/misc/msn.c +++ b/modules/misc/notify/msn.c @@ -86,13 +86,7 @@ static int Open( vlc_object_t *p_this ) intf_thread_t *p_intf = (intf_thread_t *)p_this; playlist_t *p_playlist; - /* Allocate instance and initialize some members */ - p_intf->p_sys = (intf_sys_t *)malloc( sizeof( intf_sys_t ) ); - if( p_intf->p_sys == NULL ) - { - msg_Err( p_intf, "out of memory" ); - return -1; - } + MALLOC_ERR( p_intf->p_sys, intf_sys_t ); p_intf->p_sys->psz_format = config_GetPsz( p_intf, "msn-format" ); if( !p_intf->p_sys->psz_format ) @@ -102,22 +96,10 @@ static int Open( vlc_object_t *p_this ) } msg_Dbg( p_intf, "using format: %s", p_intf->p_sys->psz_format ); - p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); - - if( !p_playlist ) - { - msg_Err( p_intf, "could not find playlist object" ); - free( p_intf->p_sys->psz_format ); - free( p_intf->p_sys ); - return VLC_ENOOBJ; - } - - /* Item's info changes */ + p_playlist = pl_Yield( p_intf ); var_AddCallback( p_playlist, "item-change", ItemChange, p_intf ); - /* We're playing a new item */ var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf ); - vlc_object_release( p_playlist ); + pl_Release( p_intf ); p_intf->pf_run = Run; @@ -130,19 +112,15 @@ static int Open( vlc_object_t *p_this ) static void Close( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; - playlist_t *p_playlist = (playlist_t *)vlc_object_find( - p_this, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); + playlist_t *p_playlist = pl_Yield( p_this ); /* clear the MSN stuff ... else it looks like we're still playing * something although VLC (or the MSN plugin) is closed */ SendToMSN( "\\0Music\\01\\0\\0\\0\\0\\0\\0\\0" ); - if( p_playlist ) - { - var_DelCallback( p_playlist, "item-change", ItemChange, p_intf ); - var_DelCallback( p_playlist, "playlist-current", ItemChange, p_intf ); - } - + var_DelCallback( p_playlist, "item-change", ItemChange, p_intf ); + var_DelCallback( p_playlist, "playlist-current", ItemChange, p_intf ); + pl_Release( p_this ); /* Destroy structure */ free( p_intf->p_sys->psz_format ); @@ -164,22 +142,16 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, vlc_value_t oldval, vlc_value_t newval, void *param ) { intf_thread_t *p_intf = (intf_thread_t *)param; - playlist_t *p_playlist; char psz_tmp[MSN_MAX_LENGTH]; char *psz_title = NULL; char *psz_artist = NULL; char *psz_album = NULL; input_thread_t *p_input; - - if( !p_intf->p_sys ) return VLC_SUCCESS; - - p_playlist = (playlist_t *)vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); - - if( !p_playlist ) return VLC_EGENERIC; + playlist_t *p_playlist = pl_Yield( p_this ); p_input = p_playlist->p_input; - vlc_object_release( p_playlist ); + pl_Release( p_this ); + if( !p_input ) return VLC_SUCCESS; vlc_object_yield( p_input ); diff --git a/modules/misc/notify.c b/modules/misc/notify/notify.c similarity index 87% rename from modules/misc/notify.c rename to modules/misc/notify/notify.c index b533753eb2..35f0a9ed55 100644 --- a/modules/misc/notify.c +++ b/modules/misc/notify/notify.c @@ -74,28 +74,19 @@ vlc_module_end(); static int Open( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; - - playlist_t *p_playlist = (playlist_t *)vlc_object_find( - p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); - - if( !p_playlist ) - { - msg_Err( p_intf, "could not find playlist object" ); - return VLC_ENOOBJ; - } - - var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf ); -/* var_AddCallback( p_playlist, "item-change", ItemChange, p_intf );*/ - - vlc_object_release( p_playlist ); + playlist_t *p_playlist; if( !notify_init( APPLICATION_NAME ) ) { msg_Err( p_intf, "can't find notification daemon" ); return VLC_EGENERIC; } + + p_playlist = pl_Yield( p_intf ); + var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf ); + pl_Release( p_intf ); + p_intf->pf_run = Run; - msg_Dbg( p_intf,"notify plugin started"); return VLC_SUCCESS; } @@ -104,14 +95,9 @@ static int Open( vlc_object_t *p_this ) *****************************************************************************/ static void Close( vlc_object_t *p_this ) { - playlist_t *p_playlist = (playlist_t *)vlc_object_find( - p_this, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); - - if( p_playlist ) - { - var_DelCallback( p_playlist, "playlist-current", ItemChange, p_this ); - vlc_object_release( p_playlist ); - } + playlist_t *p_playlist = pl_Yield( p_intf ); + var_DelCallback( p_playlist, "playlist-current", ItemChange, p_this ); + pl_Release( p_intf ); notify_uninit(); } @@ -121,7 +107,7 @@ static void Close( vlc_object_t *p_this ) *****************************************************************************/ static void Run( intf_thread_t *p_this ) { - msleep( 100*INTF_IDLE_SLEEP ); + msleep( 10*INTF_IDLE_SLEEP ); } /***************************************************************************** @@ -136,12 +122,11 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, char *psz_artist = NULL; char *psz_album = NULL; input_thread_t *p_input=NULL; - p_playlist = (playlist_t *)vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); - if( !p_playlist ) return VLC_EGENERIC; + playlist_t * p_playlist = pl_Yield( p_this ); p_input = p_playlist->p_input; vlc_object_release( p_playlist ); + if( !p_input ) return VLC_SUCCESS; vlc_object_yield( p_input ); diff --git a/modules/visualization/xosd.c b/modules/misc/notify/xosd.c similarity index 95% rename from modules/visualization/xosd.c rename to modules/misc/notify/xosd.c index 33e710f6d7..b2e9d5df62 100644 --- a/modules/visualization/xosd.c +++ b/modules/misc/notify/xosd.c @@ -141,18 +141,10 @@ static int Open( vlc_object_t *p_this ) #endif - playlist_t *p_playlist = - (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); - if( p_playlist == NULL ) - { - return VLC_EGENERIC; - } - + playlist_t *p_playlist = pl_Yield( p_intf ); var_AddCallback( p_playlist, "playlist-current", PlaylistNext, p_this ); var_AddCallback( p_playlist, "item-change", PlaylistNext, p_this ); - - vlc_object_release( p_playlist ); + pl_Release( p_intf ); /* Set user preferences */ xosd_set_font( p_intf->p_sys->p_osd, @@ -189,6 +181,10 @@ static int Open( vlc_object_t *p_this ) static void Close( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; + playlist_t *p_playlist = pl_Yield( p_intf ); + var_DelCallback( p_playlist, "playlist-current", PlaylistNext, p_this ); + var_DelCallback( p_playlist, "item-change", PlaylistNext, p_this ); + pl_Release( p_intf ); /* Uninitialize library */ xosd_destroy( p_intf->p_sys->p_osd ); @@ -215,12 +211,7 @@ static void Run( intf_thread_t *p_intf ) if( p_intf->p_sys->b_need_update == VLC_TRUE ) { p_intf->p_sys->b_need_update = VLC_FALSE; - p_playlist = (playlist_t *)vlc_object_find( p_intf, - VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); - if( !p_playlist ) - { - continue; - } + p_playlist = pl_Yield( p_intf ); if( p_playlist->i_size < 0 ) { diff --git a/modules/visualization/Modules.am b/modules/visualization/Modules.am index b46e015351..f075156ec8 100644 --- a/modules/visualization/Modules.am +++ b/modules/visualization/Modules.am @@ -1,2 +1 @@ SOURCES_goom = goom.c -SOURCES_xosd = xosd.c