]> git.sesse.net Git - vlc/commitdiff
* DAAP: add meta-information, delete hosts when they leave
authorClément Stenac <zorglub@videolan.org>
Sun, 16 Jan 2005 14:44:26 +0000 (14:44 +0000)
committerClément Stenac <zorglub@videolan.org>
Sun, 16 Jan 2005 14:44:26 +0000 (14:44 +0000)
* SAP : coding style fixes
* Some fogotten playlist_*Info

modules/gui/macosx/playlist.m
modules/gui/macosx/playlistinfo.m
modules/gui/wince/playlist.cpp
modules/misc/playlist/m3u.c
modules/services_discovery/daap.c
modules/services_discovery/sap.c
src/playlist/view.c

index 2ae7e58abe25d162f87082043e0e20f1bfb2b5b0..fc354a0803b31a3c769639d7d363ff70d9f0f10d 100644 (file)
@@ -670,7 +670,8 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
         vlc_mutex_lock( &p_playlist->object_lock );
         o_current_name = [NSString stringWithUTF8String:
             p_item->pp_children[i_current]->input.psz_name];
-        psz_temp = playlist_ItemGetInfo(p_item ,_("Meta-information"),_("Author") );
+        psz_temp = vlc_input_item_GetInfo(&p_item->input ,
+                                  _("Meta-information"),_("Author") );
         o_current_author = [NSString stringWithUTF8String: psz_temp];
         free( psz_temp);
         vlc_mutex_unlock( &p_playlist->object_lock );
@@ -1003,7 +1004,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
     else if( [[o_tc identifier] isEqualToString:@"2"] )
     {
         char *psz_temp;
-        psz_temp = playlist_ItemGetInfo( p_item ,_("Meta-information"),_("Artist") );
+        psz_temp = vlc_input_item_GetInfo( &p_item->input ,_("Meta-information"),_("Artist") );
 
         if( psz_temp == NULL )
             o_value = @"";
index 9efbbe10fb80aaa994b3e7933b42cc7d886c5d77..4eff7b64117f7ee3aeba4c8137df831ff6cb6e67 100644 (file)
             [NSString stringWithUTF8String:p_item->input.psz_name]];
     }
 
-    psz_temp = playlist_ItemGetInfo( p_item, _("General"), _("Author") );
+    psz_temp = vlc_input_item_GetInfo( &p_item->input, _("General"), _("Author") );
     vlc_mutex_unlock( &p_item->input.lock );
 
     if( psz_temp )
