@@ -1104,8 +1104,46 @@ bool load_config(char configPath[PATH_MAX], struct config_params *p, bool colors
11041104 p -> sync_updates = GetPrivateProfileInt ("output" , "synchronized_sync" , 0 , configPath );
11051105 p -> show_idle_bar_heads = GetPrivateProfileInt ("output" , "show_idle_bar_heads" , 1 , configPath );
11061106 p -> waveform = GetPrivateProfileInt ("output" , "waveform" , 0 , configPath );
1107+
1108+ // read eq values
1109+ p -> userEQ_keys = 0 ;
1110+ p -> userEQ = (double * )malloc (sizeof (double ));
1111+ if (p -> userEQ == NULL ) {
1112+ write_errorf (error , "Memory allocation failed\n" );
1113+ return false;
1114+ }
1115+ while (1 ) {
1116+ char eqResult [10 ];
1117+ char keyNum [3 ];
1118+
1119+ // pass key counter as string to GetPrivateProfileString
1120+ sprintf (keyNum , "%d" , p -> userEQ_keys + 1 );
1121+ GetPrivateProfileString ("eq" , keyNum , "NOT FOUND" , eqResult , sizeof (eqResult ), configPath );
1122+ if (!strcmp (eqResult , "NOT FOUND" )) {
1123+ break ;
1124+ } else {
1125+ double * oldPtr = p -> userEQ ;
1126+ p -> userEQ = (double * )realloc (p -> userEQ , sizeof (double ) * (p -> userEQ_keys + 1 ));
1127+ if (p -> userEQ == NULL ) {
1128+ write_errorf (error , "Memory reallocation failed\n" );
1129+ free (oldPtr );
1130+ return false;
1131+ }
11071132
1108- p -> userEQ_enabled = 0 ;
1133+ int * endptr ;
1134+ p -> userEQ [p -> userEQ_keys ] = strtod (eqResult , & endptr );
1135+ if (endptr == eqResult ) {
1136+ write_errorf (error , "Invalid string to double conversion, %d : \"%s\" \n" ,
1137+ p -> userEQ_keys + 1 , eqResult );
1138+ free (p -> userEQ );
1139+ return false;
1140+ }
1141+ p -> userEQ_keys ++ ;
1142+ }
1143+ }
1144+ if (p -> userEQ_keys > 0 ) {
1145+ p -> userEQ_enabled = 1 ;
1146+ }
11091147
11101148 p -> input = GetPrivateProfileInt ("input" , "method" , INPUT_WINSCAP , configPath );
11111149 if (p -> input != INPUT_WINSCAP ) {
0 commit comments