[vlc-commits] HLS: clean Read function
Frédéric Yhuel
git at videolan.org
Tue Feb 7 12:12:13 CET 2012
vlc/vlc-2.0 | branch: master | Frédéric Yhuel <fyhuel at viotech.net> | Wed Feb 1 13:04:48 2012 +0100| [a6d6d948c322258ae8e2b4be91d8b8a6d02c1f58] | committer: Jean-Baptiste Kempf
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: Jean-Paul Saman <jpsaman at videolan.org>
(cherry picked from commit 6fe18b3e023d1c58571d982cc41b43363c45cfae)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=a6d6d948c322258ae8e2b4be91d8b8a6d02c1f58
---
modules/stream_filter/httplive.c | 13 +++----------
1 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index ebea61d..c03061b 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -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,7 +2241,8 @@ static ssize_t hls_Read(stream_t *s, uint8_t *p_read, unsigned int i_read)
if (len > 0)
{
- memcpy(p_read + copied, segment->data->p_buffer, len);
+ 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;
copied += 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;
More information about the vlc-commits
mailing list