~ubuntu-branches/ubuntu/karmic/vlc/karmic-proposed

« back to all changes in this revision

Viewing changes to src/input/var.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-07-10 16:18:23 UTC
  • mfrom: (1.1.23 upstream) (3.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20090710161823-3pllnay3xzyougxm
Tags: 1.0.0-1ubuntu1
* Remaining changes to debian:
  - build against libxul-dev instead of iceape-dev
  - build against libass-dev and libx264-dev
  - build against and install libx264 plugin
  - add Xb-Npp header to vlc package

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * var.c: object variables for input thread
3
3
 *****************************************************************************
4
4
 * Copyright (C) 2004-2007 the VideoLAN team
5
 
 * $Id$
 
5
 * $Id: fcad8118d8ae7eade55d8418b008cf5a90e257fa $
6
6
 *
7
7
 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8
8
 *
580
580
                             void *p_data )
581
581
{
582
582
    input_thread_t *p_input = (input_thread_t*)p_this;
583
 
    vlc_value_t val, length;
584
583
    VLC_UNUSED(oldval); VLC_UNUSED(p_data);
585
584
 
586
585
    if( !strcmp( psz_cmd, "position-offset" ) )
587
586
    {
588
 
        input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION_OFFSET, &newval );
589
 
 
590
 
        val.f_float = var_GetFloat( p_input, "position" ) + newval.f_float;
591
 
        if( val.f_float < 0.0 ) val.f_float = 0.0;
592
 
        if( val.f_float > 1.0 ) val.f_float = 1.0;
593
 
        var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
 
587
        float f_position = var_GetFloat( p_input, "position" ) + newval.f_float;
 
588
        if( f_position < 0.0 )
 
589
            f_position = 0.0;
 
590
        else if( f_position > 1.0 )
 
591
            f_position = 1.0;
 
592
        var_SetFloat( p_this, "position", f_position );
594
593
    }
595
594
    else
596
595
    {
597
 
        val.f_float = newval.f_float;
 
596
        /* Update "length" for better intf behavour */
 
597
        const mtime_t i_length = var_GetTime( p_input, "length" );
 
598
        if( i_length > 0 && newval.f_float >= 0.0 && newval.f_float <= 1.0 )
 
599
        {
 
600
            vlc_value_t val;
 
601
 
 
602
            val.i_time = i_length * newval.f_float;
 
603
            var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
 
604
        }
 
605
 
 
606
        /* */
598
607
        input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION, &newval );
599
608
    }
600
 
 
601
 
    /* Update "position" for better intf behavour */
602
 
    var_Get( p_input, "length", &length );
603
 
    if( length.i_time > 0 && val.f_float >= 0.0 && val.f_float <= 1.0 )
604
 
    {
605
 
        val.i_time = length.i_time * val.f_float;
606
 
        var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
607
 
    }
608
 
 
609
609
    return VLC_SUCCESS;
610
610
}
611
611
 
613
613
                         vlc_value_t oldval, vlc_value_t newval, void *p_data )
614
614
{
615
615
    input_thread_t *p_input = (input_thread_t*)p_this;
616
 
    vlc_value_t val, length;
617
616
    VLC_UNUSED(oldval); VLC_UNUSED(p_data);
618
617
 
619
618
    if( !strcmp( psz_cmd, "time-offset" ) )
620
619
    {
621
 
        input_ControlPush( p_input, INPUT_CONTROL_SET_TIME_OFFSET, &newval );
622
 
        val.i_time = var_GetTime( p_input, "time" ) + newval.i_time;
623
 
        if( val.i_time < 0 ) val.i_time = 0;
624
 
        /* TODO maybe test against i_length ? */
625
 
        var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
 
620
        mtime_t i_time = var_GetTime( p_input, "time" ) + newval.i_time;
 
621
        if( i_time < 0 )
 
622
            i_time = 0;
 
623
        var_SetTime( p_this, "time", i_time );
626
624
    }
627
625
    else
628
626
    {
629
 
        val.i_time = newval.i_time;
 
627
        /* Update "position" for better intf behavour */
 
628
        const mtime_t i_length = var_GetTime( p_input, "length" );
 
629
        if( i_length > 0 && newval.i_time >= 0 && newval.i_time <= i_length )
 
630
        {
 
631
            vlc_value_t val;
 
632
 
 
633
            val.f_float = (double)newval.i_time/(double)i_length;
 
634
            var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
 
635
        }
 
636
 
 
637
        /* */
630
638
        input_ControlPush( p_input, INPUT_CONTROL_SET_TIME, &newval );
631
639
    }
632
 
 
633
 
    /* Update "position" for better intf behavour */
634
 
    var_Get( p_input, "length", &length );
635
 
    if( length.i_time > 0 && val.i_time >= 0 && val.i_time <= length.i_time )
636
 
    {
637
 
        val.f_float = (double)val.i_time/(double)length.i_time;
638
 
        var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
639
 
    }
640
 
 
641
640
    return VLC_SUCCESS;
642
641
}
643
642
 
714
713
    else
715
714
    {
716
715
        input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT, &newval );
 
716
        val.i_int = newval.i_int;
 
717
    }
 
718
 
 
719
    /* Actualize "title %2i" variable */
 
720
    if( val.i_int >= 0 && val.i_int < count.i_int )
 
721
    {
 
722
        int i_title = var_GetInteger( p_input, "title" );
 
723
        char psz_titlevar[10] = {0};
 
724
        snprintf( psz_titlevar, 10, "title %2i", i_title );
 
725
        var_Change( p_input, psz_titlevar, VLC_VAR_SETVALUE, &val, NULL );
717
726
    }
718
727
 
719
728
    return VLC_SUCCESS;