X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fmacosx%2Fequalizer.m;h=1809b1f7ee0d29e3d0ad40b6e895927ccf97cbae;hb=f93eb575366f57526e7e010b99b3d23ab7262708;hp=b198f7d637cd26bfe53d1cae48e48974cd540aa7;hpb=ba6501f3084682844e7ee87bad3986bced5f3652;p=vlc diff --git a/modules/gui/macosx/equalizer.m b/modules/gui/macosx/equalizer.m index b198f7d637..1809b1f7ee 100644 --- a/modules/gui/macosx/equalizer.m +++ b/modules/gui/macosx/equalizer.m @@ -49,12 +49,11 @@ static void ChangeFiltersString( intf_thread_t *p_intf, { char *psz_parser, *psz_string; int i; - vlc_object_t *p_object = vlc_object_find( p_intf, - VLC_OBJECT_AOUT, FIND_ANYWHERE ); - aout_instance_t *p_aout = (aout_instance_t *)p_object; + aout_instance_t *p_aout = getAout(); + vlc_object_t *p_object = VLC_OBJECT(p_aout); if( !p_object ) { - p_object = (vlc_object_t *)pl_Hold( p_intf ); + p_object = vlc_object_hold(pl_Get( p_intf )); } psz_string = var_GetNonEmptyString( p_object, "audio-filter" ); @@ -99,21 +98,14 @@ static void ChangeFiltersString( intf_thread_t *p_intf, } } - var_SetString( p_object, "audio-filter", psz_string ); - if( p_aout ) - { - for( i = 0; i < p_aout->i_nb_inputs; i++ ) - { - p_aout->pp_inputs[i]->b_restart = true; - } - } - + aout_EnableFilter( pl_Get( p_intf ), psz_string, b_add); + if( (BOOL)config_GetInt( p_object, "macosx-eq-keep" ) == YES ) { /* save changed to config */ config_PutPsz( p_object, "audio-filter", psz_string ); } - + free( psz_string ); vlc_object_release( p_object ); } @@ -121,11 +113,10 @@ static void ChangeFiltersString( intf_thread_t *p_intf, static bool GetFiltersStatus( intf_thread_t *p_intf, char *psz_name ) { - char *psz_parser, *psz_string; - vlc_object_t *p_object = vlc_object_find( p_intf, - VLC_OBJECT_AOUT, FIND_ANYWHERE ); + char *psz_parser, *psz_string = NULL; + vlc_object_t *p_object = VLC_OBJECT(getAout()); if( p_object == NULL ) - p_object = (vlc_object_t *)pl_Hold( p_intf ); + p_object = vlc_object_hold(pl_Get( p_intf )); if( (BOOL)config_GetInt( p_intf, "macosx-eq-keep" ) == YES ) psz_string = config_GetPsz( p_intf, "audio-filter" ); @@ -151,6 +142,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf, { int i; [o_btn_equalizer setToolTip: _NS("Equalizer")]; + [o_btn_equalizer_embedded setToolTip: _NS("Equalizer")]; [o_ckb_2pass setTitle: _NS("2 Pass")]; [o_ckb_2pass setToolTip: _NS("Apply the " "equalizer filter twice. The effect will be sharper.")]; @@ -177,11 +169,10 @@ static bool GetFiltersStatus( intf_thread_t *p_intf, bool b_2p; int i; bool b_enabled = GetFiltersStatus( p_intf, (char *)"equalizer" ); - vlc_object_t *p_object = vlc_object_find( p_intf, - VLC_OBJECT_AOUT, FIND_ANYWHERE ); + vlc_object_t *p_object = VLC_OBJECT(getAout()); if( p_object == NULL ) - p_object = (vlc_object_t *)pl_Hold( p_intf ); + p_object = vlc_object_hold(pl_Get( p_intf )); var_Create( p_object, "equalizer-preamp", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT ); @@ -205,7 +196,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf, } vlc_object_release( p_object ); - + /* Set the preamp slider */ [o_slider_preamp setFloatValue: f_preamp]; @@ -215,13 +206,9 @@ static bool GetFiltersStatus( intf_thread_t *p_intf, for( i = 0; i < 10; i++ ) { /* Read dB -20/20 */ -#ifdef HAVE_STRTOF f_band[i] = strtof( psz_bands, &p_next ); -#else - f_band[i] = (float)strtod( psz_bands, &p_next ); -#endif if( !p_next || p_next == psz_bands ) break; /* strtof() failed */ - + if( !*psz_bands ) break; /* end of line */ psz_bands = p_next+1; } @@ -231,35 +218,30 @@ static bool GetFiltersStatus( intf_thread_t *p_intf, /* Set the the checkboxes */ [o_ckb_enable setState: b_enabled]; - [o_ckb_2pass setState: b_2p]; + [o_ckb_2pass setState: b_2p]; } - (IBAction)bandSliderUpdated:(id)sender { intf_thread_t *p_intf = VLCIntf; - vlc_object_t *p_object = vlc_object_find( p_intf, - VLC_OBJECT_AOUT, FIND_ANYWHERE ); + vlc_object_t *p_object = VLC_OBJECT(getAout()); if( p_object == NULL ) - p_object = (vlc_object_t *)pl_Hold( p_intf ); - - char psz_values[102]; - memset( psz_values, 0, 102 ); - - /* Write the new bands values */ - /* TODO: write a generic code instead of ten times the same thing */ - - sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band1 floatValue] ); - sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band2 floatValue] ); - sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band3 floatValue] ); - sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band4 floatValue] ); - sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band5 floatValue] ); - sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band6 floatValue] ); - sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band7 floatValue] ); - sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band8 floatValue] ); - sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band9 floatValue] ); - sprintf( psz_values, "%s %.1f", psz_values, [o_slider_band10 floatValue] ); - + p_object = vlc_object_hold(pl_Get( p_intf )); + + const char *psz_values; + NSString *preset = [NSString stringWithFormat:@"%.1f", [o_slider_band1 floatValue] ]; + preset = [preset stringByAppendingFormat:@"%.1f ", [o_slider_band2 floatValue] ]; + preset = [preset stringByAppendingFormat:@"%.1f ", [o_slider_band3 floatValue] ]; + preset = [preset stringByAppendingFormat:@"%.1f ", [o_slider_band4 floatValue] ]; + preset = [preset stringByAppendingFormat:@"%.1f ", [o_slider_band5 floatValue] ]; + preset = [preset stringByAppendingFormat:@"%.1f ", [o_slider_band6 floatValue] ]; + preset = [preset stringByAppendingFormat:@"%.1f ", [o_slider_band7 floatValue] ]; + preset = [preset stringByAppendingFormat:@"%.1f ", [o_slider_band8 floatValue] ]; + preset = [preset stringByAppendingFormat:@"%.1f ", [o_slider_band9 floatValue] ]; + preset = [preset stringByAppendingFormat:@"%.1f", [o_slider_band10 floatValue] ]; + + psz_values = [preset UTF8String]; var_SetString( p_object, "equalizer-bands", psz_values ); if( (BOOL)config_GetInt( p_intf, "macosx-eq-keep" ) == YES ) @@ -278,18 +260,19 @@ static bool GetFiltersStatus( intf_thread_t *p_intf, { intf_thread_t *p_intf = VLCIntf; int i; - vlc_object_t *p_object= vlc_object_find( p_intf, - VLC_OBJECT_AOUT, FIND_ANYWHERE ); + vlc_object_t *p_object= VLC_OBJECT(getAout()); if( p_object == NULL ) - p_object = (vlc_object_t *)pl_Hold( p_intf ); - - char psz_values[102]; - memset( psz_values, 0, 102 ); + p_object = vlc_object_hold(pl_Get( p_intf )); var_SetString( p_object , "equalizer-preset" , preset_list[[sender indexOfSelectedItem]] ); + NSString *preset = @""; + const char *psz_values; for( i = 0; i < 10; i++ ) - sprintf( psz_values, "%s %.1f", psz_values, eqz_preset_10b[[sender indexOfSelectedItem]]->f_amp[i] ); + { + preset = [preset stringByAppendingFormat:@"%.1f ", eqz_preset_10b[[sender indexOfSelectedItem]]->f_amp[i] ]; + } + psz_values = [preset UTF8String]; var_SetString( p_object, "equalizer-bands", psz_values ); var_SetFloat( p_object, "equalizer-preamp", eqz_preset_10b[[sender indexOfSelectedItem]]->f_preamp); @@ -313,7 +296,9 @@ static bool GetFiltersStatus( intf_thread_t *p_intf, - (IBAction)enable:(id)sender { - ChangeFiltersString( VLCIntf, (char *)"equalizer", [sender state] ); +// ChangeFiltersString( VLCIntf, (char *)"equalizer", [sender state] ); + // to fix #3718 + aout_EnableFilter( pl_Get( VLCIntf ), (char *)"equalizer", [sender state]); } - (IBAction)preampSliderUpdated:(id)sender @@ -321,10 +306,9 @@ static bool GetFiltersStatus( intf_thread_t *p_intf, intf_thread_t *p_intf = VLCIntf; float f_preamp = [sender floatValue] ; - vlc_object_t *p_object = vlc_object_find( p_intf, - VLC_OBJECT_AOUT, FIND_ANYWHERE ); + vlc_object_t *p_object = VLC_OBJECT(getAout()); if( p_object == NULL ) - p_object = (vlc_object_t *)pl_Hold( p_intf ); + p_object = vlc_object_hold(pl_Get( p_intf )); var_SetFloat( p_object, "equalizer-preamp", f_preamp ); @@ -346,11 +330,13 @@ static bool GetFiltersStatus( intf_thread_t *p_intf, { [o_window orderOut:sender]; [o_btn_equalizer setState:NSOffState]; + [o_btn_equalizer_embedded setState:NSOffState]; } else { [o_window makeKeyAndOrderFront:sender]; [o_btn_equalizer setState:NSOnState]; + [o_btn_equalizer_embedded setState:NSOnState]; } } @@ -358,21 +344,12 @@ static bool GetFiltersStatus( intf_thread_t *p_intf, { intf_thread_t *p_intf = VLCIntf; bool b_2p = [sender state] ? true : false; - vlc_object_t *p_object= vlc_object_find( p_intf, - VLC_OBJECT_AOUT, FIND_ANYWHERE ); - aout_instance_t *p_aout = (aout_instance_t *)p_object; + aout_instance_t *p_aout = getAout(); + vlc_object_t *p_object= VLC_OBJECT(p_aout); if( p_object == NULL ) - p_object = (vlc_object_t *)pl_Hold( p_intf ); + p_object = vlc_object_hold(pl_Get( p_intf )); var_SetBool( p_object, "equalizer-2pass", b_2p ); - if( ( [o_ckb_enable state] ) && ( p_aout != NULL ) ) - { - int i; - for( i = 0; i < p_aout->i_nb_inputs; i++ ) - { - p_aout->pp_inputs[i]->b_restart = true; - } - } if( (BOOL)config_GetInt( p_intf, "macosx-eq-keep" ) == YES ) { @@ -394,10 +371,9 @@ static bool GetFiltersStatus( intf_thread_t *p_intf, - (void)awakeFromNib { int i; - vlc_object_t *p_object= vlc_object_find( VLCIntf, - VLC_OBJECT_AOUT, FIND_ANYWHERE ); + vlc_object_t *p_object= VLC_OBJECT(getAout()); if( p_object == NULL ) - p_object = (vlc_object_t *)pl_Hold( VLCIntf ); + p_object = vlc_object_hold(pl_Get( VLCIntf )); [o_window setExcludedFromWindowsMenu: TRUE]; @@ -415,9 +391,9 @@ static bool GetFiltersStatus( intf_thread_t *p_intf, { if( strcmp( preset_list[i], psz_preset ) ) continue; - + [o_popup_presets selectItemAtIndex: i]; - + [o_slider_preamp setFloatValue: eqz_preset_10b[i]->f_preamp]; [self setBandSlidersValues: (float *)eqz_preset_10b[i]->f_amp]; @@ -425,7 +401,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf, if( strcmp( psz_preset, "flat" ) ) { char psz_bands[100]; - + snprintf( psz_bands, sizeof( psz_bands ), "%.1f %.1f %.1f %.1f %.1f %.1f %.1f " "%.1f %.1f %.1f", @@ -439,7 +415,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf, eqz_preset_10b[i]->f_amp[7], eqz_preset_10b[i]->f_amp[8], eqz_preset_10b[i]->f_amp[9] ); - + var_Create( p_object, "equalizer-preamp", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT ); var_Create( p_object, "equalizer-bands", VLC_VAR_STRING | @@ -453,11 +429,11 @@ static bool GetFiltersStatus( intf_thread_t *p_intf, vlc_object_release( p_object ); } - [self equalizerUpdated]; + [self equalizerUpdated]; } -- (id)getSliderByIndex:(int)index +- (id)sliderByIndex:(int)index { switch(index) { @@ -495,7 +471,7 @@ static bool GetFiltersStatus( intf_thread_t *p_intf, - (void)setValue:(float)value forSlider:(int)index { - id slider = [self getSliderByIndex:index]; + id slider = [self sliderByIndex:index]; if (slider != nil) {