[vlc-commits] stream: remove anonymous union
Romain Vimont
git at videolan.org
Tue Jan 12 14:18:59 UTC 2021
vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Sat Oct 3 12:04:47 2020 +0200| [f66590a84a673ba0d51901fbed819ad3b7b6fea2] | committer: Thomas Guillem
stream: remove anonymous union
The two fields of the union have types demux_t and stream_t, which are
the same type (demux_t is a typedef of stream_t).
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f66590a84a673ba0d51901fbed819ad3b7b6fea2
---
include/vlc_stream.h | 27 +++++--------
modules/demux/filter/noseek.c | 6 +--
modules/stream_out/chromecast/chromecast_demux.cpp | 46 +++++++++++-----------
src/input/demux.c | 2 +-
4 files changed, 36 insertions(+), 45 deletions(-)
diff --git a/include/vlc_stream.h b/include/vlc_stream.h
index 5627545df5..2eb56868ca 100644
--- a/include/vlc_stream.h
+++ b/include/vlc_stream.h
@@ -53,24 +53,15 @@ struct stream_t
bool b_preparsing; /**< True if this access is used to preparse */
input_item_t *p_input_item;/**< Input item (can be NULL) */
- union {
- /**
- * Input stream
- *
- * Depending on the module capability:
- * - "stream filter" or "demux": input byte stream (not NULL)
- * - "access": a NULL pointer
- * - "demux_filter": undefined
- */
- stream_t *s;
- /**
- * Input demuxer
- *
- * If the module capability is "demux_filter", this is the upstream
- * demuxer or demux filter. Otherwise, this is undefined.
- */
- demux_t *p_next;
- };
+ /**
+ * Input stream
+ *
+ * Depending on the module capability:
+ * - "stream filter" or "demux": input byte stream (not NULL)
+ * - "access": a NULL pointer
+ * - "demux_filter": upstream demuxer or demux filter
+ */
+ stream_t *s;
/* es output */
es_out_t *out; /* our p_es_out */
diff --git a/modules/demux/filter/noseek.c b/modules/demux/filter/noseek.c
index 906da61f78..ed6d9ba151 100644
--- a/modules/demux/filter/noseek.c
+++ b/modules/demux/filter/noseek.c
@@ -28,7 +28,7 @@
static int Demux(demux_t *demux)
{
- return demux_Demux(demux->p_next);
+ return demux_Demux(demux->s);
}
static int Control(demux_t *demux, int query, va_list args)
@@ -48,7 +48,7 @@ static int Control(demux_t *demux, int query, va_list args)
{
unsigned *restrict pf = va_arg(args, unsigned *);
- if (demux_Control(demux->p_next, DEMUX_TEST_AND_CLEAR_FLAGS, pf))
+ if (demux_Control(demux->s, DEMUX_TEST_AND_CLEAR_FLAGS, pf))
*pf = 0;
*pf &= ~(INPUT_UPDATE_TITLE|INPUT_UPDATE_SEEKPOINT|
INPUT_UPDATE_TITLE_LIST);
@@ -56,7 +56,7 @@ static int Control(demux_t *demux, int query, va_list args)
}
default:
- return demux_vaControl(demux->p_next, query, args);
+ return demux_vaControl(demux->s, query, args);
}
return VLC_SUCCESS;
diff --git a/modules/stream_out/chromecast/chromecast_demux.cpp b/modules/stream_out/chromecast/chromecast_demux.cpp
index 6bfc4fa9b0..79c87136ba 100644
--- a/modules/stream_out/chromecast/chromecast_demux.cpp
+++ b/modules/stream_out/chromecast/chromecast_demux.cpp
@@ -56,7 +56,7 @@ struct demux_cc
vlc_meta_t *p_meta = vlc_meta_New();
if( likely(p_meta != NULL) )
{
- input_item_t *p_item = p_demux->p_next->p_input_item;
+ input_item_t *p_item = p_demux->s->p_input_item;
if( p_item )
{
/* Favor Meta from the input item of the input_thread since
@@ -81,24 +81,24 @@ struct demux_cc
}
p_renderer->pf_set_meta( p_renderer->p_opaque, p_meta );
}
- else if (demux_Control( p_demux->p_next, DEMUX_GET_META, p_meta) == VLC_SUCCESS)
+ else if (demux_Control( p_demux->s, DEMUX_GET_META, p_meta) == VLC_SUCCESS)
p_renderer->pf_set_meta( p_renderer->p_opaque, p_meta );
else
vlc_meta_Delete( p_meta );
}
- if (demux_Control( p_demux->p_next, DEMUX_CAN_SEEK, &m_can_seek ) != VLC_SUCCESS)
+ if (demux_Control( p_demux->s, DEMUX_CAN_SEEK, &m_can_seek ) != VLC_SUCCESS)
m_can_seek = false;
- if (demux_Control( p_demux->p_next, DEMUX_GET_LENGTH, &m_length ) != VLC_SUCCESS)
+ if (demux_Control( p_demux->s, DEMUX_GET_LENGTH, &m_length ) != VLC_SUCCESS)
m_length = -1;
int i_current_title;
- if( demux_Control( p_demux->p_next, DEMUX_GET_TITLE,
+ if( demux_Control( p_demux->s, DEMUX_GET_TITLE,
&i_current_title ) == VLC_SUCCESS )
{
input_title_t** pp_titles;
int i_nb_titles, i_title_offset, i_chapter_offset;
- if( demux_Control( p_demux->p_next, DEMUX_GET_TITLE_INFO, &pp_titles,
+ if( demux_Control( p_demux->s, DEMUX_GET_TITLE_INFO, &pp_titles,
&i_nb_titles, &i_title_offset,
&i_chapter_offset ) == VLC_SUCCESS )
{
@@ -123,13 +123,13 @@ struct demux_cc
if( b_is_interactive == true )
{
- demux_Control( p_demux->p_next, DEMUX_SET_TITLE,
+ demux_Control( p_demux->s, DEMUX_SET_TITLE,
i_longest_title );
}
}
}
- es_out_Control( p_demux->p_next->out, ES_OUT_RESET_PCR );
+ es_out_Control( p_demux->s->out, ES_OUT_RESET_PCR );
p_renderer->pf_set_demux_enabled(p_renderer->p_opaque, true,
on_paused_changed_cb, p_demux);
@@ -152,10 +152,10 @@ struct demux_cc
void initTimes()
{
- if( demux_Control( p_demux->p_next, DEMUX_GET_TIME, &m_start_time ) != VLC_SUCCESS )
+ if( demux_Control( p_demux->s, DEMUX_GET_TIME, &m_start_time ) != VLC_SUCCESS )
m_start_time = -1;
- if( demux_Control( p_demux->p_next, DEMUX_GET_POSITION, &m_start_pos ) != VLC_SUCCESS )
+ if( demux_Control( p_demux->s, DEMUX_GET_POSITION, &m_start_pos ) != VLC_SUCCESS )
m_start_pos = -1.0f;
m_last_time = m_start_time;
@@ -212,23 +212,23 @@ struct demux_cc
void seekBack( vlc_tick_t time, double pos )
{
- es_out_Control( p_demux->p_next->out, ES_OUT_RESET_PCR );
+ es_out_Control( p_demux->s->out, ES_OUT_RESET_PCR );
if( m_can_seek )
{
int ret = VLC_EGENERIC;
if( time >= 0 )
- ret = demux_Control( p_demux->p_next, DEMUX_SET_TIME, time, false );
+ ret = demux_Control( p_demux->s, DEMUX_SET_TIME, time, false );
if( ret != VLC_SUCCESS && pos >= 0 )
- demux_Control( p_demux->p_next, DEMUX_SET_POSITION, pos, false );
+ demux_Control( p_demux->s, DEMUX_SET_POSITION, pos, false );
}
}
int Demux()
{
if ( !m_enabled )
- return demux_Demux( p_demux->p_next );
+ return demux_Demux( p_demux->s );
/* The CC sout is not pacing, so we pace here */
int pace = p_renderer->pf_pace( p_renderer->p_opaque );
@@ -260,7 +260,7 @@ struct demux_cc
int ret = VLC_DEMUXER_SUCCESS;
if( !m_demux_eof )
{
- ret = demux_Demux( p_demux->p_next );
+ ret = demux_Demux( p_demux->s );
if( ret != VLC_DEMUXER_EGENERIC
&& ( m_start_time < 0 || m_start_pos < 0.0f ) )
initTimes();
@@ -273,7 +273,7 @@ struct demux_cc
/* Signal EOF to the sout when the es_out is empty (so when the
* DecoderThread fifo are empty) */
bool b_empty;
- es_out_Control( p_demux->p_next->out, ES_OUT_GET_EMPTY, &b_empty );
+ es_out_Control( p_demux->s->out, ES_OUT_GET_EMPTY, &b_empty );
if( b_empty )
p_renderer->pf_send_input_event( p_renderer->p_opaque,
CC_INPUT_EVENT_EOF,
@@ -292,7 +292,7 @@ struct demux_cc
int Control( demux_t *p_demux_filter, int i_query, va_list args )
{
if( !m_enabled && i_query != DEMUX_FILTER_ENABLE )
- return demux_vaControl( p_demux_filter->p_next, i_query, args );
+ return demux_vaControl( p_demux->s, i_query, args );
switch (i_query)
{
@@ -322,7 +322,7 @@ struct demux_cc
va_list ap;
va_copy( ap, args );
- ret = demux_vaControl( p_demux_filter->p_next, i_query, args );
+ ret = demux_vaControl( p_demux->s, i_query, args );
if( ret == VLC_SUCCESS )
m_length = *va_arg( ap, vlc_tick_t * );
va_end( ap );
@@ -335,7 +335,7 @@ struct demux_cc
va_list ap;
va_copy( ap, args );
- ret = demux_vaControl( p_demux_filter->p_next, i_query, args );
+ ret = demux_vaControl( p_demux->s, i_query, args );
if( ret == VLC_SUCCESS )
m_can_seek = *va_arg( ap, bool* );
va_end( ap );
@@ -346,7 +346,7 @@ struct demux_cc
{
double pos = va_arg( args, double );
/* Force unprecise seek */
- int ret = demux_Control( p_demux->p_next, DEMUX_SET_POSITION, pos, false );
+ int ret = demux_Control( p_demux->s, DEMUX_SET_POSITION, pos, false );
if( ret != VLC_SUCCESS )
return ret;
@@ -358,7 +358,7 @@ struct demux_cc
{
vlc_tick_t time = va_arg( args, vlc_tick_t );
/* Force unprecise seek */
- int ret = demux_Control( p_demux->p_next, DEMUX_SET_TIME, time, false );
+ int ret = demux_Control( p_demux->s, DEMUX_SET_TIME, time, false );
if( ret != VLC_SUCCESS )
return ret;
@@ -409,7 +409,7 @@ struct demux_cc
return VLC_SUCCESS;
}
- return demux_vaControl( p_demux_filter->p_next, i_query, args );
+ return demux_vaControl( p_demux->s, i_query, args );
}
protected:
@@ -428,7 +428,7 @@ protected:
static void on_paused_changed_cb( void *data, bool paused )
{
demux_t *p_demux = reinterpret_cast<demux_t*>(data);
- vlc_object_t *obj = vlc_object_parent(p_demux->p_next);
+ vlc_object_t *obj = vlc_object_parent(p_demux->s);
/* XXX: Ugly: Notify the parent of the input_thread_t that the corks state
* changed */
diff --git a/src/input/demux.c b/src/input/demux.c
index 44a7c440e7..a1e081b957 100644
--- a/src/input/demux.c
+++ b/src/input/demux.c
@@ -448,7 +448,7 @@ static demux_t *demux_FilterNew( demux_t *p_next, const char *p_name )
return NULL;
priv = vlc_stream_Private(p_demux);
- p_demux->p_next = p_next;
+ p_demux->s = p_next;
p_demux->p_input_item = NULL;
p_demux->p_sys = NULL;
p_demux->psz_name = NULL;
More information about the vlc-commits
mailing list