[vlc-devel] [RFC PATCH] libvlc: don't preclude use a libvlc_video_viewpoint_t on stack

Thomas Guillem thomas at gllm.fr
Thu Aug 30 10:29:43 CEST 2018


On Thu, Aug 30, 2018, at 08:03, Zhao Zhili wrote:
> ---
> I find libvlc_video_new_viewpoint() kind of misleading. The following
> code comes from libvlc/jni/libvlcjni-mediaplayer.c
> 
>     if (p_obj->p_sys->p_vp == NULL)
>     {
>         p_obj->p_sys->p_vp = libvlc_video_new_viewpoint();
>         if (p_obj->p_sys->p_vp == NULL)
>             return false;
>     }
>     p_obj->p_sys->p_vp->f_yaw = yaw;
>     p_obj->p_sys->p_vp->f_pitch = pitch;
>     p_obj->p_sys->p_vp->f_roll = roll;
>     p_obj->p_sys->p_vp->f_field_of_view = fov;
> 
>     return libvlc_video_update_viewpoint(p_obj->u.p_mp, p_obj->p_sys->p_vp,
>                                          absolute) == 0 ? true : false;
> 
> It would be more simple to use a variable on stack.

Yes, but we did it that way for ABI compatibility. If we add members to this struct in the future, programs built with 3.0 will still be able to link with 4.0 (but we may break totally the ABI between 3.0 and 4.0 so...).

> 
>  include/vlc/libvlc_media_player.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/
> libvlc_media_player.h
> index 73dadda..c9b2104 100644
> --- a/include/vlc/libvlc_media_player.h
> +++ b/include/vlc/libvlc_media_player.h
> @@ -1285,7 +1285,7 @@ LIBVLC_API libvlc_video_viewpoint_t 
> *libvlc_video_new_viewpoint(void);
>   * \version LibVLC 3.0.0 and later
>   *
>   * \param p_mi the media player
> - * \param p_viewpoint video viewpoint allocated via 
> libvlc_video_new_viewpoint()
> + * \param p_viewpoint video viewpoint
>   * \param b_absolute if true replace the old viewpoint with the new 
> one. If
>   * false, increase/decrease it.
>   * \return -1 in case of error, 0 otherwise
> -- 
> 2.9.5
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list