Commit 6fe18b3e authored by Frédéric Yhuel's avatar Frédéric Yhuel Committed by Jean-Paul Saman

HLS: clean Read function

If caller wants to skip data, there is no point to allocate a buffer and
put data in it. We just have to update the stream position.
Signed-off-by: default avatarJean-Paul Saman <jpsaman@videolan.org>
parent b2ded57a
......@@ -2193,6 +2193,7 @@ static int segment_RestorePos( segment_t *segment )
return VLC_SUCCESS;
}
/* p_read might be NULL if caller wants to skip data */
static ssize_t hls_Read(stream_t *s, uint8_t *p_read, unsigned int i_read)
{
stream_sys_t *p_sys = s->p_sys;
......@@ -2240,6 +2241,7 @@ static ssize_t hls_Read(stream_t *s, uint8_t *p_read, unsigned int i_read)
if (len > 0)
{
if( p_read ) /* otherwise caller skips data */
memcpy(p_read + copied, segment->data->p_buffer, len);
segment->data->i_buffer -= len;
segment->data->p_buffer += len;
......@@ -2263,15 +2265,6 @@ static int Read(stream_t *s, void *buffer, unsigned int i_read)
if (p_sys->b_error)
return 0;
if (buffer == NULL)
{
/* caller skips data, get big enough buffer */
msg_Warn(s, "buffer is NULL (allocate %d)", i_read);
buffer = calloc(1, i_read);
if (buffer == NULL)
return 0; /* NO MEMORY left*/
}
length = hls_Read(s, (uint8_t*) buffer, i_read);
if (length < 0)
return 0;
......
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