Commit 994a2555 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

stream: put stream_Seek() out of line

parent b1082a5c
......@@ -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.
......
......@@ -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 **);
......
......@@ -403,6 +403,7 @@ stream_MemoryNew
stream_Peek
stream_Read
stream_ReadLine
stream_Seek
stream_Tell
stream_UrlNew
stream_vaControl
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment