1 /*****************************************************************************
2 * extended.m: MacOS X Extended interface panel
3 *****************************************************************************
4 * Copyright (C) 2005-2008 the VideoLAN team
7 * Authors: Felix Paul Kühne <fkuehne@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
33 #import <vlc_interface.h>
35 /*****************************************************************************
36 * VLCExtended implementation
37 *****************************************************************************/
39 @implementation VLCExtended
41 static VLCExtended *_o_sharedInstance = nil;
43 + (VLCExtended *)sharedInstance
45 return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
50 if (_o_sharedInstance) {
53 _o_sharedInstance = [super init];
56 return _o_sharedInstance;
59 /*****************************************************************************
61 *****************************************************************************/
65 /* localise GUI-strings */
66 /* method is called from intf.m (in method showExtended) */
67 [o_extended_window setTitle: _NS("Extended controls")];
68 [o_lbl_video setStringValue: _NS("Video")];
69 [o_lbl_audio setStringValue: _NS("Audio")];
70 [o_lbl_audioFlts setStringValue: _NS("Audio filters")];
71 [o_lbl_videoFlts setStringValue: _NS("Video filters")];
72 [o_lbl_adjustImage setStringValue: _NS("Image adjustment")];
73 [o_btn_vidFlts_mrInfo setToolTip: _NS("Shows more information about the available video filters.")];
74 [o_ckb_wave setTitle: _NS("Wave")];
75 [o_ckb_ripple setTitle: _NS("Ripple")];
76 [o_ckb_psycho setTitle: _NS("Psychedelic")];
77 [o_ckb_gradient setTitle: _NS("Gradient")];
78 [o_lbl_general setStringValue: _NS("General editing filters")];
79 [o_lbl_distort setStringValue: _NS("Distortion filters")];
80 [o_ckb_blur setTitle: _NS("Blur")];
81 [o_ckb_blur setToolTip: _NS("Adds motion blurring to the image")];
82 [o_ckb_imgClone setTitle: _NS("Image clone")];
83 [o_ckb_imgClone setToolTip: _NS("Creates several copies of the Video "
85 [o_ckb_imgCrop setTitle: _NS("Image cropping")];
86 [o_ckb_imgCrop setToolTip: _NS("Crops a defined part of the image")];
87 [o_ckb_imgInvers setTitle: _NS("Invert colors")];
88 [o_ckb_imgInvers setToolTip: _NS("Inverts the colors of the image")];
89 [o_ckb_trnsform setTitle: _NS("Transformation")];
90 [o_ckb_trnsform setToolTip: _NS("Rotates or flips the image")];
91 [o_ckb_intZoom setTitle: _NS("Interactive Zoom")];
92 [o_ckb_intZoom setToolTip: _NS("Enables an interactive Zoom feature")];
93 [o_ckb_vlme_norm setTitle: _NS("Volume normalization")];
94 [o_ckb_vlme_norm setToolTip: _NS("Prevents the audio output from going "
95 "over a predefined value.")];
96 [o_ckb_hdphnVirt setTitle: _NS("Headphone virtualization")];
97 [o_ckb_hdphnVirt setToolTip: _NS("Imitates the effect of surround sound "
98 "when using headphones.")];
99 [o_lbl_maxLevel setStringValue: _NS("Maximum level")];
100 [o_btn_rstrDefaults setTitle: _NS("Restore Defaults")];
101 [o_ckb_enblAdjustImg setTitle: _NS("Enable")];
102 [o_lbl_brightness setStringValue: _NS("Brightness")];
103 [o_lbl_contrast setStringValue: _NS("Contrast")];
104 [o_lbl_gamma setStringValue: _NS("Gamma")];
105 [o_lbl_hue setStringValue: _NS("Hue")];
106 [o_lbl_saturation setStringValue: _NS("Saturation")];
107 [o_lbl_opaque setStringValue: _NS("Opaqueness")];
113 /* set the adjust-filter-sliders to the values from the prefs and enable
116 intf_thread_t * p_intf = VLCIntf;
117 psz_vfilters = config_GetPsz( p_intf, "vout-filter" );
118 /* set the video-filter-checkboxes to the correct values */
121 [o_ckb_blur setState: (int)strstr( psz_vfilters, "motionblur")];
122 [o_ckb_imgClone setState: (int)strstr( psz_vfilters, "clone")];
123 [o_ckb_imgCrop setState: (int)strstr( psz_vfilters, "crop")];
124 [o_ckb_trnsform setState: (int)strstr( psz_vfilters, "transform")];
126 free( psz_vfilters );
129 /* set the video-filter checkboxes to the correct values */
130 char * psz_vifilters;
131 psz_vifilters = config_GetPsz( p_intf, "video-filter" );
132 if( psz_vifilters && strstr( psz_vifilters, "adjust" ) )
134 [o_ckb_enblAdjustImg setState: NSOnState];
135 [o_btn_rstrDefaults setEnabled: YES];
136 [o_sld_brightness setEnabled: YES];
137 [o_sld_contrast setEnabled: YES];
138 [o_sld_gamma setEnabled: YES];
139 [o_sld_hue setEnabled: YES];
140 [o_sld_saturation setEnabled: YES];
144 [o_ckb_enblAdjustImg setState: NSOffState];
145 [o_btn_rstrDefaults setEnabled: NO];
146 [o_sld_brightness setEnabled: NO];
147 [o_sld_contrast setEnabled: NO];
148 [o_sld_gamma setEnabled: NO];
149 [o_sld_hue setEnabled: NO];
150 [o_sld_saturation setEnabled: NO];
154 [o_ckb_wave setState: (int)strstr( psz_vifilters, "wave")];
155 [o_ckb_psycho setState: (int)strstr( psz_vifilters, "psychedelic")];
156 [o_ckb_ripple setState: (int)strstr( psz_vifilters, "ripple")];
157 [o_ckb_gradient setState: (int)strstr( psz_vifilters, "gradient")];
158 [o_ckb_imgInvers setState: (int)strstr( psz_vifilters, "invert")];
160 free( psz_vifilters );
163 /* set the audio-filter-checkboxes to the values taken from the prefs */
165 psz_afilters = config_GetPsz( p_intf, "audio-filter" );
168 [o_ckb_hdphnVirt setState: (int)strstr( psz_afilters, "headphone" ) ];
169 [o_ckb_vlme_norm setState: (int)strstr( psz_afilters, "normvol" ) ];
171 free( psz_afilters );
177 /* collaps all views so Cocoa saves the window position correctly */
178 if( o_adjImg_expanded )
179 [self expandAdjustImage: nil];
181 if( o_audFlts_expanded )
182 [self expandAudioFilters: nil];
184 if( o_vidFlts_expanded )
185 [self expandVideoFilters: nil];
188 - (BOOL)getConfigChanged
190 return o_config_changed;
195 /* get the correct slider values from the prefs, in case they were changed
197 intf_thread_t * p_intf = VLCIntf;
199 int i_value = config_GetInt( p_intf, "hue" );
200 if( i_value > 0 && i_value < 360 )
202 [o_sld_hue setIntValue: i_value];
207 f_value = config_GetFloat( p_intf, "saturation" );
208 if( f_value > 0 && f_value < 5 )
209 [o_sld_saturation setIntValue: (int)(100 * f_value) ];
211 f_value = config_GetFloat( p_intf, "contrast" );
212 if( f_value > 0 && f_value < 4 )
213 [o_sld_contrast setIntValue: (int)(100 * f_value) ];
215 f_value = config_GetFloat( p_intf, "brightness" );
216 if( f_value > 0 && f_value < 2 )
217 [o_sld_brightness setIntValue: (int)(100 * f_value) ];
219 f_value = config_GetFloat( p_intf, "gamma" );
220 if( f_value > 0 && f_value < 10 )
221 [o_sld_gamma setIntValue: (int)(10 * f_value) ];
223 f_value = config_GetFloat( p_intf, "norm-max-level" );
224 if( f_value > 0 && f_value < 10 )
225 [o_sld_maxLevel setFloatValue: f_value ];
227 [o_sld_opaque setFloatValue: (config_GetFloat( p_intf,
228 "macosx-opaqueness") * 100)];
230 /* show the window */
231 [o_extended_window displayIfNeeded];
232 [o_extended_window makeKeyAndOrderFront:nil];
235 - (IBAction)enableAdjustImage:(id)sender
237 /* en-/disable the sliders */
238 if ([o_ckb_enblAdjustImg state] == NSOnState)
240 [o_btn_rstrDefaults setEnabled: YES];
241 [o_sld_brightness setEnabled: YES];
242 [o_sld_contrast setEnabled: YES];
243 [o_sld_gamma setEnabled: YES];
244 [o_sld_hue setEnabled: YES];
245 [o_sld_saturation setEnabled: YES];
246 [self changeVideoFiltersString: "adjust" onOrOff: VLC_TRUE];
250 [o_btn_rstrDefaults setEnabled: NO];
251 [o_sld_brightness setEnabled: NO];
252 [o_sld_contrast setEnabled: NO];
253 [o_sld_gamma setEnabled: NO];
254 [o_sld_hue setEnabled: NO];
255 [o_sld_saturation setEnabled: NO];
256 [self changeVideoFiltersString: "adjust" onOrOff: VLC_FALSE];
260 - (IBAction)restoreDefaultsForAdjustImage:(id)sender
262 /* reset the sliders */
263 [o_sld_brightness setIntValue: 100];
264 [o_sld_contrast setIntValue: 100];
265 [o_sld_gamma setIntValue: 10];
266 [o_sld_hue setIntValue: 0];
267 [o_sld_saturation setIntValue: 100];
268 [o_sld_opaque setIntValue: 100];
270 /* transmit the values */
271 [self sliderActionAdjustImage: o_sld_brightness];
272 [self sliderActionAdjustImage: o_sld_contrast];
273 [self sliderActionAdjustImage: o_sld_gamma];
274 [self sliderActionAdjustImage: o_sld_hue];
275 [self sliderActionAdjustImage: o_sld_saturation];
276 [self opaqueSliderAction: o_sld_opaque];
279 - (IBAction)sliderActionAdjustImage:(id)sender
281 /* read-out the sliders' values and apply them */
282 intf_thread_t * p_intf = VLCIntf;
283 vout_thread_t *p_vout = (vout_thread_t *)vlc_object_find(p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE);
284 vlc_object_t *p_filter;
288 msg_Dbg( p_intf, "no vout present, saving settings anyway" );
289 if (sender == o_sld_brightness)
291 config_PutFloat( p_intf , "brightness" , [o_sld_brightness floatValue] / 100);
293 else if (sender == o_sld_contrast)
295 config_PutFloat( p_intf , "contrast" , [o_sld_contrast floatValue] / 100);
297 else if (sender == o_sld_gamma)
299 config_PutFloat( p_intf , "gamma" , [o_sld_gamma floatValue] / 10);
301 else if (sender == o_sld_hue)
303 config_PutInt( p_intf , "hue" , [o_sld_hue intValue]);
305 else if (sender == o_sld_saturation)
307 config_PutFloat( p_intf , "saturation" , [o_sld_saturation floatValue] / 100);
311 msg_Warn( p_intf, "the corresponding subfilter coundn't be found" );
316 msg_Dbg( p_intf, "we found a vout to adjust, let's look for the filter" );
317 p_filter = (vlc_object_t *)vlc_object_find_name( p_intf, "adjust", FIND_ANYWHERE );
321 msg_Err( p_intf, "we're unable to find the adjust filter!" );
322 vlc_object_release( p_vout );
326 if (sender == o_sld_brightness)
328 var_SetFloat( p_filter, "brightness", [o_sld_brightness floatValue] / 100 );
329 config_PutFloat( p_intf, "brightness", [o_sld_brightness floatValue] / 100 );
331 else if (sender == o_sld_contrast)
333 var_SetFloat( p_filter, "contrast", [o_sld_contrast floatValue] / 100 );
334 config_PutFloat( p_intf, "contrast", [o_sld_contrast floatValue] / 100 );
336 else if (sender == o_sld_gamma)
338 var_SetFloat( p_filter, "gamma", [o_sld_gamma floatValue] / 10 );
339 config_PutFloat( p_intf, "gamma", [o_sld_gamma floatValue] / 10 );
341 else if (sender == o_sld_hue)
343 var_SetInteger( p_filter, "hue", [o_sld_hue intValue] );
344 config_PutInt( p_intf , "hue" , [o_sld_hue intValue] );
346 else if (sender == o_sld_saturation)
348 var_SetFloat( p_filter, "saturation", [o_sld_saturation floatValue] / 100 );
349 config_PutFloat( p_intf , "saturation" , [o_sld_saturation floatValue] / 100 );
353 msg_Warn( p_intf, "couldn't find variable for slider!" );
355 vlc_object_release( p_filter );
356 vlc_object_release( p_vout );
359 o_config_changed = YES;
362 /* change the opaqueness of the vouts */
363 - (IBAction)opaqueSliderAction:(id)sender
366 id o_window = [NSApp keyWindow];
367 NSArray *o_windows = [NSApp orderedWindows];
368 NSEnumerator *o_enumerator = [o_windows objectEnumerator];
369 playlist_t * p_playlist = pl_Yield( VLCIntf );
370 vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
371 vout_thread_t *p_real_vout;
373 val.f_float = [o_sld_opaque floatValue] / 100;
377 p_real_vout = [VLCVoutView getRealVout: p_vout];
378 var_Set( p_real_vout, "macosx-opaqueness", val );
380 while ((o_window = [o_enumerator nextObject]))
382 if( [[o_window className] isEqualToString: @"VLCVoutWindow"] ||
383 [[[VLCMain sharedInstance] getEmbeddedList]
384 windowContainsEmbedded: o_window])
386 [o_window setAlphaValue: val.f_float];
390 vlc_object_release( p_vout );
394 config_PutFloat( p_playlist , "macosx-opaqueness" , val.f_float );
396 vlc_object_release( p_playlist );
398 o_config_changed = YES;
401 - (IBAction)enableHeadphoneVirtualizer:(id)sender
403 /* en-/disable headphone virtualisation */
404 if ([o_ckb_hdphnVirt state] == NSOnState)
405 [self changeAFiltersString: "headphone_channel_mixer" onOrOff: VLC_TRUE ];
407 [self changeAFiltersString: "headphone_channel_mixer" onOrOff: VLC_FALSE ];
410 - (IBAction)sliderActionMaximumAudioLevel:(id)sender
412 /* read-out the slider's value and apply it */
413 intf_thread_t * p_intf = VLCIntf;
414 aout_instance_t * p_aout= (aout_instance_t *)vlc_object_find(p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE);
418 var_SetFloat( p_aout, "norm-max-level", [o_sld_maxLevel floatValue] );
419 vlc_object_release( p_aout );
422 config_PutFloat( p_intf, "norm-max-level", [o_sld_maxLevel floatValue] );
424 o_config_changed = YES;
427 - (IBAction)enableVolumeNormalization:(id)sender
429 /* en-/disable volume normalisation */
430 if( [o_ckb_vlme_norm state] == NSOnState )
431 [self changeAFiltersString: "normvol" onOrOff: YES ];
433 [self changeAFiltersString: "normvol" onOrOff: NO ];
436 - (IBAction)expandAdjustImage:(id)sender
438 /* expand or collapse adjImg */
439 NSRect o_win_rect = [o_extended_window frame];
440 NSRect o_box_audFlts_rect = [o_box_audFlts frame];
441 NSRect o_box_vidFlts_rect = [o_box_vidFlts frame];
442 NSRect o_box_adjImg_rect = [o_box_adjImg frame];
444 if( o_adjImg_expanded )
446 /* move the window contents upwards (partially done through settings
447 * inside the nib) and resize the window */
448 o_win_rect.size.height = o_win_rect.size.height - 193;
449 o_win_rect.origin.y = [o_extended_window frame].origin.y + 193;
450 o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y + 193;
451 o_box_vidFlts_rect.origin.y = o_box_vidFlts_rect.origin.y + 193;
453 /* remove the inserted view */
454 [o_adjustImg_view removeFromSuperviewWithoutNeedingDisplay];
458 /* move the window contents downwards and resize the window */
459 o_win_rect.size.height = o_win_rect.size.height + 193;
460 o_win_rect.origin.y = [o_extended_window frame].origin.y - 193;
461 o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y - 193;
462 o_box_vidFlts_rect.origin.y = o_box_vidFlts_rect.origin.y - 193;
465 [o_box_audFlts setFrameFromContentFrame: o_box_audFlts_rect];
466 [o_box_vidFlts setFrameFromContentFrame: o_box_vidFlts_rect];
467 [o_extended_window displayIfNeeded];
468 [o_extended_window setFrame: o_win_rect display:YES animate: YES];
470 if( o_adjImg_expanded )
472 o_box_adjImg_rect.size.height = [o_box_adjImg frame].size.height - 193;
473 o_adjImg_expanded = NO;
478 o_box_adjImg_rect.size.height = [o_box_adjImg frame].size.height + 193;
479 [o_adjustImg_view setFrame: NSMakeRect( 20, -10, 370, 203)];
480 [o_adjustImg_view setNeedsDisplay:YES];
481 [o_adjustImg_view setAutoresizesSubviews: YES];
482 [[o_box_adjImg contentView] addSubview: o_adjustImg_view];
483 o_adjImg_expanded = YES;
485 [o_box_adjImg setFrameFromContentFrame: o_box_adjImg_rect];
488 - (IBAction)expandAudioFilters:(id)sender
490 /* expand or collapse audFlts */
491 NSRect o_win_rect = [o_extended_window frame];
492 NSRect o_box_audFlts_rect = [o_box_audFlts frame];
494 if( o_audFlts_expanded )
496 /* move the window contents upwards (partially done through settings
497 * inside the nib) and resize the window */
498 o_win_rect.size.height = o_win_rect.size.height - 66;
499 o_win_rect.origin.y = [o_extended_window frame].origin.y + 66;
501 /* remove the inserted view */
502 [o_audioFlts_view removeFromSuperviewWithoutNeedingDisplay];
506 /* move the window contents downwards and resize the window */
507 o_win_rect.size.height = o_win_rect.size.height + 66;
508 o_win_rect.origin.y = [o_extended_window frame].origin.y - 66;
510 [o_extended_window displayIfNeeded];
511 [o_extended_window setFrame: o_win_rect display:YES animate: YES];
514 if( o_audFlts_expanded )
516 o_box_audFlts_rect.size.height = [o_box_audFlts frame].size.height - 66;
517 o_audFlts_expanded = NO;
522 o_box_audFlts_rect.size.height = [o_box_audFlts frame].size.height + 66;
523 [o_audioFlts_view setFrame: NSMakeRect( 20, -20, 370, 76)];
524 [o_audioFlts_view setNeedsDisplay:YES];
525 [o_audioFlts_view setAutoresizesSubviews: YES];
526 [[o_box_audFlts contentView] addSubview: o_audioFlts_view];
527 o_audFlts_expanded = YES;
529 [o_box_audFlts setFrameFromContentFrame: o_box_audFlts_rect];
532 - (IBAction)expandVideoFilters:(id)sender
534 /* expand or collapse vidFlts */
535 NSRect o_win_rect = [o_extended_window frame];
536 NSRect o_box_audFlts_rect = [o_box_audFlts frame];
537 NSRect o_box_vidFlts_rect = [o_box_vidFlts frame];
539 if( o_vidFlts_expanded )
541 /* move the window contents upwards (partially done through settings
542 * inside the nib) and resize the window */
543 o_win_rect.size.height = o_win_rect.size.height - 172;
544 o_win_rect.origin.y = [o_extended_window frame].origin.y + 172;
545 o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y + 172;
547 /* remove the inserted view */
548 [o_videoFilters_view removeFromSuperviewWithoutNeedingDisplay];
552 /* move the window contents downwards and resize the window */
553 o_win_rect.size.height = o_win_rect.size.height + 172;
554 o_win_rect.origin.y = [o_extended_window frame].origin.y - 172;
555 o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y - 172;
558 [o_box_audFlts setFrameFromContentFrame: o_box_audFlts_rect];
559 [o_extended_window displayIfNeeded];
560 [o_extended_window setFrame: o_win_rect display:YES animate: YES];
562 if( o_vidFlts_expanded )
564 o_box_vidFlts_rect.size.height = [o_box_vidFlts frame].size.height - 172;
565 o_vidFlts_expanded = NO;
570 o_box_vidFlts_rect.size.height = [o_box_vidFlts frame].size.height + 172;
571 [o_videoFilters_view setFrame: NSMakeRect( 20, -10, 370, 172)];
572 [o_videoFilters_view setNeedsDisplay:YES];
573 [o_videoFilters_view setAutoresizesSubviews: YES];
574 [[o_box_vidFlts contentView] addSubview: o_videoFilters_view];
575 o_vidFlts_expanded = YES;
577 [o_box_vidFlts setFrameFromContentFrame: o_box_vidFlts_rect];
580 - (IBAction)videoFilterAction:(id)sender
582 /* en-/disable video filters */
583 if (sender == o_ckb_blur)
584 [self changeVoutFiltersString: "motionblur" onOrOff: [o_ckb_blur state]];
586 else if (sender == o_ckb_imgClone)
587 [self changeVoutFiltersString: "clone" onOrOff: [o_ckb_imgClone state]];
589 else if (sender == o_ckb_imgCrop)
590 [self changeVoutFiltersString: "crop" onOrOff: [o_ckb_imgCrop state]];
592 else if (sender == o_ckb_imgInvers)
593 [self changeVideoFiltersString: "invert" onOrOff: [o_ckb_imgInvers state]];
595 else if (sender == o_ckb_trnsform)
596 [self changeVoutFiltersString: "transform" onOrOff: [o_ckb_trnsform state]];
598 else if (sender == o_ckb_intZoom )
599 [self changeVoutFiltersString: "magnify" onOrOff: [o_ckb_intZoom state]];
601 else if (sender == o_ckb_wave )
602 [self changeVideoFiltersString: "wave" onOrOff: [o_ckb_wave state]];
604 else if (sender == o_ckb_gradient )
605 [self changeVideoFiltersString: "gradient" onOrOff: [o_ckb_gradient state]];
607 else if (sender == o_ckb_psycho )
608 [self changeVideoFiltersString: "psychedelic" onOrOff: [o_ckb_psycho state]];
610 else if (sender == o_ckb_ripple )
611 [self changeVideoFiltersString: "ripple" onOrOff: [o_ckb_ripple state]];
614 msg_Err( VLCIntf, "cannot find switched video-filter" ); /* this can't happen */
617 - (IBAction)moreInfoVideoFilters:(id)sender
619 /* show info sheet */
620 NSBeginInformationalAlertSheet(_NS("About the video filters"),
629 _NS("This panel allows on-the-fly selection of various video effects.\n"
630 "These filters can be configured individually in the Preferences, in "
631 "the subsections of Video/Filters.\n"
632 "To choose the order in which the filter are applied, a filter "
633 "option string can be set in the Preferences, Video / Filters section."));
637 /*****************************************************************************
638 * methods to communicate changes to VLC's core
639 *****************************************************************************/
641 - (void)changeVoutFiltersString:(char *)psz_name onOrOff:(vlc_bool_t )b_add
643 /* copied from ../wxwidgets/extrapanel.cpp
644 * renamed to conform with Cocoa's rules */
645 /* this method only changes 1st generation video filters (the ones that
646 * can't be used for transcoding). Have a look at changeVideoFiltersString
647 * for the 2nd generation filters. */
649 vout_thread_t *p_vout;
650 intf_thread_t * p_intf = VLCIntf;
652 char *psz_parser, *psz_string;
653 psz_string = config_GetPsz( p_intf, "vout-filter" );
655 if( !psz_string ) psz_string = strdup("");
657 psz_parser = strstr( psz_string, psz_name );
663 psz_parser = psz_string;
664 asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
665 psz_string, psz_name );
677 memmove( psz_parser, psz_parser + strlen(psz_name) +
678 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
679 strlen(psz_parser + strlen(psz_name)) + 1 );
681 /* Remove trailing : : */
682 if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
684 *(psz_string+strlen(psz_string ) -1 ) = '\0';
693 /* Vout is not kept, so put that in the config */
694 config_PutPsz( p_intf, "vout-filter", psz_string );
696 /* Try to set on the fly */
697 p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
701 var_SetString( p_vout, "vout-filter", psz_string );
702 vlc_object_release( p_vout );
707 o_config_changed = YES;
711 - (void)changeVideoFiltersString:(char *)psz_name onOrOff:(vlc_bool_t )b_add
713 /* same as changeVoutFiltersString but addressing the "video-filter"
714 * variable which represents the video filter 2 modules */
716 vout_thread_t *p_vout;
717 intf_thread_t * p_intf = VLCIntf;
719 char *psz_parser, *psz_string;
720 psz_string = config_GetPsz( p_intf, "video-filter" );
722 if( !psz_string ) psz_string = strdup("");
724 psz_parser = strstr( psz_string, psz_name );
730 psz_parser = psz_string;
731 asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
732 psz_string, psz_name );
744 memmove( psz_parser, psz_parser + strlen(psz_name) +
745 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
746 strlen(psz_parser + strlen(psz_name)) + 1 );
748 /* Remove trailing : : */
749 if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
751 *(psz_string+strlen(psz_string ) -1 ) = '\0';
760 /* Vout is not kept, so put that in the config */
761 config_PutPsz( p_intf, "video-filter", psz_string );
763 /* Try to set on the fly */
764 p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
768 var_SetString( p_vout, "video-filter", psz_string );
769 vlc_object_release( p_vout );
774 o_config_changed = YES;
777 - (void)changeAFiltersString: (char *)psz_name onOrOff: (vlc_bool_t )b_add;
779 /* copied from ../wxwidgets/extrapanel.cpp
780 * renamed to conform with Cocoa's rules */
782 char *psz_parser, *psz_string;
783 intf_thread_t * p_intf = VLCIntf;
784 aout_instance_t * p_aout= (aout_instance_t *)vlc_object_find(p_intf,
785 VLC_OBJECT_AOUT, FIND_ANYWHERE);
789 psz_string = var_GetNonEmptyString( p_aout, "audio-filter" );
793 psz_string = config_GetPsz( p_intf, "audio-filter" );
796 if( !psz_string ) psz_string = strdup("");
798 psz_parser = strstr( psz_string, psz_name );
804 psz_parser = psz_string;
805 asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
806 psz_string, psz_name );
818 memmove( psz_parser, psz_parser + strlen(psz_name) +
819 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
820 strlen(psz_parser + strlen(psz_name)) + 1 );
822 if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
824 *(psz_string+strlen(psz_string ) -1 ) = '\0';
836 config_PutPsz( p_intf, "audio-filter", psz_string );
840 var_SetString( p_aout, "audio-filter", psz_string );
842 while( i < p_aout->i_nb_inputs )
844 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
847 vlc_object_release( p_aout );
851 o_config_changed = YES;
856 /* save the preferences to make sure that our module-changes will up on
857 * next launch again */
858 playlist_t * p_playlist = pl_Yield( VLCIntf );
860 NSArray * theModules;
861 theModules = [[NSArray alloc] initWithObjects: @"main",
871 @"headphone_channel_mixer",
876 while ( x != [theModules count] )
878 returnedValue = config_SaveConfigFile( p_playlist, [[theModules
879 objectAtIndex: x] UTF8String] );
881 if (returnedValue != 0)
883 msg_Err(p_playlist, "unable to save the preferences of the "
884 "extended control attribute '%s' (%i)",
885 [[theModules objectAtIndex: x] UTF8String] , returnedValue);
886 [theModules release];
887 vlc_object_release( p_playlist );
895 msg_Dbg( VLCIntf, "VLCExtended: saved certain preferences successfully" );
897 [theModules release];
898 vlc_object_release( p_playlist );