[vlc-devel] [PATCH] Blu-Ray basic support

Rémi Denis-Courmont remi at remlab.net
Mon Sep 20 19:13:10 CEST 2010


On Mon, 20 Sep 2010 15:52:21 +0200, Jean-Baptiste Kempf <jb at videolan.org>
wrote:
> +    /* store current bd_path */
> +    strncpy(bd_path, p_access->psz_location, sizeof( bd_path));

Cosmetic                                               ^  but  ^

> +    if ( (pos_title = strrchr(bd_path, ':')) ) {
> +        /* found character ':' for title information */
> +        pos_title[0] = '\0';
> +        i_title = atoi(pos_title + 1);
> +    }

That seems correct. While I don't care much, this is more usual:

   *(pos_title++) = '\0';
   i_title = atoi(pos_title);


> +    p_sys->bluray = bd_open(bd_path, NULL);
> +    if ( !p_sys->bluray ) {
> +        return VLC_EGENERIC;

Memory leak (1).

> +    }
> +
> +    /* set start title number */
> +    if ( bluraySetTitle(p_access, i_title) != VLC_SUCCESS ) {
> +        return VLC_EGENERIC;

Memory leaks.

> +    }
> +
> +    p_sys->i_bd_delay = var_InheritInteger(p_access, "bluray-caching");
> +
> +    return VLC_SUCCESS;
> +}
> +
> +
>
+/*****************************************************************************
> + * blurayClose: module destroy function
> +
>
*****************************************************************************/
> +static void blurayClose( vlc_object_t *object )
> +{
> +    access_t *p_access = (access_t*)object;
> +    access_sys_t *p_sys = p_access->p_sys;
> +
> +    /* bd_close( NULL ) can crash */
> +    if ( p_sys->bluray != NULL ) {

Always true because of (1).

> +        bd_close(p_sys->bluray);
> +    }
> +}
> +
> +
>
+/*****************************************************************************
> + * bluraySetTitle: select new BD title
> +
>
*****************************************************************************/
> +static int bluraySetTitle(access_t *p_access, int i_title)
> +{
> +    access_sys_t *p_sys = p_access->p_sys;
> +
> +    /* Select Blu-Ray title */
> +    if ( bd_select_title(p_access->p_sys->bluray, i_title) == 0 ) {
> +        msg_Err( p_access, "cannot select bd title '%d'",
> p_access->info.i_title);
> +        return VLC_EGENERIC;
> +    }
> +
> +    /* read title length and init some values */
> +    p_access->info.i_title = i_title;
> +    p_access->info.i_size  = bd_get_title_size(p_sys->bluray);
> +    p_access->info.i_pos   = 0;
> +    p_access->info.b_eof   = false;
> +    p_access->info.i_seekpoint = 0;
> +
> +    return VLC_SUCCESS;
> +}
> +
> +
>
+/*****************************************************************************
> + * blurayControl: handle the controls
> +
>
*****************************************************************************/
> +static int blurayControl(access_t *p_access, int query, va_list args)
> +{
> +    access_sys_t *p_sys = p_access->p_sys;
> +    bool     *pb_bool;
> +    int64_t  *pi_64;
> +    uint32_t pos;
> +
> +    switch (query) {
> +        case ACCESS_CAN_SEEK:
> +        case ACCESS_CAN_FASTSEEK:
> +        case ACCESS_CAN_PAUSE:
> +             pb_bool = (bool*)va_arg( args, bool * );
> +             *pb_bool = true;
> +             break;
> +
> +        case ACCESS_CAN_CONTROL_PACE:
> +            pb_bool = (bool*)va_arg( args, bool* );
> +            *pb_bool = true;
> +            break;

You could factor that case with the previous ones. I don't really care.

-- 
Rémi Denis-Courmont
http://www.remlab.net
http://fi.linkedin.com/in/remidenis




More information about the vlc-devel mailing list