Commit 6df71108 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

variables: use size_t for VLC_VAR_CHOICESCOUNT

parent 77a24d6a
......@@ -664,10 +664,10 @@ static inline char *var_CreateGetNonEmptyStringCommand( vlc_object_t *p_obj,
VLC_USED
static inline int var_CountChoices( vlc_object_t *p_obj, const char *psz_name )
{
vlc_value_t count;
size_t count;
if( var_Change( p_obj, psz_name, VLC_VAR_CHOICESCOUNT, &count ) )
return 0;
return count.i_int;
return count;
}
static inline bool var_ToggleBool( vlc_object_t *p_obj, const char *psz_name )
......
......@@ -1397,7 +1397,7 @@ int libvlc_media_player_get_chapter( libvlc_media_player_t *p_mi )
int libvlc_media_player_get_chapter_count( libvlc_media_player_t *p_mi )
{
input_thread_t *p_input_thread;
vlc_value_t val;
size_t val;
p_input_thread = libvlc_get_input_thread ( p_mi );
if( !p_input_thread )
......@@ -1406,14 +1406,14 @@ int libvlc_media_player_get_chapter_count( libvlc_media_player_t *p_mi )
int i_ret = var_Change( p_input_thread, "chapter", VLC_VAR_CHOICESCOUNT, &val );
vlc_object_release( p_input_thread );
return i_ret == VLC_SUCCESS ? val.i_int : -1;
return i_ret == VLC_SUCCESS ? (ssize_t)val : -1;
}
int libvlc_media_player_get_chapter_count_for_title(
libvlc_media_player_t *p_mi,
int i_title )
{
vlc_value_t val;
size_t val;
input_thread_t *p_input_thread = libvlc_get_input_thread ( p_mi );
if( !p_input_thread )
......@@ -1425,7 +1425,7 @@ int libvlc_media_player_get_chapter_count_for_title(
int i_ret = var_Change( p_input_thread, psz_name, VLC_VAR_CHOICESCOUNT, &val );
vlc_object_release( p_input_thread );
return i_ret == VLC_SUCCESS ? val.i_int : -1;
return i_ret == VLC_SUCCESS ? (ssize_t)val : -1;
}
void libvlc_media_player_set_title( libvlc_media_player_t *p_mi,
......@@ -1465,7 +1465,7 @@ int libvlc_media_player_get_title( libvlc_media_player_t *p_mi )
int libvlc_media_player_get_title_count( libvlc_media_player_t *p_mi )
{
input_thread_t *p_input_thread;
vlc_value_t val;
size_t val;
p_input_thread = libvlc_get_input_thread ( p_mi );
if( !p_input_thread )
......@@ -1474,7 +1474,7 @@ int libvlc_media_player_get_title_count( libvlc_media_player_t *p_mi )
int i_ret = var_Change( p_input_thread, "title", VLC_VAR_CHOICESCOUNT, &val );
vlc_object_release( p_input_thread );
return i_ret == VLC_SUCCESS ? val.i_int : -1;
return i_ret == VLC_SUCCESS ? (ssize_t)val : -1;
}
int libvlc_media_player_get_full_title_descriptions( libvlc_media_player_t *p_mi,
......
......@@ -1471,8 +1471,10 @@
/* Make sure we want to display the variable */
if (i_type & VLC_VAR_HASCHOICE) {
var_Change(p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val);
if (val.i_int == 0 || val.i_int == 1)
size_t count;
var_Change(p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &count);
if (count <= 1)
return;
}
else
......
......@@ -438,15 +438,14 @@ void InputManager::UpdatePosition()
void InputManager::UpdateNavigation()
{
/* Update navigation status */
vlc_value_t val; val.i_int = 0;
vlc_value_t val2; val2.i_int = 0;
size_t ntitles, nchapters;
var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &val );
var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &ntitles );
if( val.i_int > 0 )
if( ntitles > 0 )
{
bool b_menu = false;
if( val.i_int > 1 )
if( ntitles > 1 )
{
input_title_t **pp_title = NULL;
int i_title = 0;
......@@ -463,10 +462,10 @@ void InputManager::UpdateNavigation()
}
/* p_input != NULL since val.i_int != 0 */
var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &val2 );
var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &nchapters );
emit titleChanged( b_menu );
emit chapterChanged( val2.i_int > 1 );
emit chapterChanged( nchapters > 1 );
}
else
emit chapterChanged( false );
......@@ -552,9 +551,9 @@ bool InputManager::hasAudio()
{
if( hasInput() )
{
vlc_value_t val;
size_t val;
var_Change( p_input, "audio-es", VLC_VAR_CHOICESCOUNT, &val );
return val.i_int > 0;
return val > 0;
}
return false;
}
......
......@@ -1239,9 +1239,9 @@ static bool IsMenuEmpty( const char *psz_var, vlc_object_t *p_object )
if( !(var_Type( p_object, psz_var) & VLC_VAR_HASCHOICE) )
return false;
vlc_value_t val;
size_t val;
var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val );
return val.i_int == 0 || val.i_int == 1;
return val <= 1;
}
#define TEXT_OR_VAR qfue ( text.psz_string ? text.psz_string : psz_var )
......
......@@ -483,9 +483,9 @@ void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
case INPUT_EVENT_ES:
{
// Do we have audio
vlc_value_t audio_es;
size_t audio_es;
var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT, &audio_es );
SET_BOOL( m_cVarHasAudio, audio_es.i_int > 0 );
SET_BOOL( m_cVarHasAudio, audio_es > 0 );
break;
}
......@@ -518,10 +518,10 @@ void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
case INPUT_EVENT_CHAPTER:
{
vlc_value_t chapters_count;
size_t chapters_count;
var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
&chapters_count );
SET_BOOL( m_cVarDvdActive, chapters_count.i_int > 0 );
SET_BOOL( m_cVarDvdActive, chapters_count > 0 );
break;
}
......
......@@ -929,7 +929,8 @@ static void EsOutESVarUpdateGeneric( es_out_t *out, int i_id,
{
es_out_sys_t *p_sys = out->p_sys;
input_thread_t *p_input = p_sys->p_input;
vlc_value_t val, text;
vlc_value_t text;
size_t count;
if( b_delete )
{
......@@ -949,15 +950,15 @@ static void EsOutESVarUpdateGeneric( es_out_t *out, int i_id,
else
psz_var = "spu-es";
var_Change( p_input, psz_var, VLC_VAR_CHOICESCOUNT, &val );
if( val.i_int == 0 )
var_Change( p_input, psz_var, VLC_VAR_CHOICESCOUNT, &count );
if( count == 0 )
{
vlc_value_t val2;
/* First one, we need to add the "Disable" choice */
val2.i_int = -1;
var_Change( p_input, psz_var, VLC_VAR_ADDCHOICE, val2, _("Disable") );
val.i_int++;
count++;
}
/* Take care of the ES description */
......@@ -975,12 +976,13 @@ static void EsOutESVarUpdateGeneric( es_out_t *out, int i_id,
{
if( psz_language && *psz_language )
{
if( asprintf( &text.psz_string, "%s %"PRId64" - [%s]", _( "Track" ), val.i_int, psz_language ) == -1 )
if( asprintf( &text.psz_string, "%s %zu - [%s]", _("Track"), count,
psz_language ) == -1 )
text.psz_string = NULL;
}
else
{
if( asprintf( &text.psz_string, "%s %"PRId64, _( "Track" ), val.i_int ) == -1 )
if( asprintf( &text.psz_string, "%s %zu", _("Track"), count ) == -1 )
text.psz_string = NULL;
}
}
......
......@@ -3203,7 +3203,7 @@ static int input_SlaveSourceAdd( input_thread_t *p_input,
enum slave_type i_type, const char *psz_uri,
unsigned i_flags )
{
vlc_value_t count;
size_t count;
const char *psz_es;
const char *psz_forced_demux;
const bool b_can_fail = i_flags & SLAVE_ADD_CANFAIL;
......@@ -3283,13 +3283,13 @@ static int input_SlaveSourceAdd( input_thread_t *p_input,
(vlc_value_t *)NULL ) )
return VLC_SUCCESS;
if( count.i_int == 0 )
count.i_int++;
if( count == 0 )
count++;
/* if it was first one, there is disable too */
if( count.i_int < list.p_list->i_count )
if( count < (size_t)list.p_list->i_count )
{
const int i_id = list.p_list->p_values[count.i_int].i_int;
const int i_id = list.p_list->p_values[count].i_int;
es_out_Control( input_priv(p_input)->p_es_out_display, ES_OUT_SET_ES_DEFAULT_BY_ID, i_id );
es_out_Control( input_priv(p_input)->p_es_out_display, ES_OUT_SET_ES_BY_ID, i_id );
......
......@@ -660,7 +660,8 @@ static int TitleCallback( vlc_object_t *p_this, char const *psz_cmd,
void *p_data )
{
input_thread_t *p_input = (input_thread_t*)p_this;
vlc_value_t val, count;
vlc_value_t val;
size_t count;
VLC_UNUSED(oldval); VLC_UNUSED(p_data);
if( !strcmp( psz_cmd, "next-title" ) )
......@@ -669,7 +670,7 @@ static int TitleCallback( vlc_object_t *p_this, char const *psz_cmd,
val.i_int = var_GetInteger( p_input, "title" ) + 1;
var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &count );
if( val.i_int < count.i_int )
if( (size_t)val.i_int < count )
var_Change( p_input, "title", VLC_VAR_SETVALUE, &val );
}
else if( !strcmp( psz_cmd, "prev-title" ) )
......@@ -701,7 +702,8 @@ static int SeekpointCallback( vlc_object_t *p_this, char const *psz_cmd,
void *p_data )
{
input_thread_t *p_input = (input_thread_t*)p_this;
vlc_value_t val, count;
vlc_value_t val;
size_t count;
VLC_UNUSED(oldval); VLC_UNUSED(p_data);
if( !strcmp( psz_cmd, "next-chapter" ) )
......@@ -710,7 +712,7 @@ static int SeekpointCallback( vlc_object_t *p_this, char const *psz_cmd,
val.i_int = var_GetInteger( p_input, "chapter" ) + 1;
var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &count );
if( val.i_int < count.i_int )
if( (size_t)val.i_int < count )
var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val );
}
else if( !strcmp( psz_cmd, "prev-chapter" ) )
......
......@@ -519,7 +519,7 @@ int (var_Change)(vlc_object_t *p_this, const char *psz_name, int i_action, ...)
break;
}
case VLC_VAR_CHOICESCOUNT:
va_arg(ap, vlc_value_t *)->i_int = p_var->choices.i_count;
*va_arg(ap, size_t *) = p_var->choices.i_count;
break;
case VLC_VAR_CLEARCHOICES:
for( int i = 0 ; i < p_var->choices.i_count ; 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