[vlc-commits] stream: merge access_t and stream_t
Rémi Denis-Courmont
git at videolan.org
Thu Jul 21 21:30:19 CEST 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jul 18 20:47:31 2016 +0300| [38be0d228ccc3559799330c2b21a361fa0692703] | committer: Rémi Denis-Courmont
stream: merge access_t and stream_t
They were mostly identical, with just a few extra fields in access_t.
Merging them will allow removing the dummy stream_Access layer.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=38be0d228ccc3559799330c2b21a361fa0692703
---
include/vlc_access.h | 144 +++-----------------------------------------------
include/vlc_common.h | 2 +-
include/vlc_stream.h | 6 ++-
src/input/access.c | 29 ++++------
src/input/stream.c | 1 +
src/libvlccore.sym | 1 -
6 files changed, 24 insertions(+), 159 deletions(-)
diff --git a/include/vlc_access.h b/include/vlc_access.h
index a211d55..f3574ef 100644
--- a/include/vlc_access.h
+++ b/include/vlc_access.h
@@ -35,44 +35,6 @@
* Input byte stream modules interface
*/
-struct access_t
-{
- VLC_COMMON_MEMBERS
-
- /* Module properties */
- module_t *p_module;
-
- char *psz_name; /**< Access name */
- char *psz_url; /**< Full URL or MRL */
- const char *psz_location; /**< Location (URL with the scheme stripped) */
- char *psz_filepath; /**< Local file path (if applicable) */
- bool b_preparsing; /**< True if this access is used to preparse */
-
- /* pf_read/pf_block/pf_readdir is used to read data.
- * XXX A access should set one and only one of them */
- ssize_t (*pf_read) ( access_t *, void *, size_t ); /* Return -1 if no data yet, 0 if no more data, else real data read */
- block_t *(*pf_block) ( access_t *, bool * ); /* Return a block of data in his 'natural' size, NULL if not yet data or eof */
- int (*pf_readdir)( access_t *, input_item_node_t * );/* Fills the provided item_node, see doc/browsing.txt for details */
-
- /* Called for each seek.
- * XXX can be null */
- int (*pf_seek) ( access_t *, uint64_t ); /* can be null if can't seek */
-
- /* Used to retrieve and configure the access
- * XXX mandatory. look at stream_query_e to know what query you *have to* support */
- int (*pf_control)( access_t *, int i_query, va_list args);
-
- /* Access has to maintain them uptodate */
- struct
- {
- bool b_eof; /* idem */
- } info;
- void *p_sys;
-
- /* Weak link to parent input */
- input_thread_t *p_input;
-};
-
/**
* Special redirection error code.
*
@@ -94,113 +56,23 @@ struct access_t
*/
VLC_API access_t *vlc_access_NewMRL(vlc_object_t *obj, const char *mrl);
-/**
- * Closes a byte stream.
- * \param access byte stream to close
- */
-VLC_API void vlc_access_Delete(access_t *access);
+#define vlc_access_Delete vlc_stream_Delete
/**
* Sets the read byte offset.
*/
-static inline int vlc_access_Seek(access_t *access, uint64_t offset)
-{
- int ret = VLC_EGENERIC;
-
- if (access->pf_seek != NULL)
- ret = access->pf_seek(access, offset);
- if (ret == VLC_SUCCESS)
- access->info.b_eof = false;
- return ret;
-}
+#define vlc_access_Seek vlc_stream_Seek
/**
* Checks if end-of-stream is reached.
*/
-static inline bool vlc_access_Eof(const access_t *access)
-{
- return access->info.b_eof;
-}
-
-/**
- * Reads a byte stream.
- *
- * This function waits for some data to be available (if necessary) and returns
- * available data (up to the requested size). Not all byte streams support
- * this. Some streams must be read with vlc_access_Block() instead.
- *
- * \note
- * A short read does <b>not</b> imply the end of the stream. It merely implies
- * that enough data is not immediately available.
- * To detect the end of the stream, either check if the function returns zero,
- * or call vlc_access_Eof().
- *
- * \note
- * The function may return a negative value spuriously. Negative error values
- * should be ignored; they do not necessarily indicate a fatal error.
- *
- * \param buf buffer to read data into
- * \param len size of the buffer in bytes
- * \return the number of bytes read (possibly less than requested),
- * zero at end-of-stream, or -1 on <b>transient</b> errors
- */
-static inline ssize_t vlc_access_Read(access_t *access, void *buf, size_t len)
-{
- int ret = -1;
-
- if (access->pf_read != NULL)
- ret = access->pf_read(access, buf, len);
- if (len > 0 && ret == 0)
- access->info.b_eof = true;
- return ret;
-}
-
-/**
- * Dequeues one block of data.
- *
- * This function waits for a block of data to be available (if necessary) and
- * returns a reference to it. Not all byte streams support this. Some streams
- * must be read with vlc_access_Read() instead.
- *
- * \note
- * The returned block may be of any size. The size is dependent on the
- * underlying implementation of the byte stream.
- *
- * \note
- * The function may return NULL spuriously. A NULL return is not indicative of
- * a fatal error.
- *
- * \return a data block (free with block_Release()) or NULL
- */
-static inline block_t *vlc_access_Block(access_t *access)
-{
- if (access->pf_block == NULL)
- return NULL;
-
- return access->pf_block(access, &access->info.b_eof);
-}
-
-static inline int access_vaControl( access_t *p_access, int i_query, va_list args )
-{
- if( !p_access ) return VLC_EGENERIC;
- return p_access->pf_control( p_access, i_query, args );
-}
+#define vlc_access_Eof vlc_stream_Eof
-static inline int access_Control( access_t *p_access, int i_query, ... )
-{
- va_list args;
- int i_result;
-
- va_start( args, i_query );
- i_result = access_vaControl( p_access, i_query, args );
- va_end( args );
- return i_result;
-}
-
-static inline int access_GetSize( access_t *p_access, uint64_t *size )
-{
- return access_Control( p_access, STREAM_GET_SIZE, size );
-}
+#define vlc_access_Read vlc_stream_ReadPartial
+#define vlc_access_Block vlc_stream_ReadBlock
+#define access_vaControl vlc_stream_vaControl
+#define access_Control vlc_stream_Control
+#define access_GetSize stream_GetSize
/**
* \defgroup access_helper Access Helpers
diff --git a/include/vlc_common.h b/include/vlc_common.h
index 74171c5..5a6bf19 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -221,7 +221,7 @@ typedef struct config_category_t config_category_t;
typedef struct input_thread_t input_thread_t;
typedef struct input_item_t input_item_t;
typedef struct input_item_node_t input_item_node_t;
-typedef struct access_t access_t;
+typedef struct stream_t access_t;
typedef struct access_sys_t access_sys_t;
typedef struct stream_t stream_t;
typedef struct stream_sys_t stream_sys_t;
diff --git a/include/vlc_stream.h b/include/vlc_stream.h
index 37f7182..2095729 100644
--- a/include/vlc_stream.h
+++ b/include/vlc_stream.h
@@ -50,7 +50,11 @@ struct stream_t
/* Module properties for stream filter */
module_t *p_module;
- char *psz_url;
+ char *psz_name;
+ char *psz_url; /**< Full URL or MRL */
+ const char *psz_location; /**< Location (URL with the scheme stripped) */
+ char *psz_filepath; /**< Local file path (if applicable) */
+ bool b_preparsing; /**< True if this access is used to preparse */
/* Stream source for stream filter */
stream_t *p_source;
diff --git a/src/input/access.c b/src/input/access.c
index cc6d625..6369075 100644
--- a/src/input/access.c
+++ b/src/input/access.c
@@ -55,6 +55,13 @@ char *get_path(const char *location)
return path;
}
+static void vlc_access_Destroy(stream_t *access)
+{
+ module_unneed(access, access->p_module);
+ free(access->psz_filepath);
+ free(access->psz_name);
+}
+
#define MAX_REDIR 5
/*****************************************************************************
@@ -66,7 +73,7 @@ static access_t *access_New(vlc_object_t *parent, input_thread_t *input,
char *redirv[MAX_REDIR];
unsigned redirc = 0;
- access_t *access = vlc_custom_create(parent, sizeof (*access), "access");
+ stream_t *access = vlc_stream_CommonNew(parent, vlc_access_Destroy);
if (unlikely(access == NULL))
return NULL;
@@ -74,14 +81,7 @@ static access_t *access_New(vlc_object_t *parent, input_thread_t *input,
access->psz_name = NULL;
access->psz_url = strdup(mrl);
access->psz_filepath = NULL;
- access->pf_read = NULL;
- access->pf_block = NULL;
- access->pf_readdir = NULL;
- access->pf_seek = NULL;
- access->pf_control = NULL;
- access->p_sys = NULL;
access->b_preparsing = preparsing;
- access->info.b_eof = false;
if (unlikely(access->psz_url == NULL))
goto error;
@@ -135,9 +135,8 @@ error:
while (redirc > 0)
free(redirv[--redirc]);
free(access->psz_filepath);
- free(access->psz_url);
free(access->psz_name);
- vlc_object_release(access);
+ stream_CommonDelete(access);
return NULL;
}
@@ -146,16 +145,6 @@ access_t *vlc_access_NewMRL(vlc_object_t *parent, const char *mrl)
return access_New(parent, NULL, false, mrl);
}
-void vlc_access_Delete(access_t *access)
-{
- module_unneed(access, access->p_module);
-
- free(access->psz_filepath);
- free(access->psz_url);
- free(access->psz_name);
- vlc_object_release(access);
-}
-
/*****************************************************************************
* access_vaDirectoryControlHelper:
*****************************************************************************/
diff --git a/src/input/stream.c b/src/input/stream.c
index 3dbc8e7..8a1027f 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -76,6 +76,7 @@ stream_t *vlc_stream_CommonNew(vlc_object_t *parent,
s->pf_read = NULL;
s->pf_block = NULL;
s->pf_readdir = NULL;
+ s->pf_seek = NULL;
s->pf_control = NULL;
s->p_sys = NULL;
s->p_input = NULL;
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 79064d3..b5193c5 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -1,6 +1,5 @@
access_vaDirectoryControlHelper
vlc_access_NewMRL
-vlc_access_Delete
access_fsdir_init
access_fsdir_finish
access_fsdir_additem
More information about the vlc-commits
mailing list