[vlc-commits] interface: clean up intf_InsertItem()
Rémi Denis-Courmont
git at videolan.org
Sat Nov 19 12:35:46 CET 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Nov 19 13:19:06 2016 +0200| [bbe53b4f49eb0ce537409643ba1b431053aaf1d2] | committer: Rémi Denis-Courmont
interface: clean up intf_InsertItem()
- Handle and report errors.
- Fix and improve documentation.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bbe53b4f49eb0ce537409643ba1b431053aaf1d2
---
src/interface/interface.c | 27 ++++++++++++++++++++++-----
src/libvlc.h | 4 ++--
2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/src/interface/interface.c b/src/interface/interface.c
index f71790b..568215f 100644
--- a/src/interface/interface.c
+++ b/src/interface/interface.c
@@ -154,15 +154,32 @@ static playlist_t *intf_GetPlaylist(libvlc_int_t *libvlc)
}
/**
- * Inserts an item in the playlist used by interfaces.
+ * Inserts an item in the playlist.
+ *
+ * This function is used during initialization. Unlike playlist_Add() and
+ * variants, it inserts an item to the beginning of the playlist. That is
+ * meant to compensate for the reverse parsing order of the command line.
+ *
* @note This function may <b>not</b> be called at the same time as
* intf_DestroyAll().
*/
-void intf_InsertItem(libvlc_int_t *libvlc, const char *mrl, unsigned optc,
- const char *const *optv, unsigned flags)
+int intf_InsertItem(libvlc_int_t *libvlc, const char *mrl, unsigned optc,
+ const char *const *optv, unsigned flags)
{
- playlist_AddExt(intf_GetPlaylist(libvlc), mrl, NULL, 0,
- 0, optc, optv, flags, true);
+ playlist_t *playlist = intf_GetPlaylist(libvlc);
+ input_item_t *item = input_item_New(mrl, NULL);
+
+ if (unlikely(item == NULL))
+ return -1;
+
+ int ret = -1;
+
+ if (input_item_AddOptions(item, optc, optv, flags) == VLC_SUCCESS
+ && playlist_AddInput(playlist, item, 0, 0, true) == VLC_SUCCESS)
+ ret = 0;
+
+ input_item_Release(item);
+ return ret;
}
void libvlc_InternalPlay(libvlc_int_t *libvlc)
diff --git a/src/libvlc.h b/src/libvlc.h
index 63d8b54..eef1d0a 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -161,8 +161,8 @@ static inline libvlc_priv_t *libvlc_priv (libvlc_int_t *libvlc)
return (libvlc_priv_t *)libvlc;
}
-void intf_InsertItem(libvlc_int_t *, const char *mrl, unsigned optc,
- const char * const *optv, unsigned flags);
+int intf_InsertItem(libvlc_int_t *, const char *mrl, unsigned optc,
+ const char * const *optv, unsigned flags);
void intf_DestroyAll( libvlc_int_t * );
#define libvlc_stats( o ) (libvlc_priv((VLC_OBJECT(o))->obj.libvlc)->b_stats)
More information about the vlc-commits
mailing list