Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

extrapanel.cpp

00001 /*****************************************************************************
00002  * extrapanel.cpp : wxWindows plugin for vlc
00003  *****************************************************************************
00004  * Copyright (C) 2000-2004, 2003 the VideoLAN team
00005  * $Id: extrapanel.cpp 13180 2005-11-10 18:43:42Z gbazin $
00006  *
00007  * Authors: Clément Stenac <[email protected]>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 /*****************************************************************************
00025  * Preamble
00026  *****************************************************************************/
00027 #include <vlc/vlc.h>
00028 #include <vlc/aout.h>
00029 #include <aout_internal.h>
00030 #include <vlc/vout.h>
00031 #include <vlc/intf.h>
00032 
00033 #include <math.h>
00034 
00035 #include "wxwidgets.h"
00036 
00037 /*****************************************************************************
00038  * Local class declarations.
00039  *****************************************************************************/
00040 
00041 /* FIXME */
00042 #define SMOOTH_TIP N_( "If this setting is not zero, the bands will move " \
00043                 "together when you move one. The higher the value is, the " \
00044                 "more correlated their movement will be." )
00045 
00046 static int IntfBandsCallback( vlc_object_t *, char const *,
00047                               vlc_value_t, vlc_value_t, void * );
00048 static int IntfPreampCallback( vlc_object_t *, char const *,
00049                                vlc_value_t, vlc_value_t, void * );
00050 static void ChangeFiltersString( intf_thread_t *, aout_instance_t *,
00051                                  char *, vlc_bool_t );
00052 static void ChangeVFiltersString( intf_thread_t *, char *, vlc_bool_t );
00053 
00054 
00055 /* IDs for the controls and the menu commands */
00056 enum
00057 {
00058     Notebook_Event,
00059 
00060     Adjust_Event,
00061     RestoreDefaults_Event,
00062 
00063     Hue_Event,
00064     Contrast_Event,
00065     Brightness_Event,
00066     Saturation_Event,
00067     Gamma_Event,
00068     Ratio_Event,
00069 
00070     FiltersInfo_Event,
00071 
00072     Filter0_Event, Filter1_Event, Filter2_Event, Filter3_Event, Filter4_Event,
00073     Filter5_Event, Filter6_Event, Filter7_Event, Filter8_Event, Filter9_Event,
00074 
00075     EqEnable_Event,
00076     Eq2Pass_Event,
00077     EqRestore_Event,
00078 
00079     Smooth_Event,
00080 
00081     Preamp_Event,
00082 
00083     Band0_Event,Band1_Event,Band2_Event,Band3_Event,Band4_Event,
00084     Band5_Event,Band6_Event,Band7_Event,Band8_Event,Band9_Event,
00085 
00086     NormVol_Event, NVSlider_Event, HeadPhone_Event
00087 };
00088 
00089 BEGIN_EVENT_TABLE( ExtraPanel, wxPanel )
00090     EVT_IDLE( ExtraPanel::OnIdle )
00091 
00092     /* Equalizer */
00093     EVT_CHECKBOX( EqEnable_Event, ExtraPanel::OnEnableEqualizer )
00094     EVT_CHECKBOX( Eq2Pass_Event, ExtraPanel::OnEq2Pass )
00095     EVT_BUTTON( EqRestore_Event, ExtraPanel::OnEqRestore )
00096 
00097     EVT_COMMAND_SCROLL( Preamp_Event, ExtraPanel::OnPreamp )
00098     EVT_COMMAND_SCROLL( Smooth_Event, ExtraPanel::OnEqSmooth )
00099 
00100     EVT_COMMAND_SCROLL(Band0_Event, ExtraPanel::OnChangeEqualizer)
00101     EVT_COMMAND_SCROLL(Band1_Event, ExtraPanel::OnChangeEqualizer)
00102     EVT_COMMAND_SCROLL(Band2_Event, ExtraPanel::OnChangeEqualizer)
00103     EVT_COMMAND_SCROLL(Band3_Event, ExtraPanel::OnChangeEqualizer)
00104     EVT_COMMAND_SCROLL(Band4_Event, ExtraPanel::OnChangeEqualizer)
00105     EVT_COMMAND_SCROLL(Band5_Event, ExtraPanel::OnChangeEqualizer)
00106     EVT_COMMAND_SCROLL(Band6_Event, ExtraPanel::OnChangeEqualizer)
00107     EVT_COMMAND_SCROLL(Band7_Event, ExtraPanel::OnChangeEqualizer)
00108     EVT_COMMAND_SCROLL(Band8_Event, ExtraPanel::OnChangeEqualizer)
00109     EVT_COMMAND_SCROLL(Band9_Event, ExtraPanel::OnChangeEqualizer)
00110 
00111     /* Video */
00112     EVT_CHECKBOX( Adjust_Event, ExtraPanel::OnEnableAdjust )
00113     EVT_BUTTON( RestoreDefaults_Event, ExtraPanel::OnRestoreDefaults )
00114 
00115     EVT_COMMAND_SCROLL(Hue_Event, ExtraPanel::OnAdjustUpdate)
00116     EVT_COMMAND_SCROLL(Contrast_Event, ExtraPanel::OnAdjustUpdate)
00117     EVT_COMMAND_SCROLL(Brightness_Event, ExtraPanel::OnAdjustUpdate)
00118     EVT_COMMAND_SCROLL(Saturation_Event, ExtraPanel::OnAdjustUpdate)
00119     EVT_COMMAND_SCROLL(Gamma_Event, ExtraPanel::OnAdjustUpdate)
00120 
00121     EVT_BUTTON( FiltersInfo_Event, ExtraPanel::OnFiltersInfo )
00122 
00123     EVT_CHECKBOX( Filter0_Event, ExtraPanel::OnSelectFilter )
00124     EVT_CHECKBOX( Filter1_Event, ExtraPanel::OnSelectFilter )
00125     EVT_CHECKBOX( Filter2_Event, ExtraPanel::OnSelectFilter )
00126     EVT_CHECKBOX( Filter3_Event, ExtraPanel::OnSelectFilter )
00127     EVT_CHECKBOX( Filter4_Event, ExtraPanel::OnSelectFilter )
00128     EVT_CHECKBOX( Filter5_Event, ExtraPanel::OnSelectFilter )
00129     EVT_CHECKBOX( Filter6_Event, ExtraPanel::OnSelectFilter )
00130     EVT_CHECKBOX( Filter7_Event, ExtraPanel::OnSelectFilter )
00131     EVT_CHECKBOX( Filter8_Event, ExtraPanel::OnSelectFilter )
00132     EVT_CHECKBOX( Filter9_Event, ExtraPanel::OnSelectFilter )
00133 
00134     /* Audio */
00135     EVT_CHECKBOX( NormVol_Event, ExtraPanel::OnNormvol )
00136     EVT_CHECKBOX( HeadPhone_Event, ExtraPanel::OnHeadphone )
00137 
00138     EVT_COMMAND_SCROLL( NVSlider_Event, ExtraPanel::OnNormvolSlider )
00139 
00140 END_EVENT_TABLE()
00141 
00142 struct filter {
00143     char *psz_filter;
00144     char *psz_name;
00145     char *psz_help;
00146 };
00147 
00148 static const struct filter vfilters[] =
00149 {
00150     { "clone", N_("Image clone"), N_("Creates several clones of the image") },
00151     { "distort", N_("Distortion"), N_("Adds distorsion effects") },
00152     { "invert", N_("Image inversion") , N_("Inverts the image colors") },
00153     { "crop", N_("Image cropping"), N_("Crops the image") },
00154     { "motionblur", N_("Blurring"), N_("Creates a motion blurring on the image") },
00155     { "transform",  N_("Transformation"), N_("Rotates or flips the image") },
00156     { NULL, NULL, NULL } /* Do not remove this line */
00157 };
00158 
00159 /*****************************************************************************
00160  * Constructor.
00161  *****************************************************************************/
00162 ExtraPanel::ExtraPanel( intf_thread_t *_p_intf, wxWindow *_p_parent ):
00163         wxPanel( _p_parent , -1, wxDefaultPosition, wxDefaultSize )
00164 {
00165 
00166     p_intf = _p_intf;
00167     p_parent = _p_parent;
00168     SetAutoLayout( TRUE );
00169 
00170     wxBoxSizer *extra_sizer = new wxBoxSizer( wxHORIZONTAL );
00171 
00172     notebook = new wxNotebook( this, Notebook_Event );
00173 
00174 #if (!wxCHECK_VERSION(2,5,2))
00175     wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
00176 #endif
00177 
00178     notebook->AddPage( VideoPanel( notebook ), wxU(_("Video")) );
00179     notebook->AddPage( EqzPanel( notebook ), wxU(_("Equalizer")) );
00180     notebook->AddPage( AudioPanel( notebook ), wxU(_("Audio")) );
00181 
00182 #if (!wxCHECK_VERSION(2,5,2))
00183     extra_sizer->Add( notebook_sizer, 1, wxEXPAND, 0 );
00184 #else
00185     extra_sizer->Add( notebook, 1, wxEXPAND, 0 );
00186 #endif
00187 
00188     SetSizerAndFit( extra_sizer );
00189     extra_sizer->Layout();
00190 }
00191 
00192 ExtraPanel::~ExtraPanel()
00193 {
00194 }
00195 
00196 /* Video Panel constructor */
00197 wxPanel *ExtraPanel::VideoPanel( wxWindow *parent )
00198 {
00199     char *psz_filters;
00200 
00201     wxPanel *panel = new wxPanel( parent, -1 );
00202     wxBoxSizer *panel_sizer = new wxBoxSizer( wxHORIZONTAL );
00203 
00204     /* Create static box to surround the adjust controls */
00205     wxStaticBox *adjust_box =
00206            new wxStaticBox( panel, -1, wxU(_("Adjust Image")) );
00207     wxStaticBoxSizer *adjust_sizer =
00208         new wxStaticBoxSizer( adjust_box, wxVERTICAL );
00209     adjust_sizer->SetMinSize( -1, 50 );
00210 
00211     /* Create flex grid */
00212     wxFlexGridSizer *adjust_gridsizer =
00213         new wxFlexGridSizer( 6, 2, 0, 0);
00214     adjust_gridsizer->AddGrowableCol(1);
00215 
00216     /* Create the adjust button */
00217     wxCheckBox * adjust_check = new wxCheckBox( panel, Adjust_Event,
00218                                                  wxU(_("Enable")));
00219 
00220     /* Create the restore to defaults button */
00221     restoredefaults_button =
00222         new wxButton( panel, RestoreDefaults_Event,
00223         wxU(_("Restore Defaults")), wxDefaultPosition);
00224 
00225     wxStaticText *hue_text = new wxStaticText( panel, -1,
00226                                        wxU(_("Hue")) );
00227     hue_slider = new wxSlider ( panel, Hue_Event, 0, 0,
00228                                 360, wxDefaultPosition, wxDefaultSize );
00229 
00230     wxStaticText *contrast_text = new wxStaticText( panel, -1,
00231                                        wxU(_("Contrast")) );
00232     contrast_slider = new wxSlider ( panel, Contrast_Event, 0, 0,
00233                                 200, wxDefaultPosition, wxDefaultSize);
00234 
00235     wxStaticText *brightness_text = new wxStaticText( panel, -1,
00236                                        wxU(_("Brightness")) );
00237     brightness_slider = new wxSlider ( panel, Brightness_Event, 0, 0,
00238                            200, wxDefaultPosition, wxDefaultSize) ;
00239 
00240     wxStaticText *saturation_text = new wxStaticText( panel, -1,
00241                                           wxU(_("Saturation")) );
00242     saturation_slider = new wxSlider ( panel, Saturation_Event, 0, 0,
00243                            300, wxDefaultPosition, wxDefaultSize );
00244 
00245     wxStaticText *gamma_text = new wxStaticText( panel, -1,
00246                                           wxU(_("Gamma")) );
00247     gamma_slider = new wxSlider ( panel, Gamma_Event, 0, 0,
00248                            100, wxDefaultPosition, wxDefaultSize );
00249 
00250     adjust_gridsizer->Add( adjust_check, 1, wxEXPAND|wxALL, 2 );
00251     adjust_gridsizer->Add( restoredefaults_button, 1, wxEXPAND|wxALL, 2 );
00252     adjust_gridsizer->Add( hue_text, 1, wxEXPAND|wxALL, 2 );
00253     adjust_gridsizer->Add( hue_slider, 1, wxEXPAND|wxALL, 2 );
00254     adjust_gridsizer->Add( contrast_text, 1, wxEXPAND|wxALL, 2 );
00255     adjust_gridsizer->Add( contrast_slider, 1, wxEXPAND|wxALL, 2 );
00256     adjust_gridsizer->Add( brightness_text, 1, wxEXPAND|wxALL, 2 );
00257     adjust_gridsizer->Add( brightness_slider, 1, wxEXPAND|wxALL, 2 );
00258     adjust_gridsizer->Add( saturation_text, 1, wxEXPAND|wxALL, 2 );
00259     adjust_gridsizer->Add( saturation_slider, 1, wxEXPAND|wxALL, 2 );
00260     adjust_gridsizer->Add( gamma_text, 1, wxEXPAND|wxALL, 2 );
00261     adjust_gridsizer->Add( gamma_slider, 1, wxEXPAND|wxALL, 2 );
00262 
00263     adjust_sizer->Add( adjust_gridsizer, 1, wxEXPAND|wxALL, 2);
00264 
00265     panel_sizer->Add( adjust_sizer , 1, wxTOP, 2 );
00266 
00267 #if 0
00268     /* Create sizer to surround the other controls */
00269     wxBoxSizer *other_sizer = new wxBoxSizer( wxVERTICAL );
00270 
00271     wxStaticBox *video_box =
00272             new wxStaticBox( panel, -1, wxU(_("Video Options")) );
00273     /* Create the sizer for the frame */
00274     wxStaticBoxSizer *video_sizer =
00275        new wxStaticBoxSizer( video_box, wxVERTICAL );
00276     video_sizer->SetMinSize( -1, 50 );
00277 
00278     static const wxString ratio_array[] =
00279     {
00280         wxT("4:3"),
00281         wxT("16:9"),
00282     };
00283 
00284     wxBoxSizer *ratio_sizer = new wxBoxSizer( wxHORIZONTAL );
00285     wxStaticText *ratio_text = new wxStaticText( panel, -1,
00286                                           wxU(_("Aspect Ratio")) );
00287 
00288     ratio_combo = new wxComboBox( panel, Ratio_Event, wxT(""),
00289                                   wxDefaultPosition, wxSize( 80 , -1),
00290                                   WXSIZEOF(ratio_array), ratio_array,
00291                                   0 );
00292 
00293     ratio_sizer->Add( ratio_text, 0, wxALL, 2 );
00294     ratio_sizer->Add( ratio_combo, 0, wxALL, 2 );
00295     ratio_sizer->Layout();
00296 
00297     video_sizer->Add( ratio_sizer  , 0 , wxALL , 2 );
00298     video_sizer->Layout();
00299 #endif
00300 
00301     wxStaticBox *filter_box =
00302                   new wxStaticBox( panel, -1, wxU(_("Video filters")) );
00303     wxStaticBoxSizer *filter_sizer =
00304                    new wxStaticBoxSizer( filter_box, wxHORIZONTAL );
00305 
00306     wxBoxSizer *t_col_sizer = new wxBoxSizer( wxVERTICAL );
00307 
00308 
00309     for( int i = 0 ; vfilters[i].psz_filter != NULL ; i++ )
00310     {
00311         wxCheckBox *box = new wxCheckBox( panel, Filter0_Event + i,
00312                                           wxU( _( vfilters[i].psz_name ) ) );
00313         t_col_sizer->Add( box, 0, wxALL, 4 );
00314         box->SetToolTip( wxU( _( vfilters[i].psz_help ) ) );
00315     }
00316 
00317     filter_sizer->Add( t_col_sizer );
00318     filter_sizer->Add( new wxButton( panel, FiltersInfo_Event,
00319                             wxU(_("More info" ) ) ), 0, wxALL, 4 );
00320 #if 0
00321     other_sizer->Add( video_sizer, 0, wxALL | wxEXPAND , 0);
00322     other_sizer->Add( filter_sizer, 0, wxALL | wxEXPAND , 0);
00323     other_sizer->Layout();
00324     panel_sizer->Add(other_sizer , 1 );
00325 #endif
00326 
00327     panel_sizer->Add( filter_sizer, 1, wxTOP|wxLEFT, 2 );
00328 
00329     panel->SetSizerAndFit( panel_sizer );
00330 
00331     /* Layout the whole panel */
00332     panel_sizer->Layout();
00333 
00334     panel_sizer->SetSizeHints( panel );
00335 
00336     /* Write down initial values */
00337     psz_filters = config_GetPsz( p_intf, "vout-filter" );
00338     if( psz_filters && strstr( psz_filters, "adjust" ) )
00339     {
00340         adjust_check->SetValue( 1 );
00341         restoredefaults_button->Enable();
00342         saturation_slider->Enable();
00343         contrast_slider->Enable();
00344         brightness_slider->Enable();
00345         hue_slider->Enable();
00346         gamma_slider->Enable();
00347     }
00348     else
00349     {
00350         adjust_check->SetValue( 0 );
00351         restoredefaults_button->Disable();
00352         saturation_slider->Disable();
00353         contrast_slider->Disable();
00354         brightness_slider->Disable();
00355         hue_slider->Disable();
00356         gamma_slider->Disable();
00357     }
00358     if( psz_filters ) free( psz_filters );
00359 
00360     int i_value = config_GetInt( p_intf, "hue" );
00361     if( i_value > 0 && i_value < 360 )
00362         hue_slider->SetValue( i_value );
00363     float f_value;
00364     f_value = config_GetFloat( p_intf, "saturation" );
00365     if( f_value > 0 && f_value < 5 )
00366         saturation_slider->SetValue( (int)(100 * f_value) );
00367     f_value = config_GetFloat( p_intf, "contrast" );
00368     if( f_value > 0 && f_value < 4 )
00369         contrast_slider->SetValue( (int)(100 * f_value) );
00370     f_value = config_GetFloat( p_intf, "brightness" );
00371     if( f_value > 0 && f_value < 2 )
00372         brightness_slider->SetValue( (int)(100 * f_value) );
00373     f_value = config_GetFloat( p_intf, "gamma" );
00374     if( f_value > 0 && f_value < 10 )
00375         gamma_slider->SetValue( (int)(10 * f_value) );
00376 
00377     b_update = VLC_FALSE;
00378 
00379     return panel;
00380 }
00381 
00382 /* Audio panel constructor */
00383 wxPanel *ExtraPanel::AudioPanel( wxWindow *parent )
00384 {
00385     char *psz_filters;
00386 
00387     wxPanel *panel = new wxPanel( parent, -1 );
00388     wxBoxSizer *panel_sizer = new wxBoxSizer( wxHORIZONTAL );
00389 
00390     /* Create static box to surround the adjust controls */
00391     wxStaticBox *filter_box =
00392            new wxStaticBox( panel, -1, wxU(_("Audio filters")) );
00393     wxStaticBoxSizer *filter_sizer =
00394         new wxStaticBoxSizer( filter_box, wxVERTICAL );
00395     filter_sizer->SetMinSize( -1, 50 );
00396 
00397     wxCheckBox * headphone_check = new wxCheckBox( panel, HeadPhone_Event,
00398                                     wxU(_("Headphone virtualization")));
00399     headphone_check->SetToolTip( wxU(_("This filter gives the feeling of a "
00400              "5.1 speaker set when using a headphone." ) ) );
00401 
00402     wxCheckBox * normvol_check = new wxCheckBox( panel, NormVol_Event,
00403                                     wxU(_("Volume normalization")));
00404     normvol_check->SetToolTip( wxU(_("This filter prevents the audio output "
00405                          "power from going over a defined value." ) ) );
00406 
00407     wxStaticText *normvol_label = new wxStaticText( panel, -1,
00408                                    wxU( _("Maximum level") ) );
00409 
00410     wxSlider *normvol_slider = new wxSlider ( panel, NVSlider_Event, 20, 5,
00411                            100, wxDefaultPosition, wxSize( 100, -1 ) );
00412 
00413     filter_sizer->Add( headphone_check, 0, wxALL, 4 );
00414     filter_sizer->Add( normvol_check, 0, wxALL, 4 );
00415     filter_sizer->Add( normvol_label, 0, wxALL, 4 );
00416     filter_sizer->Add( normvol_slider, 0, wxALL, 4 );
00417 
00418     panel_sizer->Add( filter_sizer, 1, wxTOP, 2 );
00419     panel->SetSizerAndFit( panel_sizer );
00420     panel_sizer->Layout();
00421     panel_sizer->SetSizeHints( panel );
00422 
00423     /* Write down initial values */
00424     psz_filters = config_GetPsz( p_intf, "audio-filter" );
00425     if( psz_filters )
00426     {
00427         headphone_check->SetValue( strstr( psz_filters, "headphone" ) );
00428         normvol_check->SetValue( strstr( psz_filters, "normvol" ) );
00429         free( psz_filters );
00430     }
00431     else
00432     {
00433         headphone_check->SetValue( 0 );
00434         normvol_check->SetValue( 0 );
00435     }
00436 
00437     return panel;
00438 }
00439 
00440 
00441 static const wxString band_frequencies[] =
00442 {
00443     wxT(" 60 Hz"),
00444     wxT("170 Hz"),
00445     wxT("310 Hz"),
00446     wxT("600 Hz"),
00447     wxT(" 1 kHz"),
00448     wxT(" 3 kHz"),
00449     wxT(" 6 kHz"),
00450     wxT("12 kHz"),
00451     wxT("14 kHz"),
00452     wxT("16 kHz")
00453 };
00454 
00455 /* Equalizer Panel constructor */
00456 wxPanel *ExtraPanel::EqzPanel( wxWindow *parent )
00457 {
00458     wxPanel *panel = new wxPanel( parent, -1 );
00459     wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
00460 
00461     /* Create static box to surround the adjust controls */
00462     wxBoxSizer *top_sizer =
00463         new wxBoxSizer( wxHORIZONTAL );
00464 
00465     /* Create the enable button */
00466     eq_chkbox =  new wxCheckBox( panel, EqEnable_Event,
00467                             wxU(_("Enable") ) );
00468     eq_chkbox->SetToolTip( wxU(_("Enable the equalizer. You can either "
00469     "manually change the bands or use a preset (Audio Menu->Equalizer)." ) ) );
00470     top_sizer->Add( eq_chkbox, 0, wxALL, 2 );
00471 
00472     eq_2p_chkbox =  new wxCheckBox( panel, Eq2Pass_Event,
00473                             wxU(_("2 Pass") ) );
00474 
00475     eq_2p_chkbox->SetToolTip( wxU(_("If you enable this setting, the "
00476      "equalizer filter will be applied twice. The effect will be sharper.") ) );
00477 
00478     top_sizer->Add( eq_2p_chkbox, 0, wxALL, 2 );
00479 
00480     top_sizer->Add( 0, 0, 1, wxALL, 2 );
00481 
00482     eq_restoredefaults_button = new wxButton( panel, EqRestore_Event,
00483                                   wxU( _("Restore Defaults") ) );
00484     top_sizer->Add( eq_restoredefaults_button, 0, wxALL, 2 );
00485     top_sizer->Add( 0, 0, 1, wxALL, 2 );
00486 
00487     smooth_text = new wxStaticText( panel, -1, wxU( "Smooth :" ));
00488     smooth_text->SetToolTip( wxU( SMOOTH_TIP ) );
00489     top_sizer->Add( smooth_text, 0, wxALL, 2 );
00490 
00491     smooth_slider =new wxSlider( panel, Smooth_Event, 0, 0, 10 ,
00492                     wxDefaultPosition, wxSize( 100, -1 ) );
00493     smooth_slider->SetToolTip( wxU( SMOOTH_TIP ) );
00494     top_sizer->Add( smooth_slider, 0, wxALL, 2 );
00495     i_smooth = 0;
00496 
00497     /* Create flex grid */
00498     wxFlexGridSizer *eq_gridsizer =
00499         new wxFlexGridSizer( 2, 12, 0, 0);
00500     eq_gridsizer->AddGrowableRow( 0 );
00501     eq_gridsizer->AddGrowableCol( 1 );
00502 
00503     preamp_slider = new wxSlider( panel, Preamp_Event, 80, 0, 400,
00504                     wxDefaultPosition, wxSize( -1 , 90 ) , wxSL_VERTICAL );
00505     eq_gridsizer->Add( preamp_slider, 1, wxEXPAND|wxALL, 2 );
00506 
00507     eq_gridsizer->Add( 0, 0, 1, wxALL, 2 );
00508 
00509     for( int i = 0 ; i < 10 ; i++ )
00510     {
00511         band_sliders[i] = new wxSlider( panel, Band0_Event + i, 200, 0, 400,
00512                     wxDefaultPosition, wxSize( -1 , 90 ) , wxSL_VERTICAL );
00513 
00514         i_values[i] = 200;
00515         eq_gridsizer->Add( band_sliders[i], 1, wxEXPAND|wxALL, 2 );
00516     }
00517 
00518     preamp_text = new wxStaticText( panel, -1, wxT( "Preamp\n12.0dB" ) );
00519     wxFont font= preamp_text->GetFont();
00520     font.SetPointSize(7);
00521     preamp_text->SetFont( font );
00522     eq_gridsizer->Add( preamp_text, wxALL, 2 );
00523 
00524     eq_gridsizer->Add( 0, 0, 1 );
00525 
00526     for( int i = 0 ; i < 10 ; i++ )
00527     {
00528         band_texts[i] = new wxStaticText( panel, -1,
00529                                 band_frequencies[i] + wxU("\n0.0dB" ) ) ;
00530         eq_gridsizer->Add( band_texts[i], 1, wxEXPAND|wxALL, 2 );
00531         wxFont font= band_texts[i]->GetFont();
00532         font.SetPointSize(7);
00533         band_texts[i]->SetFont( font );
00534     }
00535 
00536     panel_sizer->Add( top_sizer , 0 , wxTOP | wxEXPAND, 5 );
00537     panel_sizer->Add( eq_gridsizer , 0 , wxEXPAND, 0 );
00538 
00539     panel->SetSizer( panel_sizer );
00540 
00541     panel_sizer->Layout();
00542 
00543     panel_sizer->SetSizeHints( panel );
00544 
00545     CheckAout();
00546 
00547     aout_instance_t *p_aout = (aout_instance_t *)vlc_object_find(p_intf,
00548                                  VLC_OBJECT_AOUT, FIND_ANYWHERE);
00549     char *psz_af = NULL;
00550     if( p_aout )
00551     {
00552         psz_af = var_GetString( p_aout, "audio-filter" );
00553         if( var_GetBool( p_aout, "equalizer-2pass" ) )
00554             eq_2p_chkbox->SetValue( true );
00555         vlc_object_release( p_aout );
00556     }
00557     else
00558     {
00559         psz_af = config_GetPsz( p_intf, "audio-filter" );
00560         if( config_GetInt( p_intf, "equalizer-2pass" ) )
00561             eq_2p_chkbox->SetValue( true );
00562     }
00563     if( psz_af != NULL ? strstr( psz_af, "equalizer" ) != NULL : VLC_FALSE )
00564     {
00565         eq_chkbox->SetValue( true );
00566     } else {
00567         eq_2p_chkbox->Disable();
00568         eq_restoredefaults_button->Disable();
00569         smooth_slider->Disable();
00570         smooth_text->Disable();
00571         preamp_slider->Disable();
00572         preamp_text->Disable();
00573         for( int i_index=0; i_index < 10; i_index++ )
00574         {
00575             band_sliders[i_index]->Disable();
00576             band_texts[i_index]->Disable();
00577         }
00578     }
00579     free( psz_af );
00580 
00581     return panel;
00582 }
00583 
00584 /*******************************************************
00585  * Event handlers
00586  *******************************************************/
00587 
00588 /* Keep aout up to date and update the bands if needed */
00589 void ExtraPanel::OnIdle( wxIdleEvent &event )
00590 {
00591     CheckAout();
00592     if( b_update == VLC_TRUE )
00593     {
00594         if( b_my_update == VLC_TRUE )
00595         {
00596             b_update = b_my_update = VLC_FALSE;
00597             return;
00598         }
00599         char *p = psz_bands;
00600         for( int i = 0; i < 10; i++ )
00601         {
00602                 float f;
00603                 char psz_val[5];
00604                 int i_val;
00605                 /* Read dB -20/20*/
00606                 f = strtof( p, &p );
00607                 i_val= (int)( ( f + 20 ) * 10 );
00608                 band_sliders[i]->SetValue( 400 - i_val );
00609                 i_values[i] = 400 - i_val;
00610                 sprintf( psz_val, "%.1f", f );
00611                 band_texts[i]->SetLabel( band_frequencies[i] + wxT("\n") +
00612                                                 wxU( psz_val ) + wxT("dB") );
00613                 if( p == NULL )
00614                 {
00615                     break;
00616                 }
00617                 p++;
00618                 if( *p == 0 )
00619                     break;
00620         }
00621         char psz_val[5];
00622         int i_val = (int)( ( f_preamp + 20 ) * 10 );
00623         sprintf( psz_val, "%.1f", f_preamp );
00624         preamp_slider->SetValue( 400 - i_val );
00625         const wxString preamp = wxT("Preamp\n");
00626         preamp_text->SetLabel( preamp + wxU( psz_val ) + wxT( "dB" ) );
00627         eq_chkbox->SetValue( TRUE );
00628         b_update = VLC_FALSE;
00629     }
00630 }
00631 
00632 /*************************
00633  *  Equalizer Panel events
00634  *************************/
00635 void ExtraPanel::OnEnableEqualizer( wxCommandEvent &event )
00636 {
00637     int i_index;
00638     aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
00639                                  VLC_OBJECT_AOUT, FIND_ANYWHERE);
00640     ChangeFiltersString( p_intf,p_aout, "equalizer",
00641                          event.IsChecked() ? VLC_TRUE : VLC_FALSE );
00642 
00643     if( event.IsChecked() )
00644     {
00645         eq_2p_chkbox->Enable();
00646         eq_restoredefaults_button->Enable();
00647         smooth_slider->Enable();
00648         smooth_text->Enable();
00649         preamp_slider->Enable();
00650         preamp_text->Enable();
00651         for( i_index=0; i_index < 10; i_index++ )
00652         {
00653             band_sliders[i_index]->Enable();
00654             band_texts[i_index]->Enable();
00655         }
00656     } else {
00657         eq_2p_chkbox->Disable();
00658         eq_restoredefaults_button->Disable();
00659         smooth_slider->Disable();
00660         smooth_text->Disable();
00661         preamp_slider->Disable();
00662         preamp_text->Disable();
00663         for( i_index=0; i_index < 10; i_index++ )
00664         {
00665             band_sliders[i_index]->Disable();
00666             band_texts[i_index]->Disable();
00667         }
00668     }
00669 
00670     if( p_aout != NULL )
00671         vlc_object_release( p_aout );
00672 }
00673 
00674 void ExtraPanel::OnEqRestore( wxCommandEvent &event )
00675 {
00676     aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
00677                                  VLC_OBJECT_AOUT, FIND_ANYWHERE);
00678     if( p_aout == NULL )
00679     {
00680         vlc_value_t val;
00681         vlc_bool_t b_previous = eq_chkbox->IsChecked();
00682         val.f_float = 12.0;
00683         IntfPreampCallback( NULL, NULL, val,val, this );
00684         config_PutFloat( p_intf, "equalizer-preamp", 12.0 );
00685         val.psz_string = strdup( "0 0 0 0 0 0 0 0 0 0" );
00686         IntfBandsCallback( NULL, NULL, val,val, this );
00687         config_PutPsz( p_intf, "equalizer-bands",
00688                                 "0 0 0 0 0 0 0 0 0 0");
00689         config_PutPsz( p_intf, "equalizer-preset","flat" );
00690         eq_chkbox->SetValue( b_previous );
00691     }
00692     else
00693     {
00694         var_SetFloat( p_aout, "equalizer-preamp", 12.0 );
00695         config_PutFloat( p_intf, "equalizer-preamp", 12.0 );
00696         var_SetString( p_aout, "equalizer-bands",
00697                                 "0 0 0 0 0 0 0 0 0 0");
00698         config_PutPsz( p_intf, "equalizer-bands",
00699                                 "0 0 0 0 0 0 0 0 0 0");
00700         var_SetString( p_aout , "equalizer-preset" , "flat" );
00701         config_PutPsz( p_intf, "equalizer-preset","flat" );
00702         vlc_object_release( p_aout );
00703     }
00704 }
00705 
00706 void ExtraPanel::OnEq2Pass( wxCommandEvent &event )
00707 {
00708     aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
00709                                  VLC_OBJECT_AOUT, FIND_ANYWHERE);
00710 
00711     vlc_bool_t b_2p = event.IsChecked() ? VLC_TRUE : VLC_FALSE;
00712 
00713     if( p_aout == NULL )
00714     {
00715         config_PutInt( p_intf, "equalizer-2pass", b_2p );
00716     }
00717     else
00718     {
00719         var_SetBool( p_aout, "equalizer-2pass", b_2p );
00720         config_PutInt( p_intf, "equalizer-2pass", b_2p );
00721         if( eq_chkbox->IsChecked() )
00722         {
00723             for( int i = 0; i < p_aout->i_nb_inputs; i++ )
00724             {
00725                 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
00726             }
00727         }
00728         vlc_object_release( p_aout );
00729     }
00730 }
00731 
00732 void ExtraPanel::OnEqSmooth( wxScrollEvent &event )
00733 {
00734     /* Max smoothing : 70% */
00735     i_smooth = event.GetPosition() * 7;
00736 }
00737 
00738 void ExtraPanel::OnPreamp( wxScrollEvent &event )
00739 {
00740     float f= (float)( 400 - event.GetPosition() ) / 10 - 20 ;
00741     char psz_val[5];
00742 
00743     aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
00744                                  VLC_OBJECT_AOUT, FIND_ANYWHERE);
00745 
00746     sprintf( psz_val, "%.1f", f );
00747     const wxString preamp = wxT("Preamp\n");
00748     preamp_text->SetLabel( preamp + wxU( psz_val ) + wxT( "dB" ) );
00749 
00750     if( p_aout == NULL )
00751     {
00752         config_PutFloat( p_intf, "equalizer-preamp", f );
00753     }
00754     else
00755     {
00756         var_SetFloat( p_aout, "equalizer-preamp", f );
00757         config_PutFloat( p_intf, "equalizer-preamp", f );
00758         b_my_update = VLC_TRUE;
00759         vlc_object_release( p_aout );
00760     }
00761 }
00762 
00763 void ExtraPanel::OnChangeEqualizer( wxScrollEvent &event )
00764 {
00765     aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
00766                                  VLC_OBJECT_AOUT, FIND_ANYWHERE);
00767     char psz_values[102];
00768     memset( psz_values, 0, 102 );
00769 
00770 
00771     /* Smoothing */
00772     int i_diff = event.GetPosition() - i_values[  event.GetId() - Band0_Event ];
00773     i_values[ event.GetId() - Band0_Event] = event.GetPosition();
00774 
00775     for( int i = event.GetId() + 1 ; i <= Band9_Event ; i++ )
00776     {
00777         int i_new = band_sliders[ i-Band0_Event ]->GetValue() +
00778            (int)( i_diff * pow( (float)i_smooth / 100 , i- event.GetId() ) ) ;
00779         if( i_new < 0 ) i_new = 0;
00780         if( i_new > 400 ) i_new = 400;
00781         band_sliders[ i-Band0_Event ]->SetValue( i_new );
00782     }
00783     for( int i = Band0_Event ; i < event.GetId() ; i++ )
00784     {
00785         int i_new =   band_sliders[ i-Band0_Event ]->GetValue() +
00786            (int)( i_diff * pow( (float)i_smooth / 100 , event.GetId() - i  ) );
00787         if( i_new < 0 ) i_new = 0;
00788         if( i_new > 400 ) i_new = 400;
00789         band_sliders[ i-Band0_Event ]->SetValue( i_new );
00790     }
00791 
00792     /* Write the new bands values */
00793     for( int i = 0 ; i < 10 ; i++ )
00794     {
00795         char psz_val[5];
00796         float f_val = (float)( 400 - band_sliders[i]->GetValue() ) / 10- 20 ;
00797         sprintf( psz_values, "%s %f", psz_values, f_val );
00798         sprintf( psz_val, "%.1f", f_val );
00799         band_texts[i]->SetLabel( band_frequencies[i] + wxT("\n") +
00800                         wxU( psz_val ) + wxT("dB" ) );
00801     }
00802     if( p_aout == NULL )
00803     {
00804         config_PutPsz( p_intf, "equalizer-bands", psz_values );
00805     }
00806     else
00807     {
00808         var_SetString( p_aout, "equalizer-bands", psz_values );
00809         config_PutPsz( p_intf, "equalizer-bands", psz_values );
00810         b_my_update = VLC_TRUE;
00811         vlc_object_release( p_aout );
00812     }
00813 }
00814 
00815 /***********************
00816  * Audio Panel events
00817  ***********************/
00818 void ExtraPanel::OnHeadphone( wxCommandEvent &event )
00819 {
00820     aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
00821                                  VLC_OBJECT_AOUT, FIND_ANYWHERE);
00822     ChangeFiltersString( p_intf , p_aout, "headphone_channel_mixer",
00823                          event.IsChecked() ? VLC_TRUE : VLC_FALSE );
00824     if( p_aout != NULL )
00825         vlc_object_release( p_aout );
00826 }
00827 
00828 void ExtraPanel::OnNormvol( wxCommandEvent &event )
00829 {
00830     aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
00831                                  VLC_OBJECT_AOUT, FIND_ANYWHERE);
00832     ChangeFiltersString( p_intf , p_aout, "normvol",
00833                          event.IsChecked() ? VLC_TRUE : VLC_FALSE );
00834     if( p_aout != NULL )
00835         vlc_object_release( p_aout );
00836 }
00837 
00838 void ExtraPanel::OnNormvolSlider( wxScrollEvent &event )
00839 {
00840     aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
00841                                  VLC_OBJECT_AOUT, FIND_ANYWHERE);
00842     if( p_aout != NULL )
00843     {
00844         var_SetFloat( p_aout, "norm-max-level", (float)event.GetPosition()/10 );
00845         vlc_object_release( p_aout );
00846     }
00847     else
00848     {
00849         config_PutFloat( p_intf, "norm-max-level",
00850                         (float)event.GetPosition()/10 );
00851     }
00852 }
00853 /***********************
00854  *  Video Panel events
00855  ***********************/
00856 void ExtraPanel::OnEnableAdjust(wxCommandEvent& event)
00857 {
00858     ChangeVFiltersString( p_intf,  "adjust",
00859                           event.IsChecked() ? VLC_TRUE : VLC_FALSE );
00860 
00861     if( event.IsChecked() )
00862     {
00863         restoredefaults_button->Enable();
00864         brightness_slider->Enable();
00865         saturation_slider->Enable();
00866         contrast_slider->Enable();
00867         hue_slider->Enable();
00868         gamma_slider->Enable();
00869     }
00870     else
00871     {
00872         restoredefaults_button->Disable();
00873         brightness_slider->Disable();
00874         saturation_slider->Disable();
00875         contrast_slider->Disable();
00876         hue_slider->Disable();
00877         gamma_slider->Disable();
00878     }
00879 }
00880 
00881 void ExtraPanel::OnRestoreDefaults( wxCommandEvent &event)
00882 {
00883     hue_slider->SetValue(0);
00884     saturation_slider->SetValue(100);
00885     brightness_slider->SetValue(100);
00886     contrast_slider->SetValue(100),
00887     gamma_slider->SetValue(10);
00888 
00889     wxScrollEvent *hscroll_event = new wxScrollEvent(0, Hue_Event, 0);
00890     OnAdjustUpdate(*hscroll_event);
00891 
00892     wxScrollEvent *sscroll_event = new wxScrollEvent(0, Saturation_Event, 100);
00893     OnAdjustUpdate(*sscroll_event);
00894 
00895     wxScrollEvent *bscroll_event = new wxScrollEvent(0, Brightness_Event, 100);
00896     OnAdjustUpdate(*bscroll_event);
00897 
00898     wxScrollEvent *cscroll_event = new wxScrollEvent(0, Contrast_Event, 100);
00899     OnAdjustUpdate(*cscroll_event);
00900 
00901     wxScrollEvent *gscroll_event = new wxScrollEvent(0, Gamma_Event, 10);
00902     OnAdjustUpdate(*gscroll_event);
00903 
00904 }
00905 
00906 void ExtraPanel::OnAdjustUpdate( wxScrollEvent &event)
00907 {
00908     vout_thread_t *p_vout = (vout_thread_t *)vlc_object_find(p_intf,
00909                                  VLC_OBJECT_VOUT, FIND_ANYWHERE);
00910     if( p_vout == NULL )
00911     {
00912         switch( event.GetId() )
00913         {
00914             case Hue_Event:
00915                 config_PutInt( p_intf , "hue" , event.GetPosition() );
00916                 break;
00917 
00918             case Saturation_Event:
00919                 config_PutFloat( p_intf , "saturation" ,
00920                                 (float)event.GetPosition()/100 );
00921                 break;
00922 
00923             case Brightness_Event:
00924                 config_PutFloat( p_intf , "brightness" ,
00925                                 (float)event.GetPosition()/100 );
00926                 break;
00927 
00928             case Contrast_Event:
00929                 config_PutFloat( p_intf , "contrast" ,
00930                                 (float)event.GetPosition()/100 );
00931                 break;
00932 
00933             case Gamma_Event:
00934                 config_PutFloat( p_intf , "gamma" ,
00935                                 (float)event.GetPosition()/10 );
00936                 break;
00937         }
00938     }
00939     else
00940     {
00941         vlc_value_t val;
00942         switch( event.GetId() )
00943         {
00944             case Hue_Event:
00945                 val.i_int = event.GetPosition();
00946                 var_Set( p_vout, "hue", val );
00947                 config_PutInt( p_intf , "hue" , event.GetPosition() );
00948                 break;
00949 
00950             case Saturation_Event:
00951                 val.f_float = (float)event.GetPosition() / 100;
00952                 var_Set( p_vout, "saturation", val );
00953                 config_PutFloat( p_intf , "saturation" ,
00954                                 (float)event.GetPosition()/100 );
00955                 break;
00956 
00957             case Brightness_Event:
00958                 val.f_float = (float)event.GetPosition() / 100;
00959                 var_Set( p_vout, "brightness", val );
00960                 config_PutFloat( p_intf , "brightness" ,
00961                                 (float)event.GetPosition()/100 );
00962                 break;
00963 
00964             case Contrast_Event:
00965                 val.f_float = (float)event.GetPosition() / 100;
00966                 var_Set( p_vout, "contrast", val );
00967                 config_PutFloat( p_intf , "contrast" ,
00968                                 (float)event.GetPosition()/100 );
00969                 break;
00970 
00971             case Gamma_Event:
00972                 val.f_float = (float)event.GetPosition() / 10;
00973                 var_Set( p_vout, "gamma", val );
00974                 config_PutFloat( p_intf , "gamma" ,
00975                                 (float)event.GetPosition()/10 );
00976                 break;
00977         }
00978         vlc_object_release(p_vout);
00979     }
00980 }
00981 
00982 /* FIXME */
00983 void ExtraPanel::OnRatio( wxCommandEvent& event )
00984 {
00985    config_PutPsz( p_intf, "aspect-ratio", ratio_combo->GetValue().mb_str() );
00986 }
00987 
00988 
00989 void ExtraPanel::OnSelectFilter(wxCommandEvent& event)
00990 {
00991     int i_filter = event.GetId() - Filter0_Event ;
00992     if( vfilters[i_filter].psz_filter  )
00993     {
00994         ChangeVFiltersString( p_intf, vfilters[i_filter].psz_filter ,
00995                               event.IsChecked() ? VLC_TRUE : VLC_FALSE );
00996     }
00997 }
00998 
00999 void ExtraPanel::OnFiltersInfo(wxCommandEvent& event)
01000 {
01001     wxMessageBox( wxU( _("Select the video effects filters to apply. "
01002                   "You must restart the stream for these settings to "
01003                   "take effect.\n"
01004                   "To configure the filters, go to the Preferences, "
01005                   "and go to Modules/Video Filters. "
01006                   "You can then configure each filter.\n"
01007                   "If you want fine control over the filters ( to choose "
01008                   "the order in which they are applied ), you need to enter "
01009                   "manually a filters string (Preferences / Video / Filters)."
01010                   ) ),
01011                     wxU( _("More information" ) ), wxOK | wxICON_INFORMATION,
01012                     this->p_parent );
01013 }
01014 /**********************************
01015  * Other functions
01016  **********************************/
01017 void ExtraPanel::CheckAout()
01018 {
01019     aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
01020                                  VLC_OBJECT_AOUT, FIND_ANYWHERE);
01021     if( p_aout != NULL )
01022     {
01023         if( p_aout != p_intf->p_sys->p_aout )
01024         {
01025             /* We want to know if someone changes the bands */
01026             if( var_AddCallback( p_aout, "equalizer-bands",
01027                                     IntfBandsCallback, this ) )
01028             {
01029                 /* The variable does not exist yet, wait */
01030                 vlc_object_release( p_aout );
01031                 return;
01032             }
01033             if( var_AddCallback( p_aout, "equalizer-preamp",
01034                                     IntfPreampCallback, this )  )
01035             {
01036                 vlc_object_release( p_aout );
01037                 return;
01038             }
01039             /* Ok, we have our variables, make a first update round */
01040             p_intf->p_sys->p_aout = p_aout;
01041 
01042             f_preamp = var_GetFloat( p_aout, "equalizer-preamp" );
01043             psz_bands = var_GetString( p_aout, "equalizer-bands" );
01044             b_update = VLC_TRUE;
01045         }
01046         vlc_object_release( p_aout );
01047     }
01048 }
01049 
01050 
01051 static void ChangeVFiltersString( intf_thread_t *p_intf,
01052                                  char *psz_name, vlc_bool_t b_add )
01053 {
01054     vout_thread_t *p_vout;
01055     char *psz_parser, *psz_string;
01056 
01057     psz_string = config_GetPsz( p_intf, "vout-filter" );
01058 
01059     if( !psz_string ) psz_string = strdup("");
01060 
01061     psz_parser = strstr( psz_string, psz_name );
01062 
01063     if( b_add )
01064     {
01065         if( !psz_parser )
01066         {
01067             psz_parser = psz_string;
01068             asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
01069                             psz_string, psz_name );
01070             free( psz_parser );
01071         }
01072         else
01073         {
01074             return;
01075         }
01076     }
01077     else
01078     {
01079         if( psz_parser )
01080         {
01081             memmove( psz_parser, psz_parser + strlen(psz_name) +
01082                             (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
01083                             strlen(psz_parser + strlen(psz_name)) + 1 );
01084 
01085             /* Remove trailing : : */
01086             if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
01087             {
01088                 *(psz_string+strlen(psz_string ) -1 ) = '\0';
01089             }
01090          }
01091          else
01092          {
01093              free( psz_string );
01094              return;
01095          }
01096     }
01097     /* Vout is not kept, so put that in the config */
01098     config_PutPsz( p_intf, "vout-filter", psz_string );
01099 
01100     /* Try to set on the fly */
01101     p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
01102                                               FIND_ANYWHERE );
01103     if( p_vout )
01104     {
01105         var_SetString( p_vout, "vout-filter", psz_string );
01106         vlc_object_release( p_vout );
01107     }
01108 
01109     free( psz_string );
01110 }
01111 
01112 
01113 static void ChangeFiltersString( intf_thread_t *p_intf,
01114                                  aout_instance_t * p_aout,
01115                                  char *psz_name, vlc_bool_t b_add )
01116 {
01117     char *psz_parser, *psz_string;
01118 
01119     if( p_aout )
01120     {
01121         psz_string = var_GetString( p_aout, "audio-filter" );
01122     }
01123     else
01124     {
01125         psz_string = config_GetPsz( p_intf, "audio-filter" );
01126     }
01127 
01128     if( !psz_string ) psz_string = strdup("");
01129 
01130     psz_parser = strstr( psz_string, psz_name );
01131 
01132     if( b_add )
01133     {
01134         if( !psz_parser )
01135         {
01136             psz_parser = psz_string;
01137             asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
01138                             psz_string, psz_name );
01139             free( psz_parser );
01140         }
01141         else
01142         {
01143             return;
01144         }
01145     }
01146     else
01147     {
01148         if( psz_parser )
01149         {
01150             memmove( psz_parser, psz_parser + strlen(psz_name) +
01151                             (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
01152                             strlen(psz_parser + strlen(psz_name)) + 1 );
01153 
01154             if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
01155             {
01156                 *(psz_string+strlen(psz_string ) -1 ) = '\0';
01157             }
01158          }
01159          else
01160          {
01161              free( psz_string );
01162              return;
01163          }
01164     }
01165 
01166     if( p_aout == NULL )
01167     {
01168         config_PutPsz( p_intf, "audio-filter", psz_string );
01169     }
01170     else
01171     {
01172         var_SetString( p_aout, "audio-filter", psz_string );
01173         for( int i = 0; i < p_aout->i_nb_inputs; i++ )
01174         {
01175             p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
01176         }
01177     }
01178     free( psz_string );
01179 }
01180 
01181 
01182 static int IntfBandsCallback( vlc_object_t *p_this, char const *psz_cmd,
01183                           vlc_value_t oldval, vlc_value_t newval, void *param )
01184 {
01185     ExtraPanel *p_panel = (ExtraPanel *)param;
01186 
01187     p_panel->psz_bands = strdup( newval.psz_string );
01188     p_panel->b_update = VLC_TRUE;
01189 
01190     return VLC_SUCCESS;
01191 }
01192 
01193 static int IntfPreampCallback( vlc_object_t *p_this, char const *psz_cmd,
01194                           vlc_value_t oldval, vlc_value_t newval, void *param )
01195 {
01196     ExtraPanel *p_panel = (ExtraPanel *)param;
01197 
01198     p_panel->f_preamp = newval.f_float;
01199     p_panel->b_update = VLC_TRUE;
01200 
01201     return VLC_SUCCESS;
01202 }
01203 
01204 #if 0
01205 /**********************************************************************
01206  * A small window to contain the extrapanel in its undocked state
01207  **********************************************************************/
01208 BEGIN_EVENT_TABLE(ExtraWindow, wxFrame)
01209 END_EVENT_TABLE()
01210 
01211 
01212 ExtraWindow::ExtraWindow( intf_thread_t *_p_intf, wxWindow *p_parent,
01213                           wxPanel *_extra_panel ):
01214        wxFrame( p_parent, -1, wxU(_("Extended controls")), wxDefaultPosition,
01215                  wxDefaultSize, wxDEFAULT_FRAME_STYLE )
01216 {
01217         fprintf(stderr,"Creating extrawindow\n");
01218     p_intf = _p_intf;
01219     SetIcon( *p_intf->p_sys->p_icon );
01220 
01221     wxBoxSizer *window_sizer = new wxBoxSizer( wxVERTICAL );
01222     SetSizer( window_sizer );
01223 //    panel = new ExtraPanel(  p_intf, this );//_extra_panel;
01224 
01225     panel = _extra_panel;
01226     window_sizer->Add( panel );
01227 
01228     window_sizer->Layout();
01229     window_sizer->Fit( this );
01230 
01231     Show();
01232 }
01233 
01234 ExtraWindow::~ExtraWindow()
01235 {
01236     delete panel;
01237 }
01238 #endif

Generated on Tue Dec 20 10:14:47 2005 for vlc-0.8.4a by  doxygen 1.4.2