[vlc-commits] input: hide attachments controls
Thomas Guillem
git at videolan.org
Tue Sep 4 16:38:04 CEST 2018
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Sep 4 16:15:04 2018 +0200| [b43a25889c43d94aafd98e7191d6744e1d836229] | committer: Thomas Guillem
input: hide attachments controls
Since they are only used privately.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b43a25889c43d94aafd98e7191d6744e1d836229
---
include/vlc_input.h | 4 ----
src/input/access.c | 4 ++--
src/input/control.c | 42 ------------------------------------
src/input/decoder.c | 8 +++++--
src/input/input.c | 43 +++++++++++++++++++++++++++++++++++++
src/input/input_internal.h | 4 ++++
src/input/meta.c | 4 ++--
src/video_output/vout_subpictures.c | 15 ++++++++-----
8 files changed, 67 insertions(+), 57 deletions(-)
diff --git a/include/vlc_input.h b/include/vlc_input.h
index 0c1d5a10b7..fddede9fc5 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -532,10 +532,6 @@ enum input_query_e
/* titles */
INPUT_GET_FULL_TITLE_INFO, /* arg1=input_title_t*** arg2= int * res=can fail */
- /* Attachments */
- INPUT_GET_ATTACHMENTS, /* arg1=input_attachment_t***, arg2=int* res=can fail */
- INPUT_GET_ATTACHMENT, /* arg1=input_attachment_t**, arg2=char* res=can fail */
-
/* On the fly input slave */
INPUT_ADD_SLAVE, /* arg1= enum slave_type, arg2= const char *,
* arg3= bool forced, arg4= bool notify,
diff --git a/src/input/access.c b/src/input/access.c
index 9a34898f83..f6ddbea338 100644
--- a/src/input/access.c
+++ b/src/input/access.c
@@ -81,8 +81,8 @@ static stream_t *accessNewAttachment(vlc_object_t *parent,
if (!input)
return NULL;
- input_attachment_t *attachment;
- if (input_Control(input, INPUT_GET_ATTACHMENT, &attachment, mrl + 13))
+ input_attachment_t *attachment = input_GetAttachment(input, mrl + 13);
+ if (!attachment)
return NULL;
stream_t *stream = vlc_stream_AttachmentNew(parent, attachment);
if (!stream)
diff --git a/src/input/control.c b/src/input/control.c
index bae8a67b7e..77da975d36 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -315,48 +315,6 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
return VLC_SUCCESS;
}
- case INPUT_GET_ATTACHMENTS: /* arg1=input_attachment_t***, arg2=int* res=can fail */
- {
- input_attachment_t ***ppp_attachment = va_arg( args, input_attachment_t *** );
- int *pi_attachment = va_arg( args, int * );
-
- vlc_mutex_lock( &priv->p_item->lock );
- if( priv->i_attachment <= 0 )
- {
- vlc_mutex_unlock( &priv->p_item->lock );
- *ppp_attachment = NULL;
- *pi_attachment = 0;
- return VLC_EGENERIC;
- }
- *pi_attachment = priv->i_attachment;
- *ppp_attachment = vlc_alloc( priv->i_attachment, sizeof(input_attachment_t*));
- for( int i = 0; i < priv->i_attachment; i++ )
- (*ppp_attachment)[i] = vlc_input_attachment_Duplicate( priv->attachment[i] );
-
- vlc_mutex_unlock( &priv->p_item->lock );
- return VLC_SUCCESS;
- }
-
- case INPUT_GET_ATTACHMENT: /* arg1=input_attachment_t**, arg2=char* res=can fail */
- {
- input_attachment_t **pp_attachment = va_arg( args, input_attachment_t ** );
- const char *psz_name = va_arg( args, const char * );
-
- vlc_mutex_lock( &priv->p_item->lock );
- for( int i = 0; i < priv->i_attachment; i++ )
- {
- if( !strcmp( priv->attachment[i]->psz_name, psz_name ) )
- {
- *pp_attachment = vlc_input_attachment_Duplicate(priv->attachment[i] );
- vlc_mutex_unlock( &priv->p_item->lock );
- return VLC_SUCCESS;
- }
- }
- *pp_attachment = NULL;
- vlc_mutex_unlock( &priv->p_item->lock );
- return VLC_EGENERIC;
- }
-
case INPUT_RESTART_ES_BY_ID:
val.i_int = va_arg( args, int );
input_ControlPushHelper( p_input, INPUT_CONTROL_RESTART_ES_BY_ID, &val );
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 0de900ded2..251fae2ec0 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -657,8 +657,12 @@ static int DecoderGetInputAttachments( decoder_t *p_dec,
if( unlikely(p_input == NULL) )
return VLC_ENOOBJ;
- return input_Control( p_input, INPUT_GET_ATTACHMENTS,
- ppp_attachment, pi_attachment );
+
+ int ret = input_GetAttachments( p_input, ppp_attachment );
+ if (ret < 0)
+ return VLC_EGENERIC;
+ *pi_attachment = ret;
+ return VLC_SUCCESS;
}
static vlc_tick_t DecoderGetDisplayDate( decoder_t *p_dec, vlc_tick_t i_ts )
diff --git a/src/input/input.c b/src/input/input.c
index ddac6fa57a..f8a551e643 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -3350,3 +3350,46 @@ char *input_CreateFilename(input_thread_t *input, input_item_t *item,
free(filename);
return path;
}
+
+int input_GetAttachments(input_thread_t *input,
+ input_attachment_t ***attachments)
+{
+ input_thread_private_t *priv = input_priv(input);
+
+ vlc_mutex_lock(&priv->p_item->lock);
+ int attachments_count = priv->i_attachment;
+ if (attachments_count <= 0)
+ {
+ vlc_mutex_unlock(&priv->p_item->lock);
+ return 0;
+ }
+
+ *attachments = vlc_alloc(attachments_count, sizeof(input_attachment_t*));
+ if (!*attachments)
+ return -1;
+
+ for (int i = 0; i < attachments_count; i++)
+ (*attachments)[i] = vlc_input_attachment_Duplicate(priv->attachment[i]);
+
+ vlc_mutex_unlock(&priv->p_item->lock);
+ return attachments_count;
+}
+
+input_attachment_t *input_GetAttachment(input_thread_t *input, const char *name)
+{
+ input_thread_private_t *priv = input_priv(input);
+
+ vlc_mutex_lock(&priv->p_item->lock);
+ for (int i = 0; i < priv->i_attachment; i++)
+ {
+ if (!strcmp( priv->attachment[i]->psz_name, name))
+ {
+ input_attachment_t *attachment =
+ vlc_input_attachment_Duplicate(priv->attachment[i] );
+ vlc_mutex_unlock( &priv->p_item->lock );
+ return attachment;
+ }
+ }
+ vlc_mutex_unlock( &priv->p_item->lock );
+ return NULL;
+}
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index 5848d95e30..1a69cc47f9 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -261,6 +261,10 @@ static inline void input_ControlPushHelper( input_thread_t *p_input, int i_type,
bool input_Stopped( input_thread_t * );
+int input_GetAttachments(input_thread_t *input, input_attachment_t ***attachments);
+
+input_attachment_t *input_GetAttachment(input_thread_t *input, const char *name);
+
/* Bound pts_delay */
#define INPUT_PTS_DELAY_MAX VLC_TICK_FROM_SEC(60)
diff --git a/src/input/meta.c b/src/input/meta.c
index b02cb25d6a..0cb62a8495 100644
--- a/src/input/meta.c
+++ b/src/input/meta.c
@@ -217,8 +217,8 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input,
}
/* */
- input_attachment_t *p_attachment = NULL;
- if( input_Control( p_input, INPUT_GET_ATTACHMENT, &p_attachment, name ) )
+ input_attachment_t *p_attachment = input_GetAttachment( p_input, name );
+ if( !p_attachment )
{
msg_Warn( p_input, "art attachment %s not found", name );
return;
diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c
index 806d70b17a..71a5544fc6 100644
--- a/src/video_output/vout_subpictures.c
+++ b/src/video_output/vout_subpictures.c
@@ -44,6 +44,7 @@
#include "../libvlc.h"
#include "vout_internal.h"
#include "../misc/subpicture.h"
+#include "../input/input_internal.h"
/*****************************************************************************
* Local prototypes
@@ -179,12 +180,16 @@ static int spu_get_attachments(filter_t *filter,
{
spu_t *spu = filter->owner.sys;
- int ret = VLC_EGENERIC;
if (spu->p->input)
- ret = input_Control(spu->p->input,
- INPUT_GET_ATTACHMENTS,
- attachment_ptr, attachment_count);
- return ret;
+ {
+ int count = input_GetAttachments(spu->p->input, attachment_ptr);
+ if (count < 0)
+ return VLC_EGENERIC;
+ *attachment_count = count;
+ return VLC_SUCCESS;
+ }
+
+ return VLC_EGENERIC;
}
static filter_t *SpuRenderCreateAndLoadText(spu_t *spu)
More information about the vlc-commits
mailing list