Commit 80717989 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Fix part of the extended panel generation using us_strtod()

parent f15e81c7
...@@ -828,7 +828,7 @@ Equalizer::Equalizer( intf_thread_t *_p_intf, QWidget *_parent ) : ...@@ -828,7 +828,7 @@ Equalizer::Equalizer( intf_thread_t *_p_intf, QWidget *_parent ) :
bands[i] = new QSlider( Qt::Vertical ); bands[i] = new QSlider( Qt::Vertical );
bands[i]->setMaximum( 400 ); bands[i]->setMaximum( 400 );
bands[i]->setValue( 200 ); bands[i]->setValue( 200 );
CONNECT( bands[i], valueChanged( int ), this, setBand() ); CONNECT( bands[i], valueChanged( int ), this, changeCoreBands() );
band_texts[i] = new QLabel( band_frequencies[i] + "\n0.0dB" ); band_texts[i] = new QLabel( band_frequencies[i] + "\n0.0dB" );
band_texts[i]->setFont( smallFont ); band_texts[i]->setFont( smallFont );
grid->addWidget( bands[i], 0, i ); grid->addWidget( bands[i], 0, i );
...@@ -863,7 +863,7 @@ Equalizer::Equalizer( intf_thread_t *_p_intf, QWidget *_parent ) : ...@@ -863,7 +863,7 @@ Equalizer::Equalizer( intf_thread_t *_p_intf, QWidget *_parent ) :
free( psz_af ); free( psz_af );
enable( ui.enableCheck->isChecked() ); enable( ui.enableCheck->isChecked() );
setValues( psz_bands, f_preamp ); updateUIValues( psz_bands, f_preamp );
} }
Equalizer::~Equalizer() Equalizer::~Equalizer()
...@@ -921,7 +921,8 @@ void Equalizer::setPreamp() ...@@ -921,7 +921,8 @@ void Equalizer::setPreamp()
aout_instance_t *p_aout= ( aout_instance_t * )vlc_object_find( p_intf, aout_instance_t *p_aout= ( aout_instance_t * )vlc_object_find( p_intf,
VLC_OBJECT_AOUT, FIND_ANYWHERE ); VLC_OBJECT_AOUT, FIND_ANYWHERE );
ui.preampLabel->setText( qtr( "Preamp\n" ) + QString::number( f, 'f', 1 ) + qtr( "dB" ) ); ui.preampLabel->setText( qtr( "Preamp\n" ) + QString::number( f, 'f', 1 )
+ qtr( "dB" ) );
if( p_aout ) if( p_aout )
{ {
delCallbacks( p_aout ); delCallbacks( p_aout );
...@@ -932,14 +933,14 @@ void Equalizer::setPreamp() ...@@ -932,14 +933,14 @@ void Equalizer::setPreamp()
config_PutFloat( p_intf, "equalizer-preamp", f ); config_PutFloat( p_intf, "equalizer-preamp", f );
} }
void Equalizer::setBand() void Equalizer::changeCoreBands()
{ {
/**\todo smoothing */ /**\todo smoothing */
QString values; QString values;
for( int i = 0; i < BANDS; i++ ) for( int i = 0; i < BANDS; i++ )
{ {
const float f_val = (float)( bands[i]->value() ) / 10 - 20; const float f_val = (float)( bands[i]->value() ) / 10 - 20;
QString val = QString("%1").arg( f_val, 5, 'f', 1 ); QString val = QString("%1").arg( f_val, 5, 'f', 1 );
band_texts[i]->setText( band_frequencies[i] + "\n" + val + "dB" ); band_texts[i]->setText( band_frequencies[i] + "\n" + val + "dB" );
...@@ -957,14 +958,15 @@ void Equalizer::setBand() ...@@ -957,14 +958,15 @@ void Equalizer::setBand()
vlc_object_release( p_aout ); vlc_object_release( p_aout );
} }
} }
void Equalizer::setValues( char *psz_bands, float f_preamp )
void Equalizer::updateUIValues( char *psz_bands, float f_preamp )
{ {
char *p = psz_bands; char *p = psz_bands;
if ( p ) if ( p )
{ {
for( int i = 0; i < BANDS; i++ ) for( int i = 0; i < BANDS; i++ )
{ {
const float f = strtof( p, &p ); const float f = us_strtod(p, &p );
bands[i]->setValue( (int)( ( f + 20 ) * 10 ) ); bands[i]->setValue( (int)( ( f + 20 ) * 10 ) );
...@@ -977,36 +979,47 @@ void Equalizer::setValues( char *psz_bands, float f_preamp ) ...@@ -977,36 +979,47 @@ void Equalizer::setValues( char *psz_bands, float f_preamp )
} }
} }
ui.preampSlider->setValue( (int)( ( f_preamp + 20 ) * 10 ) ); ui.preampSlider->setValue( (int)( ( f_preamp + 20 ) * 10 ) );
ui.preampLabel->setText( qtr( "Preamp\n" ) + QString::number( f_preamp, 'f', 1 ) + qtr( "dB" ) ); ui.preampLabel->setText( qtr( "Preamp\n" )
+ QString::number( f_preamp, 'f', 1 ) + qtr( "dB" ) );
} }
void Equalizer::setPreset( int preset ) char * Equalizer::createValuesFromPreset( int i_preset )
{ {
aout_instance_t *p_aout= ( aout_instance_t * )vlc_object_find( p_intf,
VLC_OBJECT_AOUT, FIND_ANYWHERE );
QString values; QString values;
char *psz_values;
/* Create the QString in Qt */
for( int i = 0 ; i< BANDS ;i++ ) for( int i = 0 ; i< BANDS ;i++ )
values += QString( " %1" ).arg( eqz_preset_10b[preset]->f_amp[i] ); values += QString( " %1" ).arg( eqz_preset_10b[i_preset]->f_amp[i] );
/* Convert it to char * */
if( !asprintf( &psz_values, "%s", values.toAscii().constData() ) )
return NULL;
/* XXX Only needed because of setValues */ /* Update the UI */
char psz_values[256]; updateUIValues( psz_values, eqz_preset_10b[i_preset]->f_preamp );
snprintf( psz_values, sizeof(psz_values), "%s", values.toAscii().constData() ); return psz_values;
}
void Equalizer::setPreset( int i_preset )
{
char *psz_values = createValuesFromPreset( i_preset );
if( !psz_values ) return ;
aout_instance_t *p_aout= ( aout_instance_t * )vlc_object_find( p_intf,
VLC_OBJECT_AOUT, FIND_ANYWHERE );
if( p_aout ) if( p_aout )
{ {
delCallbacks( p_aout ); delCallbacks( p_aout );
var_SetString( p_aout, "equalizer-bands", psz_values ); var_SetString( p_aout, "equalizer-bands", psz_values );
var_SetFloat( p_aout, "equalizer-preamp", var_SetFloat( p_aout, "equalizer-preamp",
eqz_preset_10b[preset]->f_preamp ); eqz_preset_10b[i_preset]->f_preamp );
addCallbacks( p_aout ); addCallbacks( p_aout );
vlc_object_release( p_aout ); vlc_object_release( p_aout );
} }
config_PutPsz( p_intf, "equalizer-bands", psz_values ); config_PutPsz( p_intf, "equalizer-bands", psz_values );
config_PutFloat( p_intf, "equalizer-preamp", config_PutFloat( p_intf, "equalizer-preamp",
eqz_preset_10b[preset]->f_preamp ); eqz_preset_10b[i_preset]->f_preamp );
setValues( psz_values, eqz_preset_10b[preset]->f_preamp );
} }
static int PresetCallback( vlc_object_t *p_this, char const *psz_cmd, static int PresetCallback( vlc_object_t *p_this, char const *psz_cmd,
......
...@@ -101,7 +101,8 @@ private: ...@@ -101,7 +101,8 @@ private:
void delCallbacks( aout_instance_t * ); void delCallbacks( aout_instance_t * );
void addCallbacks( aout_instance_t * ); void addCallbacks( aout_instance_t * );
void setValues( char *, float ); void updateUIValues( char *, float );
char * createValuesFromPreset( int i_preset );
intf_thread_t *p_intf; intf_thread_t *p_intf;
private slots: private slots:
...@@ -109,7 +110,7 @@ private slots: ...@@ -109,7 +110,7 @@ private slots:
void enable(); void enable();
void set2Pass(); void set2Pass();
void setPreamp(); void setPreamp();
void setBand(); void changeCoreBands();
void setPreset(int); void setPreset(int);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment