[vlc-commits] variables: use size_t for VLC_VAR_CHOICESCOUNT
Rémi Denis-Courmont
git at videolan.org
Sun Jun 10 12:11:12 CEST 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jun 9 14:46:51 2018 +0300| [6df7110897e29e5d79ac4e8635fe7e26c9c7a8bf] | committer: Rémi Denis-Courmont
variables: use size_t for VLC_VAR_CHOICESCOUNT
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6df7110897e29e5d79ac4e8635fe7e26c9c7a8bf
---
include/vlc_variables.h | 4 ++--
lib/media_player.c | 12 ++++++------
modules/gui/macosx/VLCMainMenu.m | 6 ++++--
modules/gui/qt/input_manager.cpp | 17 ++++++++---------
modules/gui/qt/menus.cpp | 4 ++--
modules/gui/skins2/src/vlcproc.cpp | 8 ++++----
src/input/es_out.c | 14 ++++++++------
src/input/input.c | 10 +++++-----
src/input/var.c | 10 ++++++----
src/misc/variables.c | 2 +-
10 files changed, 46 insertions(+), 41 deletions(-)
diff --git a/include/vlc_variables.h b/include/vlc_variables.h
index f6d3ee7106..5442782be3 100644
--- a/include/vlc_variables.h
+++ b/include/vlc_variables.h
@@ -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 )
diff --git a/lib/media_player.c b/lib/media_player.c
index b98abc0599..a4ea86b300 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -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,
diff --git a/modules/gui/macosx/VLCMainMenu.m b/modules/gui/macosx/VLCMainMenu.m
index 75b9b4646d..e5f003efe6 100644
--- a/modules/gui/macosx/VLCMainMenu.m
+++ b/modules/gui/macosx/VLCMainMenu.m
@@ -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
diff --git a/modules/gui/qt/input_manager.cpp b/modules/gui/qt/input_manager.cpp
index 978e426b76..c0c3020bc9 100644
--- a/modules/gui/qt/input_manager.cpp
+++ b/modules/gui/qt/input_manager.cpp
@@ -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;
}
diff --git a/modules/gui/qt/menus.cpp b/modules/gui/qt/menus.cpp
index 0a79fa7eef..5f8929fe0f 100644
--- a/modules/gui/qt/menus.cpp
+++ b/modules/gui/qt/menus.cpp
@@ -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 )
diff --git a/modules/gui/skins2/src/vlcproc.cpp b/modules/gui/skins2/src/vlcproc.cpp
index edcd0cd00a..d9a050f980 100644
--- a/modules/gui/skins2/src/vlcproc.cpp
+++ b/modules/gui/skins2/src/vlcproc.cpp
@@ -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;
}
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 9aa7761f2d..83b6532d98 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -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;
}
}
diff --git a/src/input/input.c b/src/input/input.c
index 33aa5e1d5e..ad7c82bf8b 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -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 );
diff --git a/src/input/var.c b/src/input/var.c
index 68ab3dcc9d..7f66259d3e 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -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" ) )
diff --git a/src/misc/variables.c b/src/misc/variables.c
index d9fafdb6fc..88af899eb3 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -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++ )
More information about the vlc-commits
mailing list