Skip to content

Commit

Permalink
Add min_blocksize and max_blocksize to stats
Browse files Browse the repository at this point in the history
  • Loading branch information
mgeier committed Aug 30, 2019
1 parent 66c6a20 commit a1cc70b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
3 changes: 2 additions & 1 deletion examples/fetch_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
27 changes: 21 additions & 6 deletions src/rtmixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++; }
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions src/rtmixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a1cc70b

Please sign in to comment.