~ubuntu-branches/ubuntu/natty/vlc/natty

« back to all changes in this revision

Viewing changes to modules/gui/macosx/equalizer.m

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2010-06-25 01:09:16 UTC
  • mfrom: (1.1.30 upstream)
  • Revision ID: james.westby@ubuntu.com-20100625010916-asxhep2mutg6g6pd
Tags: 1.1.0-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - build and install the libx264 plugin
  - add Xb-Npp header to vlc package
  - Add apport hook to include more vlc dependencies in bug reports
* Drop xulrunner patches.
* Drop 502_xulrunner_191.diff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * equalizer.m: MacOS X interface module
3
3
 *****************************************************************************
4
4
 * Copyright (C) 2004-2008 the VideoLAN team
5
 
 * $Id: 0c726b1a868e54b94edc6ca7a5768227a2e62ba9 $
 
5
 * $Id: 7d16a50d818d057f29ce9562927f9620c5eb1eca $
6
6
 *
7
7
 * Authors: Jérôme Decoodt <djc@videolan.org>
8
8
 *          Felix Paul Kühne <fkuehne -at- videolan -dot- org>
49
49
{
50
50
    char *psz_parser, *psz_string;
51
51
    int i;
52
 
    vlc_object_t *p_object = vlc_object_find( p_intf,
53
 
                                VLC_OBJECT_AOUT, FIND_ANYWHERE );
54
 
    aout_instance_t *p_aout = (aout_instance_t *)p_object;
 
52
    aout_instance_t *p_aout = getAout();
 
53
    vlc_object_t *p_object = VLC_OBJECT(p_aout);
55
54
    if( !p_object )
56
55
    {
57
 
        p_object = (vlc_object_t *)pl_Hold( p_intf );
 
56
        p_object = vlc_object_hold(pl_Get( p_intf ));
58
57
    }
59
58
 
60
59
    psz_string = var_GetNonEmptyString( p_object, "audio-filter" );
99
98
         }
100
99
    }
101
100
 
102
 
    var_SetString( p_object, "audio-filter", psz_string );
103
 
    if( p_aout )
104
 
    {
105
 
        for( i = 0; i < p_aout->i_nb_inputs; i++ )
106
 
        {
107
 
            p_aout->pp_inputs[i]->b_restart = true;
108
 
        }
109
 
    }
110
 
    
 
101
    aout_EnableFilter( pl_Get( p_intf ), psz_string, b_add);
 
102
 
111
103
    if( (BOOL)config_GetInt( p_object, "macosx-eq-keep" ) == YES )
112
104
    {
113
105
        /* save changed to config */
114
106
        config_PutPsz( p_object, "audio-filter", psz_string );
115
107
    }
116
 
    
 
108
 
117
109
    free( psz_string );
118
110
    vlc_object_release( p_object );
119
111
}
122
114
                                 char *psz_name )