index 0ee15539868e5bae028b3d7b930718bca9414b98..559dbc5a84f0ceb6ea95f6c7159e92c1c65570cb 100644 (file)
@@ -613,7 +613,7 @@ void Playlist::UpdateItem( int i )
 
     ListView_SetItemText( hListView, i, 0, _FROMMB(p_item->input.psz_name) );
     ListView_SetItemText( hListView, i, 1,
-                          _FROMMB( playlist_ItemGetInfo( p_item,
+                          _FROMMB( vlc_input_item_GetInfo( &p_item->input,
                                    _("General") , _("Author") ) ) );
 
     char psz_duration[MSTRTIME_MAX_SIZE];
index d3d2e7becb9892a57a932ca7a6ae3abf528f5219..2862adaef671b79c14f863018c5a733c5bb119d5 100644 (file)
@@ -64,7 +64,8 @@ int Export_M3U( vlc_object_t *p_this )
                     p_playlist->pp_items[i]->input.psz_uri ) )
         {
             char *psz_author =
-               playlist_GetInfo( p_playlist, i, _("General"), _("Author") );
+                   vlc_input_item_GetInfo( &p_playlist->pp_items[i]->input,
+                                         _("General"), _("Author") );
 
             fprintf( p_export->p_file, "#EXTINF:%i,%s,%s\n",
                      (int)(p_playlist->pp_items[i]->input.i_duration/1000000),
index 947d02a2edfbf7993b79ee96e5e664e38d3449ef..930817bcd421a2dc9654325263cdf7d292c63b77 100644 (file)
@@ -454,11 +454,27 @@ static void OnHostsUpdate( services_discovery_t *p_sd )
 {
     int i;
 
+    for( i = 0 ; i< p_sd->p_sys->p_db->i_hosts ; i ++ )
+    {
+        p_sd->p_sys->p_db->pp_hosts[i]->b_updated = VLC_FALSE;
+        p_sd->p_sys->p_db->pp_hosts[i]->b_new     = VLC_FALSE;
+    }
+
     vlc_mutex_lock( &p_sd->p_sys->p_db->search_lock );
     DAAP_Client_EnumerateHosts( p_sd->p_sys->p_client, EnumerateCallback, p_sd);
+
+    for( i = 0 ; i< p_sd->p_sys->p_db->i_hosts ; i ++ )
+    {
+        if( p_sd->p_sys->p_db->pp_hosts[i]->b_updated == VLC_FALSE )
+        {
+            host_t *p_host = p_sd->p_sys->p_db->pp_hosts[i];
+            FreeHost( p_sd, p_host );
+            REMOVE_ELEM( p_sd->p_sys->p_db->pp_hosts,
+                         p_sd->p_sys->p_db->i_hosts, i );
+        }
+    }
     vlc_mutex_unlock( &p_sd->p_sys->p_db->search_lock );
 
-    /* FIXME: Handle the list better: remove old hosts, ... */
     for( i = 0 ; i< p_sd->p_sys->p_db->i_hosts ; i ++ )
     {
         if( p_sd->p_sys->p_db->pp_hosts[i]->b_new )
@@ -585,6 +601,10 @@ static void ProcessHost( services_discovery_t *p_sd, host_t *p_host )
                                                    p_host->p_songs[i].id );
         p_item = playlist_ItemNew( p_sd, psz_buff,
                                          p_host->p_songs[i].itemname );
+        vlc_input_item_AddInfo( &p_item->input, _("Meta-Information"),
+                                _("Artist"), p_host->p_songs[i].songartist );
+        vlc_input_item_AddInfo( &p_item->input, _("Meta-Information"),
+                                _("Album"), p_host->p_songs[i].songalbum );
 
         playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY,
                               p_host->p_node, PLAYLIST_APPEND, PLAYLIST_END );
@@ -598,11 +618,21 @@ static void ProcessHost( services_discovery_t *p_sd, host_t *p_host )
 
 static void FreeHost( services_discovery_t *p_sd, host_t *p_host )
 {
+    playlist_t *p_playlist;
+
     if( p_host->p_host )
     {
         DAAP_ClientHost_Disconnect( p_host->p_host );
         DAAP_ClientHost_Release( p_host->p_host );
     }
 
+    p_playlist = (playlist_t *) vlc_object_find( p_sd, VLC_OBJECT_PLAYLIST,
+                                                 FIND_ANYWHERE );
+    if( p_playlist )
+    {
+        playlist_NodeDelete( p_playlist, p_host->p_node, VLC_TRUE );
+        vlc_object_release( p_playlist );
+    }
+
     if( p_host->p_songs ) free( p_host->p_songs );
 }
index fa9fb68765e54dd1fd2bbc4b906282fc263387fb..359e52e70dcba38920446acadd287440c440e236 100644 (file)
@@ -358,7 +358,6 @@ static int OpenDemux( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
-    
     /* Probe for SDP */
     if( p_demux->s )
     {
@@ -381,9 +380,8 @@ static int OpenDemux( vlc_object_t *p_this )
     {
         int i_read = stream_Read( p_demux->s,
                                   &psz_sdp[i_sdp], i_max_sdp - i_sdp - 1 );
-        
+
         if( i_read < 0 )
-            
         {
             msg_Err( p_demux, "failed to read SDP" );
             goto error;
@@ -400,27 +398,27 @@ static int OpenDemux( vlc_object_t *p_this )
         i_max_sdp += 1000;
         psz_sdp = (uint8_t*)realloc( psz_sdp, i_max_sdp );
     }
-    
+
     p_sdp = ParseSDP( VLC_OBJECT(p_demux), psz_sdp );
-    
+
     if( !p_sdp )
     {
         msg_Warn( p_demux, "invalid SDP");
         goto error;
     }
-    
+
     if( p_sdp->i_media > 1 )
     {
         goto error;
     }
-    
+
     if( ParseConnection( VLC_OBJECT( p_demux ), p_sdp ) )
     {
         p_sdp->psz_uri = NULL;
     }
     if( p_sdp->i_media_type != 33 && p_sdp->i_media_type != 32 && p_sdp->i_media_type != 14 )
         goto error;
-    
+
     if( p_sdp->psz_uri == NULL ) goto error;
 
     p_demux->p_sys = (demux_sys_t *)malloc( sizeof(demux_sys_t) );
@@ -431,7 +429,7 @@ static int OpenDemux( vlc_object_t *p_this )
     free( psz_sdp );
     if( p_sdp ) FreeSDP( p_sdp );
     return VLC_SUCCESS;
-    
+
 error:
     free( psz_sdp );
     if( p_sdp ) FreeSDP( p_sdp );
index 1cc1f1bc7a695c6b45cb9f6e5d8ccc4e94ed3a88..71554547bfbc1ebab7476b216854743ad24a0011 100644 (file)
@@ -338,7 +338,7 @@ int playlist_NodeEmpty( playlist_t *p_playlist, playlist_item_t *p_root,
         if( p_root->pp_children[i]->i_children > -1 )
         {
             playlist_NodeDelete( p_playlist, p_root->pp_children[i],
-                                b_delete_items );
+                                 b_delete_items );
         }
         else if( b_delete_items )
         {