[vlc-devel] [PATCH] input: set OSD message when changing rate via hotkeys to display the current rate (v4)

Pankaj yadav pankajdnapster at gmail.com
Fri Mar 26 05:48:07 CET 2010


Dont you think Inclusion of stdio.h ,math.h ,assert.h etc is
redundant???????AFAIK vlc_common.h takes care of all

On Fri, Mar 26, 2010 at 5:31 AM, Casian Andrei <skeletk13 at gmail.com> wrote:

> Hello,
>
> Done the modfications. Set the editor to highlight trailing whitespaces, so
> no more of those.
>
> Regards,
> Casian
>
> On Thu, Mar 25, 2010 at 10:41 PM, Laurent Aimar <fenrir at via.ecp.fr> wrote:
>
>> Hi,
>>
>> On Wed, Mar 24, 2010, Casian Andrei wrote:
>> > +static void DisplayRate( input_thread_t *p_input, float f_rate )
>> > +{
>> > +    char psz_msg[14 + 1];
>> > +
>> > +    if( p_input == NULL ) return;
>> Useless test, DisplayRate cannot be called with a NULL input.
>> > +
>> > +    snprintf( psz_msg, sizeof(psz_msg), _("Speed: %.2fx"), f_rate );
>> > +    vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, "%s", psz_msg
>> );
>> In fact you can merge them both (and remove psz_msg):
>>  vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, _("Speed: %.2fx"),
>> f_rate );
>>
>> > diff --git a/src/input/var.c b/src/input/var.c
>> > index 781ce7c..3975bb9 100644
>> > --- a/src/input/var.c
>> > +++ b/src/input/var.c
>> > @@ -29,6 +29,8 @@
>> >  #endif
>> >
>> >  #include <vlc_common.h>
>> > +#include <assert.h>
>> > +#include <math.h>
>> >  #include <stdio.h>
>> >  #include <stdlib.h>
>> >
>> > @@ -565,23 +567,68 @@ static int RateCallback( vlc_object_t *p_this,
>> char const *psz_cmd,
>> >  {
>> >      input_thread_t *p_input = (input_thread_t*)p_this;
>> >      VLC_UNUSED(oldval); VLC_UNUSED(p_data);
>> > +
>> > +    static const int ppi_factor[][2] = {
>> > +        {1,64}, {1,32}, {1,16}, {1,8}, {1,4}, {1,3}, {1,2}, {2,3},
>> > +        {1,1},
>> > +        {3,2}, {2,1}, {3,1}, {4,1}, {8,1}, {16,1}, {32,1}, {64,1},
>> > +        {0,0}
>> > +    };
>> > +
>> > +    int i;
>> > +    int i_idx;
>> > +    float f_rate = var_GetFloat( p_input, "rate" );
>> > +    float f_sign = f_rate >= 0 ? +1. : -1.;
>> > +    float f_error;
>> > +
>> > +    /* Determine the factor closest to the current rate */
>> > +    f_error = 1E20;
>> > +    i_idx = -1;
>> > +    for( i = 0; ppi_factor[i][0] != 0; i++ )
>> > +    {
>> > +        const float f_test_r = (float)ppi_factor[i][0] /
>> ppi_factor[i][1];
>> > +        const float f_test_e = fabs( fabs( f_rate ) - f_test_r );
>> > +        if( f_test_e < f_error )
>> > +        {
>> > +            i_idx = i;
>> > +            f_error = f_test_e;
>> > +        }
>> > +    }
>> >
>> > -    /* Problem with this way: the "rate" variable is updated after the
>> > -     * input thread did the change */
>> > -
>> > +    assert( i_idx >= 0 && ppi_factor[i_idx][0] != 0 );
>> > +
>> > +    float f_new_rate;
>> > +    const float f_rate_min = (float)INPUT_RATE_DEFAULT /
>> INPUT_RATE_MAX;
>> > +    const float f_rate_max = (float)INPUT_RATE_DEFAULT /
>> INPUT_RATE_MIN;
>> > +
>> >      if( !strcmp( psz_cmd, "rate-slower" ) )
>> >      {
>> > -        input_ControlPush( p_input, INPUT_CONTROL_SET_RATE_SLOWER, NULL
>> );
>> > +        if( ppi_factor[i_idx+1][0] > 0 )
>>  You forgot to fix the test (i_idx > 0).
>> > +            f_new_rate = (float)ppi_factor[i_idx-1][0] /
>> ppi_factor[i_idx-1][1];
>> > +        else
>> > +            f_new_rate = f_rate_min;
>> > +        f_new_rate *= f_sign;
>> > +
>>
>> Also there is a lot of trailings whitespaces that should be removed from
>> your patch.
>>
>> Regards,
>>
>> --
>> fenrir
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> http://mailman.videolan.org/listinfo/vlc-devel
>>
>
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> http://mailman.videolan.org/listinfo/vlc-devel
>
>


-- 
Pankaj Yadav
Integrated Dual Degree Pt-III
Deptt. of Mining Engg.
Institute of Technology
Banaras Hindu University,Varanasi,India
Admin-MAHASERVER
Personal: pankajdnapster at gmail.com
Academic : pankaj.yadav.min07 at itbhu.ac.in
Professional : admin at mahaserver.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20100326/408d4934/attachment.html>


More information about the vlc-devel mailing list