123
115
{
124
116
    char *psz_parser, *psz_string;
125
 
    vlc_object_t *p_object = vlc_object_find( p_intf,
126
 
                                VLC_OBJECT_AOUT, FIND_ANYWHERE );
 
117
    vlc_object_t *p_object = VLC_OBJECT(getAout());
127
118
    if( p_object == NULL )
128
 
        p_object = (vlc_object_t *)pl_Hold( p_intf );
 
119
        p_object = vlc_object_hold(pl_Get( p_intf ));
129
120
 
130
121
    if( (BOOL)config_GetInt( p_intf, "macosx-eq-keep" ) == YES )
131
122
        psz_string = config_GetPsz( p_intf, "audio-filter" );
151
142
{
152
143
    int i;
153
144
    [o_btn_equalizer setToolTip: _NS("Equalizer")];
 
145
    [o_btn_equalizer_embedded setToolTip: _NS("Equalizer")];
154
146
    [o_ckb_2pass setTitle: _NS("2 Pass")];
155
147
    [o_ckb_2pass setToolTip: _NS("Apply the "
156
148
        "equalizer filter twice. The effect will be sharper.")];
177
169
    bool b_2p;
178
170
    int i;
179
171
    bool b_enabled = GetFiltersStatus( p_intf, (char *)"equalizer" );
180
 
    vlc_object_t *p_object = vlc_object_find( p_intf,
181
 
                                              VLC_OBJECT_AOUT, FIND_ANYWHERE );
 
172
    vlc_object_t *p_object = VLC_OBJECT(getAout());
182
173
 
183
174
    if( p_object == NULL )
184
 
        p_object = (vlc_object_t *)pl_Hold( p_intf );
 
175
        p_object = vlc_object_hold(pl_Get( p_intf ));
185
176
 
186
177
    var_Create( p_object, "equalizer-preamp", VLC_VAR_FLOAT |
187
178
                VLC_VAR_DOINHERIT );
205
196
    }
206
197
 
207
198
    vlc_object_release( p_object );
208
 
    
 
199
 
209
200
    /* Set the preamp slider */
210
201
    [o_slider_preamp setFloatValue: f_preamp];
211
202
 
217
208
        /* Read dB -20/20 */
218
209
        f_band[i] = strtof( psz_bands, &p_next );
219
210
        if( !p_next || p_next == psz_bands ) break; /* strtof() failed */
220
 
    
 
211
 
221
212
        if( !*psz_bands ) break; /* end of line */
222
213
        psz_bands = p_next+1;
223
214
    }
227
218
    /* Set the the checkboxes */
228
219
    [o_ckb_enable setState: b_enabled];
229
220
 
230
 
    [o_ckb_2pass setState: b_2p];        
 
221
    [o_ckb_2pass setState: b_2p];
231
222
}
232
223
 
