Example #1
0
File: aout.c Project: AsamQi/vlc
/**
 * Raises the volume.
 * \param value how much to increase (> 0) or decrease (< 0) the volume
 * \param volp if non-NULL, will contain contain the resulting volume
 */
int playlist_VolumeUp (playlist_t *pl, int value, float *volp)
{
    int ret = -1;

    float delta = value * var_InheritFloat (pl, "volume-step");

    audio_output_t *aout = playlist_GetAout (pl);
    if (aout != NULL)
    {
        float vol = aout_VolumeGet (aout);
        if (vol >= 0.)
        {
            vol += delta / (float)AOUT_VOLUME_DEFAULT;
            if (vol < 0.)
                vol = 0.;
            if (vol > 2.)
                vol = 2.;
            if (volp != NULL)
                *volp = vol;
            ret = aout_VolumeSet (aout, vol);
        }
        vlc_object_release (aout);
    }
    return ret;
}
Example #2
0
File: aout.c Project: mstorsjo/vlc
void playlist_EnableAudioFilter (playlist_t *pl, const char *name, bool add)
{
    audio_output_t *aout = playlist_GetAout (pl);
    if (aout)
    {
        aout_EnableFilter(aout, name, add);
        vlc_object_release (aout);
    }
}
Example #3
0
File: aout.c Project: AsamQi/vlc
int playlist_VolumeSet (playlist_t *pl, float vol)
{
    int ret = -1;

    audio_output_t *aout = playlist_GetAout (pl);
    if (aout != NULL)
    {
        ret = aout_VolumeSet (aout, vol);
        vlc_object_release (aout);
    }
    return ret;
}
Example #4
0
File: aout.c Project: AsamQi/vlc
float playlist_VolumeGet (playlist_t *pl)
{
    float volume = -1.f;

    audio_output_t *aout = playlist_GetAout (pl);
    if (aout != NULL)
    {
        volume = aout_VolumeGet (aout);
        vlc_object_release (aout);
    }
    return volume;
}
Example #5
0
File: aout.c Project: AsamQi/vlc
int playlist_MuteSet (playlist_t *pl, bool mute)
{
    int ret = -1;

    audio_output_t *aout = playlist_GetAout (pl);
    if (aout != NULL)
    {
        ret = aout_MuteSet (aout, mute);
        vlc_object_release (aout);
    }
    return ret;
}
Example #6
0
File: aout.c Project: AsamQi/vlc
int playlist_MuteGet (playlist_t *pl)
{
    int mute = -1;

    audio_output_t *aout = playlist_GetAout (pl);
    if (aout != NULL)
    {
        mute = aout_MuteGet (aout);
        vlc_object_release (aout);
    }
    return mute;
}
Example #7
0
File: aout.c Project: mstorsjo/vlc
/**
 * Raises the volume.
 * \param value how much to increase (> 0) or decrease (< 0) the volume
 * \param volp if non-NULL, will contain contain the resulting volume
 */
