Commit 070cd462 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Revert "input: De-duplicate titles"

This reverts commit 66401825.

This triggers a race between the interface and the input thread.
The playlist signals that a new input_thread_t is now the current item,
while the input thread tries to create the input_source_t containing the
titles.
If the interface reacts to the new item and tries to refresh the titles
before the input_source_t has been assigned to
input_thread_private_t::master, a crash will occur.
IMHO, having the titles duplicated is best for now, considering that
there will be massive changes to the playlist in 4.0
parent 66401825
......@@ -327,9 +327,9 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
if ( *pi_req_title_offset < 0 ) /* return current title if -1 */
*pi_req_title_offset = i_current_title;
if( priv->master->i_title && priv->master->i_title > *pi_req_title_offset )
if( priv->i_title && priv->i_title > *pi_req_title_offset )
{
*p_title = vlc_input_title_Duplicate( priv->master->title[*pi_req_title_offset] );
*p_title = vlc_input_title_Duplicate( priv->title[*pi_req_title_offset] );
vlc_mutex_unlock( &priv->p_item->lock );
return VLC_SUCCESS;
}
......@@ -343,7 +343,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
case INPUT_GET_FULL_TITLE_INFO:
{
vlc_mutex_lock( &priv->p_item->lock );
unsigned count = priv->master->i_title;
unsigned count = priv->i_title;
input_title_t **array = malloc( count * sizeof (*array) );
if( count > 0 && unlikely(array == NULL) )
......@@ -353,7 +353,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
}
for( unsigned i = 0; i < count; i++ )
array[i] = vlc_input_title_Duplicate( priv->master->title[i] );
array[i] = vlc_input_title_Duplicate( priv->title[i] );
vlc_mutex_unlock( &priv->p_item->lock );
......@@ -372,13 +372,13 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
if ( *pi_title_to_fetch < 0 ) /* query current title if -1 */
*pi_title_to_fetch = var_GetInteger( p_input, "title" );
if( priv->master->i_title == 0 || priv->master->i_title <= *pi_title_to_fetch )
if( priv->i_title == 0 || priv->i_title <= *pi_title_to_fetch )
{
vlc_mutex_unlock( &priv->p_item->lock );
return VLC_EGENERIC;
}
const input_title_t *p_title = priv->master->title[*pi_title_to_fetch];
const input_title_t *p_title = priv->title[*pi_title_to_fetch];
/* set arg2 to the number of seekpoints we found */
const int i_chapters = p_title->i_seekpoint;
......
......@@ -306,6 +306,8 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
priv->i_start = 0;
priv->i_time = 0;
priv->i_stop = 0;
priv->i_title = 0;
priv->title = NULL;
priv->i_title_offset = input_priv(p_input)->i_seekpoint_offset = 0;
priv->i_state = INIT_S;
priv->is_running = false;
......@@ -873,9 +875,11 @@ static void InitTitle( input_thread_t * p_input )
vlc_mutex_lock( &priv->p_item->lock );
/* Create global title (from master) */
priv->i_title = p_master->i_title;
priv->title = p_master->title;
priv->i_title_offset = p_master->i_title_offset;
priv->i_seekpoint_offset = p_master->i_seekpoint_offset;
if( p_master->i_title > 0 )
if( priv->i_title > 0 )
{
/* Setup variables */
input_ControlVarNavigation( p_input );
......@@ -1444,6 +1448,8 @@ static void End( input_thread_t * p_input )
/* Clean up master */
InputSourceDestroy( priv->master );
priv->i_title = 0;
priv->title = NULL;
priv->i_title_offset = 0;
priv->i_seekpoint_offset = 0;
......@@ -2272,8 +2278,8 @@ static void UpdateTitleListfromDemux( input_thread_t *p_input )
for( int i = 0; i < in->i_title; i++ )
vlc_input_title_Delete( in->title[i] );
TAB_CLEAN( in->i_title, in->title );
in->i_title = 0;
in->title = NULL;
priv->i_title = 0;
priv->title = NULL;
in->b_title_demux = false;
}
......
......@@ -113,6 +113,10 @@ typedef struct input_thread_private_t
vlc_viewpoint_t viewpoint;
bool viewpoint_changed;
/* Title infos FIXME multi-input (not easy) ? */
int i_title;
const input_title_t **title;
int i_title_offset;
int i_seekpoint_offset;
......
......@@ -239,10 +239,10 @@ void input_ControlVarStop( input_thread_t *p_input )
if( !input_priv(p_input)->b_preparsing )
InputDelCallbacks( p_input, p_input_callbacks );
if( input_priv(p_input)->master->i_title > 1 )
if( input_priv(p_input)->i_title > 1 )
InputDelCallbacks( p_input, p_input_title_navigation_callbacks );
for( int i = 0; i < input_priv(p_input)->master->i_title; i++ )
for( int i = 0; i < input_priv(p_input)->i_title; i++ )
{
char name[sizeof("title ") + 3 * sizeof (int)];
......@@ -252,7 +252,7 @@ void input_ControlVarStop( input_thread_t *p_input )
if( !demux_Control( p_demux, DEMUX_GET_TITLE, &i_cur_title ) )
{
const input_title_t* t = input_priv(p_input)->master->title[ i_cur_title ];
const input_title_t* t = input_priv(p_input)->title[ i_cur_title ];
if( t->i_seekpoint > 1 )
InputDelCallbacks( p_input, p_input_seekpoint_navigation_callbacks );
......@@ -268,7 +268,7 @@ void input_ControlVarNavigation( input_thread_t *p_input )
vlc_value_t text;
/* Create more command variables */
if( input_priv(p_input)->master->i_title > 1 )
if( input_priv(p_input)->i_title > 1 )
{
if( var_Type( p_input, "next-title" ) == 0 ) {
var_Create( p_input, "next-title", VLC_VAR_VOID );
......@@ -302,7 +302,7 @@ void input_ControlVarNavigation( input_thread_t *p_input )
/* Create titles and chapters */
var_Change( p_input, "title", VLC_VAR_CLEARCHOICES, NULL, NULL );
for( int i = 0; i < input_priv(p_input)->master->i_title; i++ )
for( int i = 0; i < input_priv(p_input)->i_title; i++ )
{
vlc_value_t val2, text2;
char title[sizeof("title ") + 3 * sizeof (int)];
......@@ -315,18 +315,17 @@ void input_ControlVarNavigation( input_thread_t *p_input )
NavigationCallback, (void *)(intptr_t)i );
char psz_length[MSTRTIME_MAX_SIZE + sizeof(" []")];
if( input_priv(p_input)->master->title[i]->i_length > 0 )
if( input_priv(p_input)->title[i]->i_length > 0 )
{
strcpy( psz_length, " [" );
secstotimestr( &psz_length[2],
input_priv(p_input)->master->title[i]->i_length / CLOCK_FREQ );
secstotimestr( &psz_length[2], input_priv(p_input)->title[i]->i_length / CLOCK_FREQ );
strcat( psz_length, "]" );
}
else
psz_length[0] = '\0';
if( input_priv(p_input)->master->title[i]->psz_name == NULL ||
*input_priv(p_input)->master->title[i]->psz_name == '\0' )
if( input_priv(p_input)->title[i]->psz_name == NULL ||
*input_priv(p_input)->title[i]->psz_name == '\0' )
{
if( asprintf( &text.psz_string, _("Title %i%s"),
i + input_priv(p_input)->i_title_offset, psz_length ) == -1 )
......@@ -335,7 +334,7 @@ void input_ControlVarNavigation( input_thread_t *p_input )
else
{
if( asprintf( &text.psz_string, "%s%s",
input_priv(p_input)->master->title[i]->psz_name, psz_length ) == -1 )
input_priv(p_input)->title[i]->psz_name, psz_length ) == -1 )
continue;
}
......@@ -345,12 +344,12 @@ void input_ControlVarNavigation( input_thread_t *p_input )
free( text.psz_string );
for( int j = 0; j < input_priv(p_input)->master->title[i]->i_seekpoint; j++ )
for( int j = 0; j < input_priv(p_input)->title[i]->i_seekpoint; j++ )
{
val2.i_int = j;
if( input_priv(p_input)->master->title[i]->seekpoint[j]->psz_name == NULL ||
*input_priv(p_input)->master->title[i]->seekpoint[j]->psz_name == '\0' )
if( input_priv(p_input)->title[i]->seekpoint[j]->psz_name == NULL ||
*input_priv(p_input)->title[i]->seekpoint[j]->psz_name == '\0' )
{
/* Default value */
if( asprintf( &text2.psz_string, _("Chapter %i"),
......@@ -360,7 +359,7 @@ void input_ControlVarNavigation( input_thread_t *p_input )
else
{
text2.psz_string =
strdup( input_priv(p_input)->master->title[i]->seekpoint[j]->psz_name );
strdup( input_priv(p_input)->title[i]->seekpoint[j]->psz_name );
}
var_Change( p_input, title, VLC_VAR_ADDCHOICE, &val2, &text2 );
......@@ -376,7 +375,7 @@ void input_ControlVarNavigation( input_thread_t *p_input )
*****************************************************************************/
void input_ControlVarTitle( input_thread_t *p_input, int i_title )
{
const input_title_t *t = input_priv(p_input)->master->title[i_title];
const input_title_t *t = input_priv(p_input)->title[i_title];
vlc_value_t text;
int i;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment