vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Tue Sep 1 23:26:58 2015 +0300| [994a2555f0c2fe15396d28f53261527d9ad20be5] | committer: Rémi Denis-Courmont
stream: put stream_Seek() out of line > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=994a2555f0c2fe15396d28f53261527d9ad20be5 --- include/vlc_stream.h | 14 ++++++++------ src/input/stream.c | 43 +++++++++++++++++++++++-------------------- src/libvlccore.sym | 1 + 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/include/vlc_stream.h b/include/vlc_stream.h index ba642ff..597b29c 100644 --- a/include/vlc_stream.h +++ b/include/vlc_stream.h @@ -82,7 +82,6 @@ enum stream_query_e STREAM_CAN_PAUSE, /**< arg1= bool * res=cannot fail*/ STREAM_CAN_CONTROL_PACE, /**< arg1= bool * res=cannot fail*/ /* */ - STREAM_SET_POSITION, /**< arg1= uint64_t res=can fail */ STREAM_GET_SIZE=6, /**< arg1= uint64_t * res=can fail */ STREAM_IS_DIRECTORY, /**< arg1= bool *, arg2= bool *, arg3=bool *, res=cannot fail*/ @@ -148,6 +147,14 @@ VLC_API ssize_t stream_Peek(stream_t *, const uint8_t **, size_t) VLC_USED; */ VLC_API uint64_t stream_Tell(const stream_t *) VLC_USED; +/** + * Sets the current stream position. + * + * @param offset byte offset from the beginning of the stream + * @return zero on success, a negative value on error + */ +VLC_API int stream_Seek(stream_t *, uint64_t offset) VLC_USED; + VLC_API int stream_vaControl( stream_t *s, int i_query, va_list args ); VLC_API void stream_Delete( stream_t *s ); VLC_API int stream_Control( stream_t *s, int i_query, ... ); @@ -174,11 +181,6 @@ static inline int64_t stream_Size( stream_t *s ) return i_pos; } -static inline int stream_Seek( stream_t *s, uint64_t i_pos ) -{ - return stream_Control( s, STREAM_SET_POSITION, i_pos ); -} - /** * Get the Content-Type of a stream, or NULL if unknown. * Result must be free()'d. diff --git a/src/input/stream.c b/src/input/stream.c index c098a88..0c412c8 100644 --- a/src/input/stream.c +++ b/src/input/stream.c @@ -445,6 +445,29 @@ uint64_t stream_Tell(const stream_t *s) return pos; } +int stream_Seek(stream_t *s, uint64_t offset) +{ + stream_priv_t *priv = (stream_priv_t *)s; + + if (s->pf_seek == NULL) + return VLC_EGENERIC; + + int ret = s->pf_seek(s, offset); + if (ret != VLC_SUCCESS) + return ret; + + priv->offset = offset; + + block_t *peek = priv->peek; + if (peek != NULL) + { + priv->peek = NULL; + block_Release(peek); + } + + return ret; +} + static int stream_ControlInternal(stream_t *s, int cmd, ...) { va_list ap; @@ -467,26 +490,6 @@ int stream_vaControl(stream_t *s, int cmd, va_list args) switch (cmd) { - case STREAM_SET_POSITION: - { - uint64_t pos = va_arg(args, uint64_t); - - if (s->pf_seek == NULL) - return VLC_EGENERIC; - - int ret = s->pf_seek(s, pos); - if (ret != VLC_SUCCESS) - return ret; - - if (priv->peek != NULL) - { - block_Release(priv->peek); - priv->peek = NULL; - } - priv->offset = pos; - return VLC_SUCCESS; - } - case STREAM_GET_PRIVATE_BLOCK: { block_t **b = va_arg(args, block_t **); diff --git a/src/libvlccore.sym b/src/libvlccore.sym index 2e914db..372b312 100644 --- a/src/libvlccore.sym +++ b/src/libvlccore.sym @@ -403,6 +403,7 @@ stream_MemoryNew stream_Peek stream_Read stream_ReadLine +stream_Seek stream_Tell stream_UrlNew stream_vaControl _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