int playlist_VolumeUp (playlist_t *pl, int value, float *volp)
{
    int ret = -1;

    audio_output_t *aout = playlist_GetAout (pl);
    if (aout != NULL)
    {
        ret = aout_VolumeUpdate (aout, value, volp);
        vlc_object_release (aout);
    }
    return ret;
}
Example #8
0
File: aout.c Project: AsamQi/vlc
void playlist_EnableAudioFilter (playlist_t *pl, const char *name, bool add)
{
    audio_output_t *aout = playlist_GetAout (pl);

    if (aout_ChangeFilterString (VLC_OBJECT(pl), VLC_OBJECT(aout),
                                 "audio-filter", name, add))
    {
        if (aout != NULL)
            aout_InputRequestRestart (aout);
    }
    if (aout != NULL)
        vlc_object_release (aout);
}
Example #9
0
void VlcProc::init_equalizer()
{
    playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
    audio_output_t* pAout = playlist_GetAout( pPlaylist );
    if( pAout )
    {
        if( !var_Type( pAout, "equalizer-bands" ) )
            var_Create( pAout, "equalizer-bands",
                        VLC_VAR_STRING | VLC_VAR_DOINHERIT);
        if( !var_Type( pAout, "equalizer-preamp" ) )
            var_Create( pAout, "equalizer-preamp",
                        VLC_VAR_FLOAT | VLC_VAR_DOINHERIT);

        // New Aout (addCallbacks)
        var_AddCallback( pAout, "audio-filter",
                         onGenericCallback, this );
        var_AddCallback( pAout, "equalizer-bands",
                         onEqBandsChange, this );
        var_AddCallback( pAout, "equalizer-preamp",
                         onEqPreampChange, this );
    }

    // is equalizer enabled ?
    char *pFilters = pAout ?
                   var_GetNonEmptyString( pAout, "audio-filter" ) :
                   var_InheritString( getIntf(), "audio-filter" );
    bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
    free( pFilters );
    SET_BOOL( m_cVarEqualizer, b_equalizer );

    // retrieve initial bands
    char* bands = pAout ?
                  var_GetString( pAout, "equalizer-bands" ) :
                  var_InheritString( getIntf(), "equalizer-bands" );
    if( bands )
    {
        m_varEqBands.set( bands );
        free( bands );
    }

    // retrieve initial preamp
    float preamp = pAout ?
                   var_GetFloat( pAout, "equalizer-preamp" ) :
                   var_InheritFloat( getIntf(), "equalizer-preamp" );
    EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)m_cVarEqPreamp.get();
    pVarPreamp->set( (preamp + 20.0) / 40.0 );

    if( pAout )
        vlc_object_release( pAout);
}
Example #10
0
static int vlclua_get_aout( lua_State *L )
{
    playlist_t *p_playlist = vlclua_get_playlist_internal( L );
    if( p_playlist != NULL )
    {
        audio_output_t *p_aout = playlist_GetAout( p_playlist );
        if( p_aout != NULL )
        {
            vlclua_push_vlc_object( L, (vlc_object_t *)p_aout );
            return 1;
        }
    }
    lua_pushnil( L );
    return 1;
}
Example #11
0
void EqualizerPreamp::set( float percentage, bool updateVLC )
{
    playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
    audio_output_t *pAout = playlist_GetAout( pPlaylist );

    VarPercent::set( percentage );

    // Avoid infinite loop
    if( updateVLC )
    {
        float val = 40 * percentage - 20;

        config_PutFloat( getIntf(), "equalizer-preamp", val );
        if( pAout )
        {
            // Update the audio output
            var_SetFloat( pAout, "equalizer-preamp", val );
        }
    }

    if( pAout )
        vlc_object_release( pAout );
}
Example #12
0
void EqualizerBands::onUpdate( Subject<VarPercent> &rBand, void *arg )
{
    (void)rBand;
    (void)arg;
    playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
    audio_output_t *pAout = playlist_GetAout( pPlaylist );

    // Make sure we are not called from set()
    if (!m_isUpdating)
    {
        float val;
        stringstream ss;
        // Write one digit after the floating point
        ss << setprecision( 1 ) << setiosflags( ios::fixed );

        // Convert the band values to a string
        val = 40 * ((VarPercent*)m_cBands[0].get())->get() - 20;
        ss << val;
        for( int i = 1; i < kNbBands; i++ )
        {
            val = 40 * ((VarPercent*)m_cBands[i].get())->get() - 20;
            ss << " " << val;
        }

        string bands = ss.str();

        config_PutPsz( getIntf(), "equalizer-bands", bands.c_str() );
        if( pAout )
        {
            // Update the audio output
            var_SetString( pAout, "equalizer-bands", (char*)bands.c_str() );
        }
    }

    if( pAout )
        vlc_object_release( pAout );
}