Commit 2882b9ff authored by Rémi Denis-Courmont's avatar 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)
parent 8562754a
...@@ -119,7 +119,6 @@ static void DestroySource (void *data) ...@@ -119,7 +119,6 @@ static void DestroySource (void *data)
{ {
struct device *d = 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); vlc_gc_decref (d->item);
free (d); free (d);
...@@ -164,18 +163,22 @@ static int AddSource (services_discovery_t *sd, const pa_source_info *info) ...@@ -164,18 +163,22 @@ static int AddSource (services_discovery_t *sd, const pa_source_info *info)
} }
d->index = info->index; d->index = info->index;
d->item = item; d->item = item;
d->sd = NULL;
struct device **dp = tsearch (d, &sys->root, cmpsrc); struct device **dp = tsearch (d, &sys->root, cmpsrc);
if (dp == NULL) /* Out-of-memory */ if (dp == NULL) /* Out-of-memory */
{ {
DestroySource (d); free (d);
vlc_gc_decref (item);
return -1; return -1;
} }
if (*dp != d) /* Replace existing source */ if (*dp != d) /* Update existing source */
{ {
DestroySource (*dp); free (d);
*dp = 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"); const char *card = pa_proplist_gets(info->proplist, "device.product.name");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment