Commit 5678c190 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.
parent 6707159e
......@@ -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;
......
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