1 /*****************************************************************************
2 * extended.m: MacOS X Extended interface panel
3 *****************************************************************************
4 * Copyright (C) 2005-2006 the VideoLAN team
7 * Authors: Felix Kühne <fkuehne@users.sf.net>
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 * the code used to bind with VLC's modules is heavily based upon
28 * ../wxwidgets/extrapanel.cpp, written by Clément Stenac.
29 * the code used to insert/remove the views was inspired by intf.m,
30 * written by Derk-Jan Hartman and Benjamin Pracht.
31 * (all 3 are members of the VideoLAN team)
32 *****************************************************************************/
35 /*****************************************************************************
37 *****************************************************************************/
43 #import <aout_internal.h>
47 /*****************************************************************************
48 * VLCExtended implementation
49 *****************************************************************************/
51 @implementation VLCExtended
53 static VLCExtended *_o_sharedInstance = nil;
55 + (VLCExtended *)sharedInstance
57 return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
62 if (_o_sharedInstance) {
65 _o_sharedInstance = [super init];
68 return _o_sharedInstance;
71 /*****************************************************************************
73 *****************************************************************************/
77 /* localise GUI-strings */
78 /* method is called from intf.m (in method showExtended) */
79 [o_extended_window setTitle: _NS("Extended controls")];
80 [o_lbl_video setStringValue: _NS("Video")];
81 [o_lbl_audio setStringValue: _NS("Audio")];
82 [o_lbl_audioFlts setStringValue: _NS("Audio filters")];
83 [o_lbl_videoFlts setStringValue: _NS("Video filters")];
84 [o_lbl_adjustImage setStringValue: _NS("Image adjustment")];
85 [o_btn_vidFlts_mrInfo setTitle: _NS("More Info")];
86 [o_ckb_wave setTitle: _NS("Wave")];
87 [o_ckb_ripple setTitle: _NS("Ripple")];
88 [o_ckb_psycho setTitle: _NS("Psychedelic")];
89 [o_ckb_gradient setTitle: _NS("Gradient")];
90 [o_lbl_general setStringValue: _NS("General editing filters")];
91 [o_lbl_distort setStringValue: _NS("Distortion filters")];
92 [o_ckb_blur setTitle: _NS("Blur")];
93 [o_ckb_blur setToolTip: _NS("Adds motion blurring to the image")];
94 [o_ckb_imgClone setTitle: _NS("Image clone")];
95 [o_ckb_imgClone setToolTip: _NS("Creates several copies of the Video "
97 [o_ckb_imgCrop setTitle: _NS("Image cropping")];
98 [o_ckb_imgCrop setToolTip: _NS("Crops a defined part of the image")];
99 [o_ckb_imgInvers setTitle: _NS("Invert colors")];
100 [o_ckb_imgInvers setToolTip: _NS("Inverts the colors of the image")];
101 [o_ckb_trnsform setTitle: _NS("Transformation")];
102 [o_ckb_trnsform setToolTip: _NS("Rotates or flips the image")];
103 [o_ckb_intZoom setTitle: _NS("Interactive Zoom")];
104 [o_ckb_intZoom setToolTip: _NS("Enables an interactive Zoom feature")];
105 [o_ckb_vlme_norm setTitle: _NS("Volume normalization")];
106 [o_ckb_vlme_norm setToolTip: _NS("Prevents the audio output from going "
107 "over a predefined value.")];
108 [o_ckb_hdphnVirt setTitle: _NS("Headphone virtualization")];
109 [o_ckb_hdphnVirt setToolTip: _NS("Imitates the effect of surround sound "
110 "when using headphones.")];
111 [o_lbl_maxLevel setStringValue: _NS("Maximum level")];
112 [o_btn_rstrDefaults setTitle: _NS("Restore Defaults")];
113 [o_ckb_enblAdjustImg setTitle: _NS("Enable")];
114 [o_lbl_brightness setStringValue: _NS("Brightness")];
115 [o_lbl_contrast setStringValue: _NS("Contrast")];
116 [o_lbl_gamma setStringValue: _NS("Gamma")];
117 [o_lbl_hue setStringValue: _NS("Hue")];
118 [o_lbl_saturation setStringValue: _NS("Saturation")];
119 [o_lbl_opaque setStringValue: _NS("Opaqueness")];
125 /* set the adjust-filter-sliders to the values from the prefs and enable
128 intf_thread_t * p_intf = VLCIntf;
129 psz_vfilters = config_GetPsz( p_intf, "vout-filter" );
130 if( psz_vfilters && strstr( psz_vfilters, "adjust" ) )
132 [o_ckb_enblAdjustImg setState: NSOnState];
133 [o_btn_rstrDefaults setEnabled: YES];
134 [o_sld_brightness setEnabled: YES];
135 [o_sld_contrast setEnabled: YES];
136 [o_sld_gamma setEnabled: YES];
137 [o_sld_hue setEnabled: YES];
138 [o_sld_saturation setEnabled: YES];
142 [o_ckb_enblAdjustImg setState: NSOffState];
143 [o_btn_rstrDefaults setEnabled: NO];
144 [o_sld_brightness setEnabled: NO];
145 [o_sld_contrast setEnabled: NO];
146 [o_sld_gamma setEnabled: NO];
147 [o_sld_hue setEnabled: NO];
148 [o_sld_saturation setEnabled: NO];
151 /* set the other video-filter-checkboxes to the correct values */
154 [o_ckb_blur setState: (int)strstr( psz_vfilters, "motionblur")];
155 [o_ckb_imgClone setState: (int)strstr( psz_vfilters, "clone")];
156 [o_ckb_imgCrop setState: (int)strstr( psz_vfilters, "crop")];
157 [o_ckb_trnsform setState: (int)strstr( psz_vfilters, "transform")];
159 free( psz_vfilters );
162 /* set the video-filter checkboxes to the correct values */
163 char * psz_vifilters;
164 psz_vifilters = config_GetPsz( p_intf, "video-filter" );
167 [o_ckb_wave setState: (int)strstr( psz_vifilters, "wave")];
168 [o_ckb_psycho setState: (int)strstr( psz_vifilters, "psychedelic")];
169 [o_ckb_ripple setState: (int)strstr( psz_vifilters, "ripple")];
170 [o_ckb_gradient setState: (int)strstr( psz_vifilters, "gradient")];
171 [o_ckb_imgInvers setState: (int)strstr( psz_vifilters, "invert")];
173 free( psz_vifilters );
176 /* set the audio-filter-checkboxes to the values taken from the prefs */
178 psz_afilters = config_GetPsz( p_intf, "audio-filter" );
181 [o_ckb_hdphnVirt setState: (int)strstr( psz_afilters, "headphone" ) ];
182 [o_ckb_vlme_norm setState: (int)strstr( psz_afilters, "normvol" ) ];
184 free( psz_afilters );
190 /* collaps all views so Cocoa saves the window position correctly */
191 if( o_adjImg_expanded )
193 [self extWin_exp_adjImg: nil];
195 if( o_audFlts_expanded )
197 [self extWin_exp_audFlts: nil];
199 if( o_vidFlts_expanded )
201 [self extWin_exp_vidFlts: nil];
205 - (BOOL)getConfigChanged
207 return o_config_changed;
212 /* get the correct slider values from the prefs, in case they were changed
214 intf_thread_t * p_intf = VLCIntf;
216 int i_value = config_GetInt( p_intf, "hue" );
217 if( i_value > 0 && i_value < 360 )
219 [o_sld_hue setIntValue: i_value];
224 f_value = config_GetFloat( p_intf, "saturation" );
225 if( f_value > 0 && f_value < 5 )
227 [o_sld_saturation setIntValue: (int)(100 * f_value) ];
230 f_value = config_GetFloat( p_intf, "contrast" );
231 if( f_value > 0 && f_value < 4 )
233 [o_sld_contrast setIntValue: (int)(100 * f_value) ];
236 f_value = config_GetFloat( p_intf, "brightness" );
237 if( f_value > 0 && f_value < 2 )
239 [o_sld_brightness setIntValue: (int)(100 * f_value) ];
242 f_value = config_GetFloat( p_intf, "gamma" );
243 if( f_value > 0 && f_value < 10 )
245 [o_sld_gamma setIntValue: (int)(10 * f_value) ];
248 f_value = config_GetFloat( p_intf, "norm-max-level" );
249 if( f_value > 0 && f_value < 10 )
251 [o_sld_maxLevel setFloatValue: f_value ];
254 [o_sld_opaque setFloatValue: (config_GetFloat( p_intf,
255 "macosx-opaqueness") * 100)];
258 /* show the window */
259 [o_extended_window displayIfNeeded];
260 [o_extended_window makeKeyAndOrderFront:nil];
263 - (IBAction)adjImg_Enbl:(id)sender
265 /* en-/disable the sliders */
266 if ([o_ckb_enblAdjustImg state] == NSOnState)
268 [o_btn_rstrDefaults setEnabled: YES];
269 [o_sld_brightness setEnabled: YES];
270 [o_sld_contrast setEnabled: YES];
271 [o_sld_gamma setEnabled: YES];
272 [o_sld_hue setEnabled: YES];
273 [o_sld_saturation setEnabled: YES];
274 [self changeVoutFiltersString: "adjust" onOrOff: VLC_TRUE];
276 [o_btn_rstrDefaults setEnabled: NO];
277 [o_sld_brightness setEnabled: NO];
278 [o_sld_contrast setEnabled: NO];
279 [o_sld_gamma setEnabled: NO];
280 [o_sld_hue setEnabled: NO];
281 [o_sld_saturation setEnabled: NO];
282 [self changeVoutFiltersString: "adjust" onOrOff: VLC_FALSE];
286 - (IBAction)adjImg_rstrDefaults:(id)sender
288 /* reset the sliders */
289 [o_sld_brightness setIntValue: 100];
290 [o_sld_contrast setIntValue: 100];
291 [o_sld_gamma setIntValue: 10];
292 [o_sld_hue setIntValue: 0];
293 [o_sld_saturation setIntValue: 100];
295 /* transmit the values */
296 [self adjImg_sliders: o_sld_brightness];
297 [self adjImg_sliders: o_sld_contrast];
298 [self adjImg_sliders: o_sld_gamma];
299 [self adjImg_sliders: o_sld_hue];
300 [self adjImg_sliders: o_sld_saturation];
303 - (IBAction)adjImg_sliders:(id)sender
305 /* read-out the sliders' values and apply them */
306 intf_thread_t * p_intf = VLCIntf;
307 vout_thread_t *p_vout = (vout_thread_t *)vlc_object_find(p_intf,
308 VLC_OBJECT_VOUT, FIND_ANYWHERE);
311 if (sender == o_sld_brightness)
313 config_PutFloat( p_intf , "brightness" , [o_sld_brightness floatValue] / 100);
314 } else if (sender == o_sld_contrast)
316 config_PutFloat( p_intf , "contrast" , [o_sld_contrast floatValue] / 100);
317 } else if (sender == o_sld_gamma)
319 config_PutFloat( p_intf , "gamma" , [o_sld_gamma floatValue] / 10);
320 } else if (sender == o_sld_hue)
322 config_PutInt( p_intf , "hue" , [o_sld_hue intValue]);
323 } else if (sender == o_sld_saturation)
325 config_PutFloat( p_intf , "saturation" , [o_sld_saturation floatValue] / 100);
327 msg_Warn( p_intf, "the corresponding subfilter coundn't be found" );
331 if (sender == o_sld_brightness)
333 val.f_float = [o_sld_brightness floatValue] / 100;
334 var_Set( p_vout, "brightness", val );
335 config_PutFloat( p_intf , "brightness" , [o_sld_brightness floatValue] / 100);
336 } else if (sender == o_sld_contrast)
338 val.f_float = [o_sld_contrast floatValue] / 100;
339 var_Set( p_vout, "contrast", val );
340 config_PutFloat( p_intf , "contrast" , [o_sld_contrast floatValue] / 100);
341 } else if (sender == o_sld_gamma)
343 val.f_float = [o_sld_gamma floatValue] / 10;
344 var_Set( p_vout, "gamma", val );
345 config_PutFloat( p_intf , "gamma" , [o_sld_gamma floatValue] / 10);
346 } else if (sender == o_sld_hue)
348 val.i_int = [o_sld_hue intValue];
349 var_Set( p_vout, "hue", val );
350 config_PutInt( p_intf , "hue" , [o_sld_hue intValue]);
351 } else if (sender == o_sld_saturation)
353 val.f_float = [o_sld_saturation floatValue] / 100;
354 var_Set( p_vout, "saturation", val );
355 config_PutFloat( p_intf , "saturation" , [o_sld_saturation floatValue] / 100);
357 msg_Warn( p_intf, "the corresponding subfilter coundn't be found" );
359 vlc_object_release( p_vout );
362 o_config_changed = YES;
365 /* change the opaqueness of the vouts */
366 - (IBAction)adjImg_opaque:(id)sender
369 id o_window = [NSApp keyWindow];
370 NSArray *o_windows = [NSApp orderedWindows];
371 NSEnumerator *o_enumerator = [o_windows objectEnumerator];
372 playlist_t * p_playlist = pl_Yield( VLCIntf );
373 vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
374 vout_thread_t *p_real_vout;
376 val.f_float = [o_sld_opaque floatValue] / 100;
381 p_real_vout = [VLCVoutView getRealVout: p_vout];
382 var_Set( p_real_vout, "macosx-opaqueness", val );
384 while ((o_window = [o_enumerator nextObject]))
386 if( [[o_window className] isEqualToString: @"VLCWindow"] ||
387 [[[VLCMain sharedInstance] getEmbeddedList]
388 windowContainsEmbedded: o_window])
390 [o_window setAlphaValue: val.f_float];
394 vlc_object_release( p_vout );
398 config_PutFloat( p_playlist , "macosx-opaqueness" , val.f_float );
400 vlc_object_release( p_playlist );
402 o_config_changed = YES;
405 - (IBAction)audFtls_hdphnVirt:(id)sender
407 /* en-/disable headphone virtualisation */
408 if ([o_ckb_hdphnVirt state] == NSOnState)
410 [self changeAFiltersString: "headphone_channel_mixer" onOrOff: VLC_TRUE ];
412 [self changeAFiltersString: "headphone_channel_mixer" onOrOff: VLC_FALSE ];
416 - (IBAction)audFtls_maxLevelSld:(id)sender
418 /* read-out the slider's value and apply it */
419 intf_thread_t * p_intf = VLCIntf;
420 aout_instance_t * p_aout= (aout_instance_t *)vlc_object_find(p_intf,
421 VLC_OBJECT_AOUT, FIND_ANYWHERE);
424 var_SetFloat( p_aout, "norm-max-level", [o_sld_maxLevel floatValue] );
425 vlc_object_release( p_aout );
427 config_PutFloat( p_intf, "norm-max-level", [o_sld_maxLevel floatValue] );
429 o_config_changed = YES;
432 - (IBAction)audFtls_vlmeNorm:(id)sender
434 /* en-/disable volume normalisation */
435 if ([o_ckb_vlme_norm state] == NSOnState)
437 [self changeAFiltersString: "normvol" onOrOff: YES ];
439 [self changeAFiltersString: "normvol" onOrOff: NO ];
443 - (IBAction)extWin_exp_adjImg:(id)sender
445 /* expand or collapse adjImg */
446 NSRect o_win_rect = [o_extended_window frame];
447 NSRect o_box_audFlts_rect = [o_box_audFlts frame];
448 NSRect o_box_vidFlts_rect = [o_box_vidFlts frame];
449 NSRect o_box_adjImg_rect = [o_box_adjImg frame];
451 if (o_adjImg_expanded)
453 /* move the window contents upwards (partially done through settings
454 * inside the nib) and resize the window */
455 o_win_rect.size.height = o_win_rect.size.height - 193;
456 o_win_rect.origin.y = [o_extended_window frame].origin.y + 193;
457 o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y + 193;
458 o_box_vidFlts_rect.origin.y = o_box_vidFlts_rect.origin.y + 193;
460 /* remove the inserted view */
461 [o_adjustImg_view removeFromSuperviewWithoutNeedingDisplay];
464 /* move the window contents downwards and resize the window */
465 o_win_rect.size.height = o_win_rect.size.height + 193;
466 o_win_rect.origin.y = [o_extended_window frame].origin.y - 193;
467 o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y - 193;
468 o_box_vidFlts_rect.origin.y = o_box_vidFlts_rect.origin.y - 193;
471 [o_box_audFlts setFrameFromContentFrame: o_box_audFlts_rect];
472 [o_box_vidFlts setFrameFromContentFrame: o_box_vidFlts_rect];
473 [o_extended_window displayIfNeeded];
474 [o_extended_window setFrame: o_win_rect display:YES animate: YES];
476 if (o_adjImg_expanded)
478 o_box_adjImg_rect.size.height = [o_box_adjImg frame].size.height - 193;
479 o_adjImg_expanded = NO;
482 o_box_adjImg_rect.size.height = [o_box_adjImg frame].size.height + 193;
483 [o_adjustImg_view setFrame: NSMakeRect( 20, -10, 370, 203)];
484 [o_adjustImg_view setNeedsDisplay:YES];
485 [o_adjustImg_view setAutoresizesSubviews: YES];
486 [[o_box_adjImg contentView] addSubview: o_adjustImg_view];
487 o_adjImg_expanded = YES;
489 [o_box_adjImg setFrameFromContentFrame: o_box_adjImg_rect];
492 - (IBAction)extWin_exp_audFlts:(id)sender
494 /* expand or collapse audFlts */
495 NSRect o_win_rect = [o_extended_window frame];
496 NSRect o_box_audFlts_rect = [o_box_audFlts frame];
498 if (o_audFlts_expanded)
500 /* move the window contents upwards (partially done through settings
501 * inside the nib) and resize the window */
502 o_win_rect.size.height = o_win_rect.size.height - 66;
503 o_win_rect.origin.y = [o_extended_window frame].origin.y + 66;
505 /* remove the inserted view */
506 [o_audioFlts_view removeFromSuperviewWithoutNeedingDisplay];
508 /* move the window contents downwards and resize the window */
509 o_win_rect.size.height = o_win_rect.size.height + 66;
510 o_win_rect.origin.y = [o_extended_window frame].origin.y - 66;
512 [o_extended_window displayIfNeeded];
513 [o_extended_window setFrame: o_win_rect display:YES animate: YES];
516 if (o_audFlts_expanded)
518 o_box_audFlts_rect.size.height = [o_box_audFlts frame].size.height - 66;
519 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)extWin_exp_vidFlts:(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 - 188;
544 o_win_rect.origin.y = [o_extended_window frame].origin.y + 188;
545 o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y + 188;
547 /* remove the inserted view */
548 [o_videoFilters_view removeFromSuperviewWithoutNeedingDisplay];
551 /* move the window contents downwards and resize the window */
552 o_win_rect.size.height = o_win_rect.size.height + 188;
553 o_win_rect.origin.y = [o_extended_window frame].origin.y - 188;
554 o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y - 188;
557 [o_box_audFlts setFrameFromContentFrame: o_box_audFlts_rect];
558 [o_extended_window displayIfNeeded];
559 [o_extended_window setFrame: o_win_rect display:YES animate: YES];
561 if (o_vidFlts_expanded)
563 o_box_vidFlts_rect.size.height = [o_box_vidFlts frame].size.height - 188;
564 o_vidFlts_expanded = NO;
567 o_box_vidFlts_rect.size.height = [o_box_vidFlts frame].size.height + 188;
568 [o_videoFilters_view setFrame: NSMakeRect( 20, -10, 370, 188)];
569 [o_videoFilters_view setNeedsDisplay:YES];
570 [o_videoFilters_view setAutoresizesSubviews: YES];
571 [[o_box_vidFlts contentView] addSubview: o_videoFilters_view];
572 o_vidFlts_expanded = YES;
574 [o_box_vidFlts setFrameFromContentFrame: o_box_vidFlts_rect];
577 - (IBAction)vidFlts:(id)sender
579 /* en-/disable video filters */
580 if (sender == o_ckb_blur)
581 [self changeVoutFiltersString: "motionblur" onOrOff: [o_ckb_blur state]];
583 else if (sender == o_ckb_imgClone)
584 [self changeVoutFiltersString: "clone" onOrOff: [o_ckb_imgClone state]];
586 else if (sender == o_ckb_imgCrop)
587 [self changeVoutFiltersString: "crop" onOrOff: [o_ckb_imgCrop state]];
589 else if (sender == o_ckb_imgInvers)
590 [self changeVideoFiltersString: "invert" onOrOff: [o_ckb_imgInvers state]];
592 else if (sender == o_ckb_trnsform)
593 [self changeVoutFiltersString: "transform" onOrOff: [o_ckb_trnsform state]];
595 else if (sender == o_ckb_intZoom )
596 [self changeVoutFiltersString: "magnify" onOrOff: [o_ckb_intZoom state]];
598 else if (sender == o_ckb_wave )
599 [self changeVideoFiltersString: "wave" onOrOff: [o_ckb_wave state]];
601 else if (sender == o_ckb_gradient )
602 [self changeVideoFiltersString: "gradient" onOrOff: [o_ckb_gradient state]];
604 else if (sender == o_ckb_psycho )
605 [self changeVideoFiltersString: "psychedelic" onOrOff: [o_ckb_psycho state]];
607 else if (sender == o_ckb_ripple )
608 [self changeVideoFiltersString: "ripple" onOrOff: [o_ckb_ripple state]];
611 /* this shouldn't happen */
612 msg_Warn (VLCIntf, "cannot find switched video-filter");
616 - (IBAction)vidFlts_mrInfo:(id)sender
618 /* show info sheet */
619 NSBeginInformationalAlertSheet(_NS("More Information"), _NS("OK"), @"", @"",
620 o_extended_window, nil, nil, nil, nil, _NS("This panel allows to "
621 "select video effects filters to apply.\n"
622 "The filters can be configured individually in the Preferences, in "
623 "the subsections of Video/Filters.\n"
624 "To choose the order in which the filter are applied, a filter "
625 "option string can be set in the Preferences, Video / Filters section."));
629 /*****************************************************************************
630 * methods to communicate changes to VLC's core
631 *****************************************************************************/
633 - (void)changeVoutFiltersString:(char *)psz_name onOrOff:(vlc_bool_t )b_add
635 /* copied from ../wxwidgets/extrapanel.cpp
636 * renamed to conform with Cocoa's rules */
637 /* this method only changes 1st generation video filters (the ones which
638 * can't be used for transcoding). Have a look at changeVideoFiltersString
639 * for the 2nd generation filters. */
641 vout_thread_t *p_vout;
642 intf_thread_t * p_intf = VLCIntf;
644 char *psz_parser, *psz_string;
645 psz_string = config_GetPsz( p_intf, "vout-filter" );
647 if( !psz_string ) psz_string = strdup("");
649 psz_parser = strstr( psz_string, psz_name );
655 psz_parser = psz_string;
656 asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
657 psz_string, psz_name );
669 memmove( psz_parser, psz_parser + strlen(psz_name) +
670 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
671 strlen(psz_parser + strlen(psz_name)) + 1 );
673 /* Remove trailing : : */
674 if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
676 *(psz_string+strlen(psz_string ) -1 ) = '\0';
685 /* Vout is not kept, so put that in the config */
686 config_PutPsz( p_intf, "vout-filter", psz_string );
688 /* Try to set on the fly */
689 p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
693 var_SetString( p_vout, "vout-filter", psz_string );
694 vlc_object_release( p_vout );
699 o_config_changed = YES;
703 - (void)changeVideoFiltersString:(char *)psz_name onOrOff:(vlc_bool_t )b_add
705 /* same as changeVoutFiltersString but addressing the "video-filter"
706 * variable which represents the video filter 2 modules */
708 vout_thread_t *p_vout;
709 intf_thread_t * p_intf = VLCIntf;
711 char *psz_parser, *psz_string;
712 psz_string = config_GetPsz( p_intf, "video-filter" );
714 if( !psz_string ) psz_string = strdup("");
716 psz_parser = strstr( psz_string, psz_name );
722 psz_parser = psz_string;
723 asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
724 psz_string, psz_name );
736 memmove( psz_parser, psz_parser + strlen(psz_name) +
737 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
738 strlen(psz_parser + strlen(psz_name)) + 1 );
740 /* Remove trailing : : */
741 if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
743 *(psz_string+strlen(psz_string ) -1 ) = '\0';
752 /* Vout is not kept, so put that in the config */
753 config_PutPsz( p_intf, "video-filter", psz_string );
755 /* Try to set on the fly */
756 p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
760 var_SetString( p_vout, "video-filter", psz_string );
761 vlc_object_release( p_vout );
766 o_config_changed = YES;
769 - (void)changeAFiltersString: (char *)psz_name onOrOff: (vlc_bool_t )b_add;
771 /* copied from ../wxwidgets/extrapanel.cpp
772 * renamed to conform with Cocoa's rules */
774 char *psz_parser, *psz_string;
775 intf_thread_t * p_intf = VLCIntf;
776 aout_instance_t * p_aout= (aout_instance_t *)vlc_object_find(p_intf,
777 VLC_OBJECT_AOUT, FIND_ANYWHERE);
781 psz_string = var_GetString( p_aout, "audio-filter" );
785 psz_string = config_GetPsz( p_intf, "audio-filter" );
788 if( !psz_string ) psz_string = strdup("");
790 psz_parser = strstr( psz_string, psz_name );
796 psz_parser = psz_string;
797 asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
798 psz_string, psz_name );
810 memmove( psz_parser, psz_parser + strlen(psz_name) +
811 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
812 strlen(psz_parser + strlen(psz_name)) + 1 );
814 if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
816 *(psz_string+strlen(psz_string ) -1 ) = '\0';
828 config_PutPsz( p_intf, "audio-filter", psz_string );
832 var_SetString( p_aout, "audio-filter", psz_string );
834 while( i < p_aout->i_nb_inputs )
836 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
839 vlc_object_release( p_aout );
843 o_config_changed = YES;
848 /* save the preferences to make sure that our module-changes will up on
849 * next launch again */
850 playlist_t * p_playlist = pl_Yield( VLCIntf );
852 NSArray * theModules;
853 theModules = [[NSArray alloc] initWithObjects: @"main", @"headphone",
854 @"transform", @"adjust", @"invert", @"motionblur", @"distort",
855 @"clone", @"crop", @"normvol", @"headphone_channel_mixer", @"macosx",
859 while ( x != [theModules count] )
861 returnedValue = config_SaveConfigFile( p_playlist, [[theModules
862 objectAtIndex: x] UTF8String] );
864 if (returnedValue != 0)
866 msg_Err(p_playlist, "unable to save the preferences of the "
867 "extended control attribute '%s' (%i)",
868 [[theModules objectAtIndex: x] UTF8String] , returnedValue);
869 [theModules release];
870 vlc_object_release( p_playlist );
878 msg_Dbg( p_playlist, "VLCExtended: saved certain preferences successfully" );
880 [theModules release];
881 vlc_object_release( p_playlist );