[vlc-commits] lib: actually return bool

Rémi Denis-Courmont git at videolan.org
Sun May 19 09:49:13 CEST 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun May 19 10:44:21 2019 +0300| [94105be6cfababfa9337efe2ba3997cc90f58206] | committer: Rémi Denis-Courmont

lib: actually return bool

This fixes the old int-for-bool return values from before 1.1.0 and the
later cargo culted ones.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=94105be6cfababfa9337efe2ba3997cc90f58206
---

 include/vlc/deprecated.h               |  7 ++---
 include/vlc/libvlc_media.h             |  9 +++---
 include/vlc/libvlc_media_discoverer.h  |  8 +++---
 include/vlc/libvlc_media_list.h        |  8 ++----
 include/vlc/libvlc_media_list_player.h |  8 +++---
 include/vlc/libvlc_media_player.h      | 48 +++++++++++++++----------------
 lib/media.c                            |  7 ++---
 lib/media_discoverer.c                 |  3 +-
 lib/media_list.c                       |  2 +-
 lib/media_list_player.c                |  3 +-
 lib/media_player.c                     | 52 +++++++++++++++++-----------------
 lib/video.c                            |  2 +-
 12 files changed, 75 insertions(+), 82 deletions(-)

diff --git a/include/vlc/deprecated.h b/include/vlc/deprecated.h
index 6f433654b4..82ac660f94 100644
--- a/include/vlc/deprecated.h
+++ b/include/vlc/deprecated.h
@@ -82,11 +82,10 @@ libvlc_media_parse_async( libvlc_media_t *p_md );
  * \see libvlc_MediaParsedChanged
  *
  * \param p_md media descriptor object
- * \return true if media object has been parsed otherwise it returns false
- *
- * \libvlc_return_bool
+ * \retval true media object has been parsed
+ * \retval false otherwise
  */
-LIBVLC_DEPRECATED LIBVLC_API int
+LIBVLC_DEPRECATED LIBVLC_API bool
    libvlc_media_is_parsed( libvlc_media_t *p_md );
 
 /** @}*/
