- case STATS_LAST:
- case STATS_MIN:
- case STATS_MAX:
- if( p_counter->i_samples > 1)
- {
- msg_Err( p_handler, "LAST counter has several samples !" );
- return VLC_EGENERIC;
- }
- if( p_counter->i_type != VLC_VAR_FLOAT &&
- p_counter->i_type != VLC_VAR_INTEGER &&
- p_counter->i_compute_type != STATS_LAST )
- {
- msg_Err( p_handler, "Unable to compute MIN or MAX for this type");
- return VLC_EGENERIC;
- }
-
- if( p_counter->i_samples == 0 )
- {
- counter_sample_t *p_new = (counter_sample_t*)malloc(
- sizeof( counter_sample_t ) );
- p_new->value.psz_string = NULL;
-
- INSERT_ELEM( p_counter->pp_samples, p_counter->i_samples,
- p_counter->i_samples, p_new );
- }
- if( p_counter->i_samples == 1 )
- {
- /* Update if : LAST or (MAX and bigger) or (MIN and bigger) */
- if( p_counter->i_compute_type == STATS_LAST ||
- ( p_counter->i_compute_type == STATS_MAX &&
- ( ( p_counter->i_type == VLC_VAR_INTEGER &&
- p_counter->pp_samples[0]->value.i_int > val.i_int ) ||
- ( p_counter->i_type == VLC_VAR_FLOAT &&
- p_counter->pp_samples[0]->value.f_float > val.f_float )
- ) ) ||
- ( p_counter->i_compute_type == STATS_MIN &&
- ( ( p_counter->i_type == VLC_VAR_INTEGER &&
- p_counter->pp_samples[0]->value.i_int < val.i_int ) ||
- ( p_counter->i_type == VLC_VAR_FLOAT &&
- p_counter->pp_samples[0]->value.f_float < val.f_float )
- ) ) )
- {
- if( p_counter->i_type == VLC_VAR_STRING &&
- p_counter->pp_samples[0]->value.psz_string )
- {
- free( p_counter->pp_samples[0]->value.psz_string );
- }
- p_counter->pp_samples[0]->value = val;
- }
- }
- break;