[vlc-commits] stream: make stream_t.p_sys void * (refs #17078)

Rémi Denis-Courmont git at videolan.org
Wed Jul 20 23:06:54 CEST 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jul 18 20:38:54 2016 +0300| [676b185957ebb0ace208402a6d1e5bde10897451] | committer: Rémi Denis-Courmont

stream: make stream_t.p_sys void * (refs #17078)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=676b185957ebb0ace208402a6d1e5bde10897451
---

 include/vlc_stream.h            |    2 +-
 modules/access/archive/stream.c |    8 +++++---
 modules/access/rar/stream.c     |   22 +++++-----------------
 modules/stream_filter/hds/hds.c |    4 ++--
 modules/stream_filter/record.c  |    3 ++-
 5 files changed, 15 insertions(+), 24 deletions(-)

diff --git a/include/vlc_stream.h b/include/vlc_stream.h
index c304bf4..8f66d5f 100644
--- a/include/vlc_stream.h
+++ b/include/vlc_stream.h
@@ -62,7 +62,7 @@ struct stream_t
     int         (*pf_control)( stream_t *, int i_query, va_list );
 
     /* Private data for module */
-    stream_sys_t *p_sys;
+    void *p_sys;
 
     /* Weak link to parent input */
     input_thread_t *p_input;
diff --git a/modules/access/archive/stream.c b/modules/access/archive/stream.c
index 05d1ec1..720a0a1 100644
--- a/modules/access/archive/stream.c
+++ b/modules/access/archive/stream.c
@@ -66,19 +66,21 @@ static ssize_t ReadCallback(struct archive *p_archive, void *p_object, const voi
 {
     VLC_UNUSED(p_archive);
     stream_t *p_stream = (stream_t*)p_object;
+    stream_sys_t *sys = p_stream->p_sys;
 
-    *pp_buffer = &p_stream->p_sys->buffer;
-    return stream_Read(p_stream->p_source, &p_stream->p_sys->buffer, ARCHIVE_READ_SIZE);
+    *pp_buffer = &sys->buffer;
+    return stream_Read(p_stream->p_source, &sys->buffer, ARCHIVE_READ_SIZE);
 }
 
 static ssize_t SkipCallback(struct archive *p_archive, void *p_object, ssize_t i_request)
 {
     VLC_UNUSED(p_archive);
     stream_t *p_stream = (stream_t*)p_object;
+    stream_sys_t *sys = p_stream->p_sys;
     ssize_t i_skipped = 0;
 
     /* be smart as small seeks converts to reads */
-    if (p_stream->p_sys->b_source_canseek)
+    if (sys->b_source_canseek)
     {
         int64_t i_pos = stream_Tell(p_stream->p_source);
         if (i_pos >=0)
diff --git a/modules/access/rar/stream.c b/modules/access/rar/stream.c
index 2b90fa6..9fc62ad 100644
--- a/modules/access/rar/stream.c
+++ b/modules/access/rar/stream.c
@@ -35,18 +35,14 @@
 
 #include "rar.h"
 
-struct stream_sys_t {
-    stream_t *payload;
-};
-
 static ssize_t Read(stream_t *s, void *data, size_t size)
 {
-    return stream_Read(s->p_sys->payload, data, size);
+    return stream_Read(s->p_sys, data, size);
 }
 
 static int Seek(stream_t *s, uint64_t offset)
 {
-    return stream_Seek(s->p_sys->payload, offset);
+    return stream_Seek(s->p_sys, offset);
 }
 
 static int Control(stream_t *s, int query, va_list args)
@@ -58,7 +54,7 @@ static int Control(stream_t *s, int query, va_list args)
         return VLC_SUCCESS;
     }
     default:
-        return stream_vaControl(s->p_sys->payload, query, args);
+        return stream_vaControl(s->p_sys, query, args);
     }
 }
 
@@ -145,13 +141,7 @@ int RarStreamOpen(vlc_object_t *object)
     s->pf_read = Read;
     s->pf_seek = Seek;
     s->pf_control = Control;
-
-    stream_sys_t *sys = s->p_sys = malloc(sizeof(*sys));
-    if (!sys) {
-        stream_Delete(payload);
-        return VLC_ENOMEM;
-    }
-    sys->payload = payload;
+    s->p_sys = payload;
 
     char *tmp;
     if (asprintf(&tmp, "%s.m3u", s->psz_url) < 0) {
@@ -167,8 +157,6 @@ int RarStreamOpen(vlc_object_t *object)
 void RarStreamClose(vlc_object_t *object)
 {
     stream_t *s = (stream_t*)object;
-    stream_sys_t *sys = s->p_sys;
 
-    stream_Delete(sys->payload);
-    free(sys);
+    stream_Delete(s->p_sys);
 }
diff --git a/modules/stream_filter/hds/hds.c b/modules/stream_filter/hds/hds.c
index 0bc7a39..588d72b 100644
--- a/modules/stream_filter/hds/hds.c
+++ b/modules/stream_filter/hds/hds.c
@@ -1692,7 +1692,7 @@ static void Close( vlc_object_t *p_this )
 
     // TODO: Change here for selectable stream
     hds_stream_t *stream = vlc_array_count(p_sys->hds_streams) ?
-        s->p_sys->hds_streams->pp_elems[0] : NULL;
+        p_sys->hds_streams->pp_elems[0] : NULL;
 
     p_sys->closed = true;
     if (stream)
@@ -1839,7 +1839,7 @@ static ssize_t Read( stream_t *s, void *buffer, size_t i_read )
         return 0;
 
     // TODO: change here for selectable stream
-    hds_stream_t *stream = s->p_sys->hds_streams->pp_elems[0];
+    hds_stream_t *stream = p_sys->hds_streams->pp_elems[0];
 
     if ( header_unfinished( p_sys ) )
         return send_flv_header( stream, p_sys, buffer, i_read );
diff --git a/modules/stream_filter/record.c b/modules/stream_filter/record.c
index 73dcccc..fe44b94 100644
--- a/modules/stream_filter/record.c
+++ b/modules/stream_filter/record.c
@@ -147,12 +147,13 @@ static int Control( stream_t *s, int i_query, va_list args )
     if( i_query != STREAM_SET_RECORD_STATE )
         return stream_vaControl( s->p_source, i_query, args );
 
+    stream_sys_t *sys = s->p_sys;
     bool b_active = (bool)va_arg( args, int );
     const char *psz_extension = NULL;
     if( b_active )
         psz_extension = (const char*)va_arg( args, const char* );
 
-    if( !s->p_sys->f == !b_active )
+    if( !sys->f == !b_active )
         return VLC_SUCCESS;
 
     if( b_active )



More information about the vlc-commits mailing list