]> git.sesse.net Git - vlc/commitdiff
PulseAudio: update existing item rather than delete and replace
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 18 Mar 2012 17:53:39 +0000 (19:53 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 18 Mar 2012 17:55:14 +0000 (19:55 +0200)
This avoids the infamous VLC playlist bug whereby the playlist stops if
the current item is deleted. It turns out PulseAudio tends to "update"
a source right after VLC opens it, and then VLC stopped playing almost
as soon as it started.

modules/services_discovery/pulse.c

index 725580df80857f24ea9ab310b7570becaf5a37aa..87076a66912e6e7257c94d2d31ccf77033848462 100644 (file)
@@ -119,8 +119,7 @@ static void DestroySource (void *data)
 {
     struct device *d = data;
 
-    if (d->sd)
-        services_discovery_RemoveItem (d->sd, d->item);
+    services_discovery_RemoveItem (d->sd, d->item);
     vlc_gc_decref (d->item);
     free (d);
 }
@@ -164,18 +163,22 @@ static int AddSource (services_discovery_t *sd, const pa_source_info *info)
     }
     d->index = info->index;
     d->item = item;
-    d->sd = NULL;
 
     struct device **dp = tsearch (d, &sys->root, cmpsrc);
     if (dp == NULL) /* Out-of-memory */
     {
-        DestroySource (d);
+        free (d);
+        vlc_gc_decref (item);
         return -1;
     }
-    if (*dp != d) /* Replace existing source */
+    if (*dp != d) /* Update existing source */
     {
-        DestroySource (*dp);
-        *dp = d;
+        free (d);
+        d = *dp;
+        input_item_SetURI (d->item, item->psz_uri);
+        input_item_SetName (d->item, item->psz_name);
+        vlc_gc_decref (item);
+        return 0;
     }
 
     char *card;