diff --git a/include/vlc/libvlc_media.h b/include/vlc/libvlc_media.h
index bb47738920..4bc6f924ef 100644
--- a/include/vlc/libvlc_media.h
+++ b/include/vlc/libvlc_media.h
@@ -618,12 +618,11 @@ LIBVLC_API libvlc_state_t libvlc_media_get_state(
  * \param p_md: media descriptor object
  * \param p_stats: structure that contain the statistics about the media
  *                 (this structure must be allocated by the caller)
- * \return true if the statistics are available, false otherwise
- *
- * \libvlc_return_bool
+ * \retval true statistics are available
+ * \retval false otherwise
  */
-LIBVLC_API int libvlc_media_get_stats( libvlc_media_t *p_md,
-                                           libvlc_media_stats_t *p_stats );
+LIBVLC_API bool libvlc_media_get_stats(libvlc_media_t *p_md,
+                                       libvlc_media_stats_t *p_stats);
 
 /* The following method uses libvlc_media_list_t, however, media_list usage is optionnal
  * and this is here for convenience */
diff --git a/include/vlc/libvlc_media_discoverer.h b/include/vlc/libvlc_media_discoverer.h
index f360b0794f..d8423b371e 100644
--- a/include/vlc/libvlc_media_discoverer.h
+++ b/include/vlc/libvlc_media_discoverer.h
@@ -139,12 +139,12 @@ libvlc_media_discoverer_media_list( libvlc_media_discoverer_t * p_mdis );
  * Query if media service discover object is running.
  *
  * \param p_mdis media service discover object
- * \return true if running, false if not
  *
- * \libvlc_return_bool
+ * \retval true running
+ * \retval false not running
  */
-LIBVLC_API int
-libvlc_media_discoverer_is_running( libvlc_media_discoverer_t * p_mdis );
+LIBVLC_API bool
+libvlc_media_discoverer_is_running(libvlc_media_discoverer_t *p_mdis);
 
 /**
  * Get media discoverer services by category
diff --git a/include/vlc/libvlc_media_list.h b/include/vlc/libvlc_media_list.h
index 50ad0a22b0..95f24a5c03 100644
--- a/include/vlc/libvlc_media_list.h
+++ b/include/vlc/libvlc_media_list.h
@@ -158,12 +158,10 @@ LIBVLC_API int
  * This indicates if this media list is read-only from a user point of view
  *
  * \param p_ml media list instance
- * \return 1 on readonly, 0 on readwrite
- *
- * \libvlc_return_bool
+ * \retval true read-only
+ * \retval false read/write
  */
-LIBVLC_API int
-    libvlc_media_list_is_readonly( libvlc_media_list_t * p_ml );
+LIBVLC_API bool libvlc_media_list_is_readonly(libvlc_media_list_t *p_ml);
 
 /**
  * Get lock on media list items
diff --git a/include/vlc/libvlc_media_list_player.h b/include/vlc/libvlc_media_list_player.h
index 6e5d3d2eaf..8dcdcb961a 100644
--- a/include/vlc/libvlc_media_list_player.h
+++ b/include/vlc/libvlc_media_list_player.h
@@ -153,12 +153,12 @@ void libvlc_media_list_player_set_pause(libvlc_media_list_player_t * p_mlp,
  * Is media list playing?
  *
  * \param p_mlp media list player instance
- * \return true for playing and false for not playing
  *
- * \libvlc_return_bool
+ * \retval true playing
+ * \retval false not playing
  */
-LIBVLC_API int
-    libvlc_media_list_player_is_playing( libvlc_media_list_player_t * p_mlp );
+LIBVLC_API bool
+libvlc_media_list_player_is_playing(libvlc_media_list_player_t * p_mlp);
 
 /**
  * Get current libvlc_state of media list player
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 14e9a8b363..cf432a7352 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -235,11 +235,10 @@ LIBVLC_API libvlc_event_manager_t * libvlc_media_player_event_manager ( libvlc_m
  * is_playing
  *
  * \param p_mi the Media Player
- * \return 1 if the media player is playing, 0 otherwise
- *
- * \libvlc_return_bool
+ * \retval true media player is playing
+ * \retval false media player is not playing
  */
-LIBVLC_API int libvlc_media_player_is_playing ( libvlc_media_player_t *p_mi );
+LIBVLC_API bool libvlc_media_player_is_playing(libvlc_media_player_t *p_mi);
 
 /**
  * Play
@@ -579,11 +578,13 @@ typedef enum libvlc_video_engine_t {
  * \param makeCurrent_cb callback called to enter/leave the opengl context (cannot be NULL for \ref libvlc_video_engine_opengl and for \ref libvlc_video_engine_gles2)
  * \param getProcAddress_cb opengl function loading callback (cannot be NULL for \ref libvlc_video_engine_opengl and for \ref libvlc_video_engine_gles2)
  * \param opaque private pointer passed to callbacks
- * \libvlc_return_bool
+ *
+ * \retval true engine selected and callbacks set
+ * \retval false engine type unknown, callbacks not set
  * \version LibVLC 4.0.0 or later
  */
 LIBVLC_API
-int libvlc_video_set_output_callbacks( libvlc_media_player_t *mp,
+bool libvlc_video_set_output_callbacks( libvlc_media_player_t *mp,
                                         libvlc_video_engine_t engine,
                                         libvlc_video_setup_cb setup_cb,
                                         libvlc_video_cleanup_cb cleanup_cb,
@@ -778,11 +779,13 @@ typedef bool( *libvlc_video_direct3d_select_plane_cb )( void *opaque, size_t pla
  * \param makeCurrent_cb callback to tell the host the rendering is starting/ended (cannot be NULL)
  * \param select_plane_cb callback to select different D3D11 rendering targets
  * \param opaque private pointer passed to the \ref cleanup_cb callback
- * \libvlc_return_bool
+ *
+ * \retval true Direct3D selected and callbacks set
+ * \retval false Direct3D version, callbacks not set
  * \version LibVLC 4.0.0 or later
  */
 LIBVLC_API
-int libvlc_video_direct3d_set_callbacks( libvlc_media_player_t *mp,
+bool libvlc_video_direct3d_set_callbacks( libvlc_media_player_t *mp,
                                          libvlc_video_direct3d_engine_t engine,
                                          libvlc_video_direct3d_device_setup_cb setup_cb,
                                          libvlc_video_direct3d_device_cleanup_cb cleanup_cb,
@@ -1177,9 +1180,7 @@ LIBVLC_API int libvlc_media_player_get_chapter_count( libvlc_media_player_t *p_m
  * Is the player able to play
  *
  * \param p_mi the Media Player
- * \return boolean
- *
- * \libvlc_return_bool
+ * \retval boolean
  */
 LIBVLC_API int libvlc_media_player_will_play( libvlc_media_player_t *p_mi );
 
@@ -1271,32 +1272,30 @@ LIBVLC_API unsigned libvlc_media_player_has_vout( libvlc_media_player_t *p_mi );
  * Is this media player seekable?
  *
  * \param p_mi the media player
- * \return true if the media player can seek
- *
- * \libvlc_return_bool
+ * \retval true media player can seek
+ * \retval false media player cannot seek
  */
-LIBVLC_API int libvlc_media_player_is_seekable( libvlc_media_player_t *p_mi );
+LIBVLC_API bool libvlc_media_player_is_seekable(libvlc_media_player_t *p_mi);
 
 /**
  * Can this media player be paused?
  *
  * \param p_mi the media player
- * \return true if the media player can pause
- *
- * \libvlc_return_bool
+ * \retval true media player can be paused
+ * \retval false media player cannot be paused
  */
-LIBVLC_API int libvlc_media_player_can_pause( libvlc_media_player_t *p_mi );
+LIBVLC_API bool libvlc_media_player_can_pause(libvlc_media_player_t *p_mi);
 
 /**
  * Check if the current program is scrambled
  *
  * \param p_mi the media player
- * \return true if the current program is scrambled
+ * \retval true current program is scrambled
+ * \retval false current program is not scrambled
  *
- * \libvlc_return_bool
  * \version LibVLC 2.2.0 or later
  */
-LIBVLC_API int libvlc_media_player_program_scrambled( libvlc_media_player_t *p_mi );
+LIBVLC_API bool libvlc_media_player_program_scrambled( libvlc_media_player_t *p_mi );
 
 /**
  * Display the next frame (if supported)
@@ -1393,9 +1392,10 @@ LIBVLC_API void libvlc_set_fullscreen(libvlc_media_player_t *p_mi, bool b_fullsc
  * \param p_mi the media player
  * \return the fullscreen status (boolean)
  *
- * \libvlc_return_bool
+ * \retval false media player is windowed
+ * \retval true media player is in fullscreen mode
  */
-LIBVLC_API int libvlc_get_fullscreen( libvlc_media_player_t *p_mi );
+LIBVLC_API bool libvlc_get_fullscreen( libvlc_media_player_t *p_mi );
 
 /**
  * Enable or disable key press events handling, according to the LibVLC hotkeys
diff --git a/lib/media.c b/lib/media.c
index c7febc3548..db7ef622bb 100644
--- a/lib/media.c
+++ b/lib/media.c
@@ -697,8 +697,8 @@ libvlc_media_subitems( libvlc_media_t * p_md )
 /**************************************************************************
  * Getter for statistics information
  **************************************************************************/
-int libvlc_media_get_stats( libvlc_media_t *p_md,
-                            libvlc_media_stats_t *p_stats )
+bool libvlc_media_get_stats(libvlc_media_t *p_md,
+                            libvlc_media_stats_t *p_stats)
 {
     input_item_t *item = p_md->p_input_item;
 
@@ -864,8 +864,7 @@ libvlc_media_parse_stop( libvlc_media_t *media )
 /**************************************************************************
  * Get parsed status for media object.
  **************************************************************************/
-int
-libvlc_media_is_parsed(libvlc_media_t *media)
+bool libvlc_media_is_parsed(libvlc_media_t *media)
 {
     bool parsed;
 
diff --git a/lib/media_discoverer.c b/lib/media_discoverer.c
index 80ae82bc50..763e955590 100644
--- a/lib/media_discoverer.c
+++ b/lib/media_discoverer.c
@@ -251,8 +251,7 @@ libvlc_media_discoverer_media_list( libvlc_media_discoverer_t * p_mdis )
 /**************************************************************************
  * running (Public)
  **************************************************************************/
-int
-libvlc_media_discoverer_is_running( libvlc_media_discoverer_t * p_mdis )
+bool libvlc_media_discoverer_is_running(libvlc_media_discoverer_t * p_mdis)
 {
     return p_mdis->p_sd != NULL;
 }
diff --git a/lib/media_list.c b/lib/media_list.c
index baa9da24ab..1de1f39f37 100644
--- a/lib/media_list.c
+++ b/lib/media_list.c
@@ -446,7 +446,7 @@ int libvlc_media_list_index_of_item( libvlc_media_list_t * p_mlist,
  *
  * This indicates if this media list is read-only from a user point of view
  **************************************************************************/
-int libvlc_media_list_is_readonly( libvlc_media_list_t * p_mlist )
+bool libvlc_media_list_is_readonly( libvlc_media_list_t * p_mlist )
 {
     return p_mlist->b_read_only;
 }
diff --git a/lib/media_list_player.c b/lib/media_list_player.c
index 0131f4e99e..c4ae8c4043 100644
--- a/lib/media_list_player.c
+++ b/lib/media_list_player.c
@@ -660,8 +660,7 @@ void libvlc_media_list_player_set_pause(libvlc_media_list_player_t * p_mlp,
 /**************************************************************************
  *        is_playing (Public)
  **************************************************************************/
-int
-libvlc_media_list_player_is_playing(libvlc_media_list_player_t * p_mlp)
+bool libvlc_media_list_player_is_playing(libvlc_media_list_player_t * p_mlp)
 {
     libvlc_state_t state = libvlc_media_player_get_state(p_mlp->p_mi);
     return (state == libvlc_Opening) || (state == libvlc_Playing);
diff --git a/lib/media_player.c b/lib/media_player.c
index ccc163c2d0..ddb5509721 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1081,7 +1081,7 @@ void libvlc_media_player_pause( libvlc_media_player_t *p_mi )
 /**************************************************************************
  * Tells whether the media player is currently playing.
  **************************************************************************/
-int libvlc_media_player_is_playing( libvlc_media_player_t *p_mi )
+bool libvlc_media_player_is_playing(libvlc_media_player_t *p_mi)
 {
     libvlc_state_t state = libvlc_media_player_get_state( p_mi );
     return libvlc_Playing == state;
@@ -1162,15 +1162,15 @@ void libvlc_video_set_format( libvlc_media_player_t *mp, const char *chroma,
     var_SetInteger( mp, "vmem-pitch", pitch );
 }
 
-int libvlc_video_set_output_callbacks( libvlc_media_player_t *mp,
-                                        libvlc_video_engine_t engine,
-                                        libvlc_video_setup_cb setup_cb,
-                                        libvlc_video_cleanup_cb cleanup_cb,
-                                        libvlc_video_update_output_cb update_output_cb,
-                                        libvlc_video_swap_cb swap_cb,
-                                        libvlc_video_makeCurrent_cb makeCurrent_cb,
-                                        libvlc_video_getProcAddress_cb getProcAddress_cb,
-                                        void* opaque )
+bool libvlc_video_set_output_callbacks(libvlc_media_player_t *mp,
+                                       libvlc_video_engine_t engine,
+                                       libvlc_video_setup_cb setup_cb,
+                                       libvlc_video_cleanup_cb cleanup_cb,
+                                       libvlc_video_update_output_cb update_output_cb,
+                                       libvlc_video_swap_cb swap_cb,
+                                       libvlc_video_makeCurrent_cb makeCurrent_cb,
+                                       libvlc_video_getProcAddress_cb getProcAddress_cb,
+                                       void *opaque)
 {
 #ifdef __ANDROID__
     //use the default android window
@@ -1190,7 +1190,7 @@ int libvlc_video_set_output_callbacks( libvlc_media_player_t *mp,
         var_SetString ( mp, "gl", "vgl");
     }
     else
-        return 0;
+        return false;
 
     var_SetAddress( mp, "vout-cb-opaque", opaque );
     var_SetAddress( mp, "vout-cb-setup", setup_cb );
@@ -1199,19 +1199,19 @@ int libvlc_video_set_output_callbacks( libvlc_media_player_t *mp,
     var_SetAddress( mp, "vout-cb-swap", swap_cb );
     var_SetAddress( mp, "vout-cb-get-proc-address", getProcAddress_cb );
     var_SetAddress( mp, "vout-cb-make-current", makeCurrent_cb );
-    return 1;
+    return true;
 }
 
 
-int libvlc_video_direct3d_set_callbacks( libvlc_media_player_t *mp,
-                                        libvlc_video_direct3d_engine_t engine,
-                                        libvlc_video_direct3d_device_setup_cb setup_cb,
-                                        libvlc_video_direct3d_device_cleanup_cb cleanup_cb,
-                                        libvlc_video_direct3d_update_output_cb update_output_cb,
-                                        libvlc_video_swap_cb swap_cb,
-                                        libvlc_video_direct3d_start_end_rendering_cb makeCurrent_cb,
-                                        libvlc_video_direct3d_select_plane_cb select_plane_cb,
-                                        void* opaque )
+bool libvlc_video_direct3d_set_callbacks(libvlc_media_player_t *mp,
+                                         libvlc_video_direct3d_engine_t engine,
+                                         libvlc_video_direct3d_device_setup_cb setup_cb,
+                                         libvlc_video_direct3d_device_cleanup_cb cleanup_cb,
+                                         libvlc_video_direct3d_update_output_cb update_output_cb,
+                                         libvlc_video_swap_cb swap_cb,
+                                         libvlc_video_direct3d_start_end_rendering_cb makeCurrent_cb,
+                                         libvlc_video_direct3d_select_plane_cb select_plane_cb,
+                                         void *opaque)
 {
     var_SetString( mp, "window", "wdummy");
 
@@ -1226,7 +1226,7 @@ int libvlc_video_direct3d_set_callbacks( libvlc_media_player_t *mp,
         var_SetString ( mp, "avcodec-hw", "dxva2");
     }
     else
-        return 0;
+        return false;
 
     var_SetAddress( mp, "vout-cb-opaque", opaque );
     var_SetAddress( mp, "vout-cb-setup", setup_cb );
@@ -1235,7 +1235,7 @@ int libvlc_video_direct3d_set_callbacks( libvlc_media_player_t *mp,
     var_SetAddress( mp, "vout-cb-swap", swap_cb );
     var_SetAddress( mp, "vout-cb-make-current", makeCurrent_cb );
     var_SetAddress( mp, "vout-cb-select-plane", select_plane_cb );
-    return 1;
+    return true;
 }
 
 /**************************************************************************
@@ -1814,7 +1814,7 @@ libvlc_state_t libvlc_media_player_get_state( libvlc_media_player_t *p_mi )
     return state;
 }
 
-int libvlc_media_player_is_seekable( libvlc_media_player_t *p_mi )
+bool libvlc_media_player_is_seekable(libvlc_media_player_t *p_mi)
 {
     input_thread_t *p_input_thread;
     bool b_seekable;
@@ -1905,7 +1905,7 @@ void libvlc_track_description_list_release( libvlc_track_description_t *p_td )
     }
 }
 
-int libvlc_media_player_can_pause( libvlc_media_player_t *p_mi )
+bool libvlc_media_player_can_pause(libvlc_media_player_t *p_mi)
 {
     input_thread_t *p_input_thread;
     bool b_can_pause;
@@ -1919,7 +1919,7 @@ int libvlc_media_player_can_pause( libvlc_media_player_t *p_mi )
     return b_can_pause;
 }
 
-int libvlc_media_player_program_scrambled( libvlc_media_player_t *p_mi )
+bool libvlc_media_player_program_scrambled(libvlc_media_player_t *p_mi)
 {
     input_thread_t *p_input_thread;
     bool b_program_scrambled;
diff --git a/lib/video.c b/lib/video.c
index 4eee0b8d59..cb7838a28a 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -109,7 +109,7 @@ void libvlc_set_fullscreen(libvlc_media_player_t *p_mi, bool b_fullscreen)
     free (pp_vouts);
 }
 
-int libvlc_get_fullscreen( libvlc_media_player_t *p_mi )
+bool libvlc_get_fullscreen( libvlc_media_player_t *p_mi )
 {
     return var_GetBool (p_mi, "fullscreen");
 }



More information about the vlc-commits mailing list