+static const char *psz_control_names[] =
+{
+ "Roomsize", "Width" , "Wet", "Dry", "Damp"
+};
+
+Spatializer::Spatializer( intf_thread_t *_p_intf, QWidget *_parent ) :
+ QWidget( _parent ) , p_intf( _p_intf )
+{
+ QFont smallFont = QApplication::font( static_cast<QWidget*>( 0 ) );
+ smallFont.setPointSize( smallFont.pointSize() - 3 );
+
+ QGridLayout *layout = new QGridLayout( this );
+ layout->setMargin( 0 );
+
+ enableCheck = new QCheckBox( qtr( "Enable spatializer" ) );
+ layout->addWidget( enableCheck, 0, 0, 1, NUM_SP_CTRL );
+
+ for( int i = 0 ; i < NUM_SP_CTRL ; i++ )
+ {
+ spatCtrl[i] = new QSlider( Qt::Vertical );
+ if( i < 2 )
+ {
+ spatCtrl[i]->setMaximum( 10 );
+ spatCtrl[i]->setValue( 2 );
+ }
+ else
+ {
+ spatCtrl[i]->setMaximum( 10 );
+ spatCtrl[i]->setValue( 0 );
+ spatCtrl[i]->setMinimum( -10 );
+ }
+ oldControlVars[i] = spatCtrl[i]->value();
+ CONNECT( spatCtrl[i], valueChanged( int ), this, setInitValues() );
+ ctrl_texts[i] = new QLabel( qfu( psz_control_names[i] ) + "\n" );
+ ctrl_texts[i]->setFont( smallFont );
+ ctrl_readout[i] = new QLabel( "" );
+ ctrl_readout[i]->setFont( smallFont );
+ layout->addWidget( spatCtrl[i], 1, i );
+ layout->addWidget( ctrl_readout[i], 2, i );
+ layout->addWidget( ctrl_texts[i], 3, i );
+ }
+
+ BUTTONACT( enableCheck, enable() );
+
+ /* Write down initial values */
+ aout_instance_t *p_aout = ( aout_instance_t * )
+ vlc_object_find( p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE );
+ char *psz_af;
+
+ if( p_aout )
+ {
+ psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
+ for( int i = 0; i < NUM_SP_CTRL ; i++ )
+ {
+ controlVars[i] = var_GetFloat( p_aout, psz_control_names[i] );
+ }
+ vlc_object_release( p_aout );
+ }
+ else
+ {
+ psz_af = config_GetPsz( p_intf, "audio-filter" );
+ for( int i = 0; i < NUM_SP_CTRL ; i++ )
+ {
+ controlVars[i] = config_GetFloat( p_intf, psz_control_names[i] );
+ }
+ }
+ if( psz_af && strstr( psz_af, "spatializer" ) != NULL )
+ enableCheck->setChecked( true );
+ free( psz_af );
+ enable( enableCheck->isChecked() );
+ setValues( controlVars );
+}
+
+Spatializer::~Spatializer()
+{
+}
+
+void Spatializer::enable()
+{
+ bool en = enableCheck->isChecked();
+ aout_EnableFilter( VLC_OBJECT( p_intf ), "spatializer",
+ en ? true : false );
+ enable( en );
+}
+
+void Spatializer::enable( bool en )
+{
+ for( int i = 0 ; i< NUM_SP_CTRL; i++ )
+ {
+ spatCtrl[i]->setEnabled( en );
+ ctrl_texts[i]->setEnabled( en );
+ ctrl_readout[i]->setEnabled( en );
+ }
+}
+void Spatializer::setInitValues()
+{
+ setValues( controlVars );
+}
+
+void Spatializer::setValues( float *controlVars )
+{
+ aout_instance_t *p_aout= ( aout_instance_t * )
+ vlc_object_find( p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE );
+
+ for( int i = 0 ; i < NUM_SP_CTRL ; i++ )
+ {
+ float f = (float)( spatCtrl[i]->value() );
+ ctrl_readout[i]->setText( QString::number( f, 'f', 1 ) );
+ }
+ if( p_aout )
+ {
+ for( int i = 0 ; i < NUM_SP_CTRL ; i++ )
+ {
+ if( oldControlVars[i] != spatCtrl[i]->value() )
+ {
+ var_SetFloat( p_aout, psz_control_names[i],
+ ( float )spatCtrl[i]->value() );
+ config_PutFloat( p_intf, psz_control_names[i],
+ ( float ) spatCtrl[i]->value() );
+ oldControlVars[i] = ( float ) spatCtrl[i]->value();
+ }
+ }
+ vlc_object_release( p_aout );
+ }
+
+}
+void Spatializer::delCallbacks( aout_instance_t *p_aout )
+{
+ // var_DelCallback( p_aout, "Spatializer-bands", EqzCallback, this );
+ // var_DelCallback( p_aout, "Spatializer-preamp", EqzCallback, this );
+}
+
+void Spatializer::addCallbacks( aout_instance_t *p_aout )
+{
+ // var_AddCallback( p_aout, "Spatializer-bands", EqzCallback, this );
+ // var_AddCallback( p_aout, "Spatializer-preamp", EqzCallback, this );
+}
+
+#include <QToolButton>
+#include <QGridLayout>
+
+SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) :
+ QWidget( _parent ) , p_intf( _p_intf )
+{
+ QGroupBox *AVBox, *subsBox;
+
+ QToolButton *moinsAV, *plusAV;
+ QToolButton *moinssubs, *plussubs;
+ QToolButton *moinssubSpeed, *plussubSpeed;
+
+ QToolButton *updateButton;
+
+ QGridLayout *mainLayout = new QGridLayout( this );
+
+ /* AV sync */
+ AVBox = new QGroupBox( qtr( "Audio/Video" ) );
+ QGridLayout *AVLayout = new QGridLayout( AVBox );
+
+ moinsAV = new QToolButton;
+ moinsAV->setToolButtonStyle( Qt::ToolButtonTextOnly );
+ moinsAV->setAutoRaise( true );
+ moinsAV->setText( "-" );
+ AVLayout->addWidget( moinsAV, 0, 1, 1, 1 );
+
+ plusAV = new QToolButton;
+ plusAV->setToolButtonStyle( Qt::ToolButtonTextOnly );
+ plusAV->setAutoRaise( true );
+ plusAV->setText( "+" );
+ AVLayout->addWidget( plusAV, 0, 3, 1, 1 );
+
+ QLabel *AVLabel = new QLabel;
+ AVLabel->setText( qtr( "Advance of audio over video:" ) );
+ AVLayout->addWidget( AVLabel, 0, 0, 1, 1 );
+
+ AVSpin = new QDoubleSpinBox;
+ AVSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
+ AVSpin->setDecimals( 3 );
+ AVSpin->setMinimum( -100 );
+ AVSpin->setMaximum( 100 );
+ AVSpin->setSingleStep( 0.1 );
+ AVSpin->setToolTip( qtr( "A positive value means that\n"
+ "the audio is ahead of the video" ) );
+ AVSpin->setSuffix( "s" );
+ AVLayout->addWidget( AVSpin, 0, 2, 1, 1 );
+ mainLayout->addWidget( AVBox, 1, 0, 1, 5 );
+
+
+ /* Subs */
+ subsBox = new QGroupBox( qtr( "Subtitles/Video" ) );
+ QGridLayout *subsLayout = new QGridLayout( subsBox );
+
+ moinssubs = new QToolButton;
+ moinssubs->setToolButtonStyle( Qt::ToolButtonTextOnly );
+ moinssubs->setAutoRaise( true );
+ moinssubs->setText( "-" );
+ subsLayout->addWidget( moinssubs, 0, 1, 1, 1 );
+
+ plussubs = new QToolButton;
+ plussubs->setToolButtonStyle( Qt::ToolButtonTextOnly );
+ plussubs->setAutoRaise( true );
+ plussubs->setText( "+" );
+ subsLayout->addWidget( plussubs, 0, 3, 1, 1 );
+
+ QLabel *subsLabel = new QLabel;
+ subsLabel->setText( qtr( "Advance of subtitles over video:" ) );
+ subsLayout->addWidget( subsLabel, 0, 0, 1, 1 );
+
+ subsSpin = new QDoubleSpinBox;
+ subsSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
+ subsSpin->setDecimals( 3 );
+ subsSpin->setMinimum( -100 );
+ subsSpin->setMaximum( 100 );
+ subsSpin->setSingleStep( 0.1 );
+ subsSpin->setToolTip( qtr( "A positive value means that\n"
+ "the subtitles are ahead of the video" ) );
+ subsSpin->setSuffix( "s" );
+ subsLayout->addWidget( subsSpin, 0, 2, 1, 1 );
+
+
+ moinssubSpeed = new QToolButton;
+ moinssubSpeed->setToolButtonStyle( Qt::ToolButtonTextOnly );
+ moinssubSpeed->setAutoRaise( true );
+ moinssubSpeed->setText( "-" );
+ subsLayout->addWidget( moinssubSpeed, 1, 1, 1, 1 );
+
+ plussubSpeed = new QToolButton;
+ plussubSpeed->setToolButtonStyle( Qt::ToolButtonTextOnly );
+ plussubSpeed->setAutoRaise( true );
+ plussubSpeed->setText( "+" );
+ subsLayout->addWidget( plussubSpeed, 1, 3, 1, 1 );
+
+ QLabel *subSpeedLabel = new QLabel;
+ subSpeedLabel->setText( qtr( "Speed of the subtitles:" ) );
+ subsLayout->addWidget( subSpeedLabel, 1, 0, 1, 3 );
+
+ subSpeedSpin = new QDoubleSpinBox;
+ subSpeedSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
+ subSpeedSpin->setDecimals( 3 );
+ subSpeedSpin->setMinimum( 1 );
+ subSpeedSpin->setMaximum( 100 );
+ subSpeedSpin->setSingleStep( 0.2 );
+ subsLayout->addWidget( subSpeedSpin, 1, 2, 1, 1 );
+
+ mainLayout->addWidget( subsBox, 2, 0, 2, 5 );
+
+ updateButton = new QToolButton;
+ updateButton->setAutoRaise( true );
+ mainLayout->addWidget( updateButton, 0, 4, 1, 1 );
+
+
+ /* Various Connects */
+ CONNECT( moinsAV, clicked(), AVSpin, stepDown () );
+ CONNECT( plusAV, clicked(), AVSpin, stepUp () );
+ CONNECT( moinssubs, clicked(), subsSpin, stepDown () );
+ CONNECT( plussubs, clicked(), subsSpin, stepUp () );
+ CONNECT( moinssubSpeed, clicked(), subSpeedSpin, stepDown () );
+ CONNECT( plussubSpeed, clicked(), subSpeedSpin, stepUp () );
+ CONNECT( AVSpin, valueChanged ( double ), this, advanceAudio( double ) ) ;
+ CONNECT( subsSpin, valueChanged ( double ), this, advanceSubs( double ) ) ;
+ CONNECT( subSpeedSpin, valueChanged ( double ),
+ this, adjustSubsSpeed( double ) );
+ BUTTON_SET_ACT_I( updateButton, "", update,
+ qtr( "Force update of this dialog's values" ), update() );
+
+ /* Set it */
+ update();
+}
+
+void SyncControls::update()
+{
+ int64_t i_delay;
+ if( THEMIM->getInput() )
+ {
+ i_delay = var_GetTime( THEMIM->getInput(), "spu-delay" );
+ AVSpin->setValue( ( (double)i_delay ) / 1000000 );
+ i_delay = var_GetTime( THEMIM->getInput(), "audio-delay" );
+ subsSpin->setValue( ( (double)i_delay ) / 1000000 );
+ subSpeedSpin->setValue( var_GetFloat( THEMIM->getInput(), "sub-fps" ) );
+ }
+}
+
+void SyncControls::advanceAudio( double f_advance )
+{
+ if( THEMIM->getInput() )
+ {
+ int64_t i_delay = var_GetTime( THEMIM->getInput(), "audio-delay" );
+ i_delay += f_advance * 1000000;
+ var_SetTime( THEMIM->getInput(), "audio-delay", i_delay );
+ msg_Dbg( p_intf, "I am advancing Audio %d", f_advance );
+ }
+}
+
+void SyncControls::advanceSubs( double f_advance )
+{
+ if( THEMIM->getInput() )
+ {
+ int64_t i_delay = var_GetTime( THEMIM->getInput(), "spu-delay" );
+ i_delay += f_advance * 1000000;
+ var_SetTime( THEMIM->getInput(), "spu-delay", i_delay );
+ msg_Dbg( p_intf, "I am advancing subtitles %d", f_advance );
+ }
+}
+
+void SyncControls::adjustSubsSpeed( double f_fps )
+{
+ if( THEMIM->getInput() )
+ {
+ var_SetFloat( THEMIM->getInput(), "sub-fps", f_fps );
+ }
+}