[vlc-commits] input: add vlc_stream_CustomNew() and vlc_stream_Private()
Rémi Denis-Courmont
git at videolan.org
Fri Apr 6 20:05:00 CEST 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Apr 6 20:05:21 2018 +0300| [c89e49dedef2be48abce864bcd70a2605f4e2f1b] | committer: Rémi Denis-Courmont
input: add vlc_stream_CustomNew() and vlc_stream_Private()
These two functions allow setting the object type name for the stream
object, and allocating type-specific private data.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c89e49dedef2be48abce864bcd70a2605f4e2f1b
---
src/input/stream.c | 22 +++++++++++++++++++---
src/input/stream.h | 5 +++++
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/src/input/stream.c b/src/input/stream.c
index e79a752d7d..6b1d69eadd 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -27,6 +27,7 @@
#endif
#include <assert.h>
+#include <stdalign.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
@@ -58,15 +59,19 @@ typedef struct stream_priv_t
unsigned char char_width;
bool little_endian;
} text;
+
+ max_align_t private_data[];
} stream_priv_t;
/**
* Allocates a VLC stream object
*/
-stream_t *vlc_stream_CommonNew(vlc_object_t *parent,
- void (*destroy)(stream_t *))
+stream_t *vlc_stream_CustomNew(vlc_object_t *parent,
+ void (*destroy)(stream_t *), size_t size,
+ const char *type_name)
{
- stream_priv_t *priv = vlc_custom_create(parent, sizeof (*priv), "stream");
+ stream_priv_t *priv = vlc_custom_create(parent, sizeof (*priv) + size,
+ type_name);
if (unlikely(priv == NULL))
return NULL;
@@ -97,6 +102,17 @@ stream_t *vlc_stream_CommonNew(vlc_object_t *parent,
return s;
}
+void *vlc_stream_Private(stream_t *stream)
+{
+ return ((stream_priv_t *)stream)->private_data;
+}
+
+stream_t *vlc_stream_CommonNew(vlc_object_t *parent,
+ void (*destroy)(stream_t *))
+{
+ return vlc_stream_CustomNew(parent, destroy, 0, "stream");
+}
+
void stream_CommonDelete(stream_t *s)
{
stream_priv_t *priv = (stream_priv_t *)s;
diff --git a/src/input/stream.h b/src/input/stream.h
index 0ea78b8c00..025d7e1795 100644
--- a/src/input/stream.h
+++ b/src/input/stream.h
@@ -28,6 +28,11 @@
#include <vlc_common.h>
#include <vlc_stream.h>
+stream_t *vlc_stream_CustomNew(vlc_object_t *parent,
+ void (*destroy)(stream_t *), size_t extra_size,
+ const char *type_name);
+void *vlc_stream_Private(stream_t *stream);
+
/* */
void stream_CommonDelete( stream_t *s );
More information about the vlc-commits
mailing list