[vlc-commits] PulseAudio: update existing item rather than delete and replace
Rémi Denis-Courmont
git at videolan.org
Sun Mar 18 18:55:21 CET 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Mar 18 19:53:39 2012 +0200| [5678c1900b38babcbdf453fcbf3ee4f9a863e594] | 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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5678c1900b38babcbdf453fcbf3ee4f9a863e594
---
modules/services_discovery/pulse.c | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/modules/services_discovery/pulse.c b/modules/services_discovery/pulse.c
index 725580d..87076a6 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;
}
char *card;
More information about the vlc-commits
mailing list