[vlc-devel] [PATCH 03/11] input/input: load slaves from input items
Thomas Guillem
thomas at gllm.fr
Fri Apr 1 10:31:02 CEST 2016
From: Benjamin Adolphi <b.adolphi at gmail.com>
---
src/input/input.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/src/input/input.c b/src/input/input.c
index a226d55..4d4222e 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -1007,6 +1007,46 @@ static void LoadSubtitles( input_thread_t *p_input )
}
free( psz_autopath );
+ /* Add subtitles found by the directory demuxer */
+ vlc_mutex_lock( &p_input->p->p_item->lock );
+ input_item_t *p_item = p_input->p->p_item;
+ for( int i = 0; i < p_item->i_slaves; i++ )
+ {
+ input_item_slave *p_slave = p_item->pp_slaves[i];
+ if( p_slave->i_type == SLAVE_TYPE_SPU )
+ {
+ bool added = false;
+ const char *psz_uri = strstr( p_slave->psz_uri, "file://" );
+ if( psz_uri )
+ {
+ psz_uri += strlen( "file://" );
+
+ /* check that we did not add the slave through sub-autodetect-path */
+ for( int i = 0; i < i_slaves; i++ )
+ {
+ if( !strcmp( pp_slaves[i]->psz_uri, psz_uri ) )
+ {
+ added = true;
+ break;
+ }
+ }
+
+ /* check that we did not add the slave through sub-file */
+ if( psz_subtitle && !strcmp( psz_subtitle, psz_uri ) )
+ added = true;
+ }
+ if( !added )
+ {
+ input_item_slave *p_sub = input_item_slave_New( p_slave->psz_uri,
+ p_slave->i_type,
+ p_slave->i_priority );
+ if( p_sub )
+ INSERT_ELEM( pp_slaves, i_slaves, i_slaves, p_sub );
+ }
+ }
+ }
+ vlc_mutex_unlock( &p_input->p->p_item->lock );
+
qsort( pp_slaves, i_slaves, sizeof(input_item_slave*), SlaveCompare );
/* add all detected subtitles */
--
2.8.0.rc3
More information about the vlc-devel
mailing list