vlc/vlc-2.0 | branch: master | Rémi Denis-Courmont <[email protected]> | Sun Mar 
18 19:53:39 2012 +0200| [2882b9ff2164f4298520c8c15b4809788a938e9b] | committer: 
Rémi Denis-Courmont

PulseAudio: update existing item rather than delete and replace

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.
(cherry picked from commit 5678c1900b38babcbdf453fcbf3ee4f9a863e594)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=2882b9ff2164f4298520c8c15b4809788a938e9b
---

 modules/services_discovery/pulse.c |   17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/modules/services_discovery/pulse.c 
b/modules/services_discovery/pulse.c
index 0694cba..0b81950 100644
--- a/modules/services_discovery/pulse.c
+++ b/modules/services_discovery/pulse.c
@@ -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;
     }
 
     const char *card = pa_proplist_gets(info->proplist, "device.product.name");

_______________________________________________
vlc-commits mailing list
[email protected]
http://mailman.videolan.org/listinfo/vlc-commits

Reply via email to