diff --git a/examples/fetch_stats.py b/examples/fetch_stats.py index 3585918..775b8a3 100755 --- a/examples/fetch_stats.py +++ b/examples/fetch_stats.py @@ -14,7 +14,8 @@ def print_stats(obj): - print(' blocks:', obj.stats.blocks) + print('blocks (min/max): {} ({}/{})'.format( + obj.stats.blocks, obj.stats.min_blocksize, obj.stats.max_blocksize)) print(' overflows:', obj.stats.input_overflows) diff --git a/src/rtmixer.c b/src/rtmixer.c index 81d7209..491bb9d 100644 --- a/src/rtmixer.c +++ b/src/rtmixer.c @@ -33,12 +33,27 @@ void remove_action(struct action** addr, const struct state* state) } } -void get_stats(PaStreamCallbackFlags flags, struct stats* stats) +void get_stats(frame_t frameCount, PaStreamCallbackFlags flags + , struct stats* stats) { + if (stats->blocks == 0) + { + stats->min_blocksize = frameCount; + stats->max_blocksize = frameCount; + } + else + { + if (frameCount < stats->min_blocksize) + { + stats->min_blocksize = frameCount; + } + if (frameCount > stats->max_blocksize) + { + stats->max_blocksize = frameCount; + } + } stats->blocks++; - // TODO: store min/max block size? - if (flags & paInputUnderflow) { stats->input_underflows++; } if (flags & paInputOverflow) { stats->input_overflows++; } if (flags & paOutputUnderflow) { stats->output_underflows++; } @@ -114,7 +129,7 @@ int callback(const void* input, void* output, frame_t frameCount memset(output, 0, sizeof(float) * state->output_channels * frameCount); - get_stats(statusFlags, &(state->stats)); + get_stats(frameCount, statusFlags, &(state->stats)); get_new_actions(state); @@ -249,9 +264,9 @@ int callback(const void* input, void* output, frame_t frameCount continue; } - // Store buffer over-/underflow information + // Store buffer over-/underflow information etc. - get_stats(statusFlags, &(action->stats)); + get_stats(frameCount, statusFlags, &(action->stats)); // Get number of remaining frames in the current block diff --git a/src/rtmixer.h b/src/rtmixer.h index 239b3fc..39a8393 100644 --- a/src/rtmixer.h +++ b/src/rtmixer.h @@ -23,6 +23,8 @@ enum actiontype struct stats { frame_t blocks; + frame_t min_blocksize; + frame_t max_blocksize; frame_t input_underflows; frame_t input_overflows; frame_t output_underflows;