Fix warning
[vlc.git] / modules / misc / growl.c
index 2184397..ec2d8dd 100644 (file)
@@ -99,7 +99,7 @@ static int Open( vlc_object_t *p_this )
     if( !p_playlist )
     {
         msg_Err( p_intf, "could not find playlist object" );
-        return -1;
+        return VLC_ENOOBJ;
     }
 
     var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf );
@@ -108,7 +108,7 @@ static int Open( vlc_object_t *p_this )
     RegisterToGrowl( p_this );
     p_intf->pf_run = Run;
 
-    return 0;
+    return VLC_SUCCESS;
 }
 
 /*****************************************************************************
@@ -116,6 +116,14 @@ 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 );
+    }
 }
 
 /*****************************************************************************
@@ -133,23 +141,32 @@ 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_INPUT,
+                                                FIND_ANYWHERE );
+    if( !p_playlist ) return VLC_EGENERIC;
+
+    p_input = p_playlist->p_input;
+    vlc_object_release( p_playlist );
+    if( !p_input ) return VLC_SUCCESS;
+    vlc_object_yield( p_input );
 
-    input_thread_t *p_input =
-        (input_thread_t *)vlc_object_find( p_this, VLC_OBJECT_INPUT,
-                                           FIND_ANYWHERE );
-    if( !p_input || p_input->b_dead || !p_input->input.p_item->psz_name )
+    if( p_input->b_dead || !p_input->input.p_item->psz_name )
     {
         /* Not playing anything ... */
+        vlc_object_release( p_input );
         return VLC_SUCCESS;
     }
 
     /* Playing something ... */
     psz_artist = vlc_input_item_GetInfo( p_input->input.p_item,
                                          _("Meta-information"),
-                                         VLC_META_ARTIST);
+                                         _(VLC_META_ARTIST) );
     psz_album = vlc_input_item_GetInfo( p_input->input.p_item,
                                          _("Meta-information"),
                                          _("Album/movie/show title" ) );
@@ -179,7 +196,7 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
 
 #define insertstrlen( psz ) \
 { \
-    uint16_t i_size = htons(strlen( psz )); \
+    uint16_t i_size = strlen( psz ); \
     psz_encoded[i++] = (i_size>>8)&0xFF; \
     psz_encoded[i++] = i_size&0xFF; \
 }
@@ -235,7 +252,7 @@ static int NotifyToGrowl( vlc_object_t *p_this, char *psz_type,
     memset( psz_encoded, 0, sizeof(psz_encoded) );
     psz_encoded[i++] = GROWL_PROTOCOL_VERSION;
     psz_encoded[i++] = GROWL_TYPE_NOTIFICATION;
-    flags = htons(0);
+    flags = 0;
     psz_encoded[i++] = (flags>>8)&0xFF;
     psz_encoded[i++] = flags&0xFF;
     insertstrlen(psz_type);
@@ -274,7 +291,7 @@ static int CheckAndSend( vlc_object_t *p_this, uint8_t* p_data, int i_offset )
 
     for( i = 0 ; i < 4 ; i++ )
     {
-        md5.p_digest[i] = htonl(md5.p_digest[i]);
+        md5.p_digest[i] = md5.p_digest[i];
         p_data[i_offset++] =  md5.p_digest[i]     &0xFF;
         p_data[i_offset++] = (md5.p_digest[i]>> 8)&0xFF;
         p_data[i_offset++] = (md5.p_digest[i]>>16)&0xFF;