233
224
- (IBAction)bandSliderUpdated:(id)sender
234
225
{
235
226
    intf_thread_t *p_intf = VLCIntf;
236
 
    vlc_object_t *p_object = vlc_object_find( p_intf,
237
 
                                              VLC_OBJECT_AOUT, FIND_ANYWHERE );
 
227
    vlc_object_t *p_object = VLC_OBJECT(getAout());
238
228
 
239
229
    if( p_object == NULL )
240
 
        p_object = (vlc_object_t *)pl_Hold( p_intf );
 
230
        p_object = vlc_object_hold(pl_Get( p_intf ));
241
231
 
242
232
    const char *psz_values;
243
233
    NSString *preset = [NSString stringWithFormat:@"%.1f", [o_slider_band1 floatValue] ];
270
260
{
271
261
    intf_thread_t *p_intf = VLCIntf;
272
262
    int i;
273
 
    vlc_object_t *p_object= vlc_object_find( p_intf,
274
 
                                             VLC_OBJECT_AOUT, FIND_ANYWHERE );
 
263
    vlc_object_t *p_object= VLC_OBJECT(getAout());
275
264
    if( p_object == NULL )
276
 
        p_object = (vlc_object_t *)pl_Hold( p_intf );
 
265
        p_object = vlc_object_hold(pl_Get( p_intf ));
277
266
 
278
267
    var_SetString( p_object , "equalizer-preset" , preset_list[[sender indexOfSelectedItem]] );
279
268
 
307
296
 
308
297
- (IBAction)enable:(id)sender
309
298
{
310
 
    ChangeFiltersString( VLCIntf, (char *)"equalizer", [sender state] );
 
299
//    ChangeFiltersString( VLCIntf, (char *)"equalizer", [sender state] );
 
300
    // to fix #3718
 
301
    aout_EnableFilter( pl_Get( VLCIntf ), (char *)"equalizer", [sender state]);
311
302
}
312
303
 
313
304
- (IBAction)preampSliderUpdated:(id)sender
315
306
    intf_thread_t *p_intf = VLCIntf;
316
307
    float f_preamp = [sender floatValue] ;
317
308
 
318
 
    vlc_object_t *p_object = vlc_object_find( p_intf,
319
 
                                              VLC_OBJECT_AOUT, FIND_ANYWHERE );
 
309
    vlc_object_t *p_object = VLC_OBJECT(getAout());
320
310
    if( p_object == NULL )
321
 
        p_object = (vlc_object_t *)pl_Hold( p_intf );
 
311
        p_object = vlc_object_hold(pl_Get( p_intf ));
322
312
 
323
313
    var_SetFloat( p_object, "equalizer-preamp", f_preamp );
324
314
 
340
330
    {
341
331
        [o_window orderOut:sender];
342
332
        [o_btn_equalizer setState:NSOffState];
 
333
        [o_btn_equalizer_embedded setState:NSOffState];
343
334
    }
344
335
    else
345
336
    {
346
337
        [o_window makeKeyAndOrderFront:sender];
347
338
        [o_btn_equalizer setState:NSOnState];
 
339
        [o_btn_equalizer_embedded setState:NSOnState];
348
340
    }
349
341
}
350
342
 
352
344
{
353
345
    intf_thread_t *p_intf = VLCIntf;
354
346
    bool b_2p = [sender state] ? true : false;
355
 
    vlc_object_t *p_object= vlc_object_find( p_intf,
356
 
                                             VLC_OBJECT_AOUT, FIND_ANYWHERE );
357
 
    aout_instance_t *p_aout = (aout_instance_t *)p_object;
 
347
    aout_instance_t *p_aout = getAout();
 
348
    vlc_object_t *p_object= VLC_OBJECT(p_aout);
358
349
    if( p_object == NULL )
359
 
        p_object = (vlc_object_t *)pl_Hold( p_intf );
 
350
        p_object = vlc_object_hold(pl_Get( p_intf ));
360
351
 
361
352
    var_SetBool( p_object, "equalizer-2pass", b_2p );
362
 
    if( ( [o_ckb_enable state] ) && ( p_aout != NULL ) )
363
 
    {
364
 
        int i;
365
 
        for( i = 0; i < p_aout->i_nb_inputs; i++ )
366
 
        {
367
 
            p_aout->pp_inputs[i]->b_restart = true;
368
 
        }
369
 
    }
370
353
 
371
354
    if( (BOOL)config_GetInt( p_intf, "macosx-eq-keep" ) == YES )
372
355
    {
388
371
- (void)awakeFromNib
389
372
{
390
373
    int i;
391
 
    vlc_object_t *p_object= vlc_object_find( VLCIntf,
392
 
                                             VLC_OBJECT_AOUT, FIND_ANYWHERE );
 
374
    vlc_object_t *p_object= VLC_OBJECT(getAout());
393
375
    if( p_object == NULL )
394
 
        p_object = (vlc_object_t *)pl_Hold( VLCIntf );
 
376
        p_object = vlc_object_hold(pl_Get( VLCIntf ));
395
377
 
396
378
    [o_window setExcludedFromWindowsMenu: TRUE];
397
379
 
409
391
        {
410
392
            if( strcmp( preset_list[i], psz_preset ) )
411
393
                continue;
412
 
    
 
394
 
413
395
            [o_popup_presets selectItemAtIndex: i];
414
 
        
 
396
 
415
397
 
416
398
            [o_slider_preamp setFloatValue: eqz_preset_10b[i]->f_preamp];
417
399
            [self setBandSlidersValues: (float *)eqz_preset_10b[i]->f_amp];
419
401
            if( strcmp( psz_preset, "flat" ) )
420
402
            {
421
403
                char psz_bands[100];
422
 
    
 
404
 
423
405
                snprintf( psz_bands, sizeof( psz_bands ),
424
406
                          "%.1f %.1f %.1f %.1f %.1f %.1f %.1f "
425
407
                          "%.1f %.1f %.1f",
433
415
                          eqz_preset_10b[i]->f_amp[7],
434
416
                          eqz_preset_10b[i]->f_amp[8],
435
417
                          eqz_preset_10b[i]->f_amp[9] );
436
 
    
 
418
 
437
419
                var_Create( p_object, "equalizer-preamp", VLC_VAR_FLOAT |
438
420
                            VLC_VAR_DOINHERIT );
439
421
                var_Create( p_object, "equalizer-bands", VLC_VAR_STRING |
447
429
        vlc_object_release( p_object );
448
430
    }
449
431
 
450
 
    [self equalizerUpdated];    
 
432
    [self equalizerUpdated];
451
433
}
452
434
 
453
435