]> git.sesse.net Git - vlc/commitdiff
* Move all notifications plugins to misc/notify
authorClément Stenac <zorglub@videolan.org>
Sun, 17 Sep 2006 09:33:59 +0000 (09:33 +0000)
committerClément Stenac <zorglub@videolan.org>
Sun, 17 Sep 2006 09:33:59 +0000 (09:33 +0000)
* 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

configure.ac
modules/misc/Modules.am
modules/misc/notify/Modules.am [new file with mode: 0644]
modules/misc/notify/growl.c [moved from modules/misc/growl.c with 98% similarity]
modules/misc/notify/msn.c [moved from modules/misc/msn.c with 85% similarity]
modules/misc/notify/notify.c [moved from modules/misc/notify.c with 87% similarity]
modules/misc/notify/xosd.c [moved from modules/visualization/xosd.c with 95% similarity]
modules/visualization/Modules.am

index 5371af611a7b20c6a986a824b9bd461558631043..dc0183f9389aedb34c464970e47b40a5d6d688db 100644 (file)
@@ -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
index 2f23e17bfd2c2dc250ab3bfd4cd3e49dc75d1aa6..ef00194de39e881fa6010067c1631d70562c5c80 100644 (file)
@@ -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 (file)
index 0000000..9931df5
--- /dev/null
@@ -0,0 +1,4 @@
+SOURCES_msn = msn.c
+SOURCES_growl = growl.c
+SOURCES_notify = notify.c
+SOURCES_xosd = xosd.c
similarity index 98%
rename from modules/misc/growl.c
rename to modules/misc/notify/growl.c
index 6e9749df5f2df341dc75991064abf46a1ad7385d..d4a58c07251aefd95c78f6360a35c637f36e4d99 100644 (file)
@@ -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 );
 
similarity index 85%
rename from modules/misc/msn.c
rename to modules/misc/notify/msn.c
index 9d4423964b4cf0533e41b3ff4f74fbd71e58a8e5..42e3494de0289fef3f51667d3e598fd838802676 100644 (file)
@@ -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 );
 
similarity index 87%
rename from modules/misc/notify.c
rename to modules/misc/notify/notify.c
index b533753eb2505689779969ce8c77aec5dbfd9b49..35f0a9ed55bd60fbb329649724f4b7657688d50d 100644 (file)
@@ -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 );
 
similarity index 95%
rename from modules/visualization/xosd.c
rename to modules/misc/notify/xosd.c
index 33e710f6d72bc61aadec9ea7f378c6ae6a14e920..b2e9d5df62b23d4542bbcb52cc87315a5fa08547 100644 (file)
@@ -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  )
             {
index b46e0153510704c107980c3c759c2af990d26d8c..f075156ec87687de74d13ae71ea00f579229ffc4 100644 (file)
@@ -1,2 +1 @@
 SOURCES_goom = goom.c
-SOURCES_xosd = xosd.c