[vlc-commits] demux: playlist: accept stream_t * in helper macros
Rémi Denis-Courmont
git at videolan.org
Sat Jun 3 20:47:38 CEST 2017
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon May 22 19:46:44 2017 +0300| [d39235e020702509d3eed800b9ee1c3342fbffcb] | committer: Rémi Denis-Courmont
demux: playlist: accept stream_t * in helper macros
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d39235e020702509d3eed800b9ee1c3342fbffcb
---
modules/demux/playlist/playlist.c | 2 +-
modules/demux/playlist/playlist.h | 17 ++++++++++++-----
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/modules/demux/playlist/playlist.c b/modules/demux/playlist/playlist.c
index 8bb844999b..a178472fb0 100644
--- a/modules/demux/playlist/playlist.c
+++ b/modules/demux/playlist/playlist.c
@@ -166,7 +166,7 @@ int Control(demux_t *demux, int query, va_list args)
*
* Rebuilds the base URL for the playlist.
*/
-char *FindPrefix(demux_t *p_demux)
+char *(FindPrefix)(demux_t *p_demux)
{
char *url;
diff --git a/modules/demux/playlist/playlist.h b/modules/demux/playlist/playlist.h
index 283ccdee44..2d5e6f71a6 100644
--- a/modules/demux/playlist/playlist.h
+++ b/modules/demux/playlist/playlist.h
@@ -22,6 +22,7 @@
*****************************************************************************/
#include <vlc_input.h>
+#include <vlc_demux.h>
int Control(demux_t *, int, va_list);
char *ProcessMRL( const char *, const char * );
@@ -67,18 +68,24 @@ void Close_WPL ( vlc_object_t * );
int Import_Dir ( vlc_object_t * );
-static inline input_item_t * GetCurrentItem(demux_t *p_demux)
-{
- return input_GetItem( p_demux->p_input );
-}
+#define GetCurrentItem(obj) input_GetItem((obj)->p_input)
+#define GetSource(obj) \
+ (_Generic((obj), \
+ demux_t *: ((demux_t *)(obj))->s, \
+ stream_t *: ((stream_t *)(obj))->p_source))
#define CHECK_FILE(obj) \
do { \
- if( vlc_stream_Control( (obj)->s, \
+ if( vlc_stream_Control( GetSource(obj), \
STREAM_IS_DIRECTORY ) == VLC_SUCCESS ) \
return VLC_EGENERIC; \
} while(0)
+#define FindPrefix(obj) \
+ (_Generic((obj), \
+ demux_t *: FindPrefix((demux_t *)(obj)), \
+ stream_t *: strdup(((stream_t *)(obj))->psz_url)))
+
#define STANDARD_DEMUX_INIT_MSG( msg ) do { \
DEMUX_INIT_COMMON(); \
msg_Dbg( p_demux, "%s", msg ); } while(0)
More information about the vlc-commits
mailing list