Skip to content

Commit a1cc70b

Browse files
committed
Add min_blocksize and max_blocksize to stats
1 parent 66c6a20 commit a1cc70b

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

examples/fetch_stats.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515

1616
def print_stats(obj):
17-
print(' blocks:', obj.stats.blocks)
17+
print('blocks (min/max): {} ({}/{})'.format(
18+
obj.stats.blocks, obj.stats.min_blocksize, obj.stats.max_blocksize))
1819
print(' overflows:', obj.stats.input_overflows)
1920

2021

src/rtmixer.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,27 @@ void remove_action(struct action** addr, const struct state* state)
3333
}
3434
}
3535

36-
void get_stats(PaStreamCallbackFlags flags, struct stats* stats)
36+
void get_stats(frame_t frameCount, PaStreamCallbackFlags flags
37+
, struct stats* stats)
3738
{
39+
if (stats->blocks == 0)
40+
{
41+
stats->min_blocksize = frameCount;
42+
stats->max_blocksize = frameCount;
43+
}
44+
else
45+
{
46+
if (frameCount < stats->min_blocksize)
47+
{
48+
stats->min_blocksize = frameCount;
49+
}
50+
if (frameCount > stats->max_blocksize)
51+
{
52+
stats->max_blocksize = frameCount;
53+
}
54+
}
3855
stats->blocks++;
3956

40-
// TODO: store min/max block size?
41-
4257
if (flags & paInputUnderflow) { stats->input_underflows++; }
4358
if (flags & paInputOverflow) { stats->input_overflows++; }
4459
if (flags & paOutputUnderflow) { stats->output_underflows++; }
@@ -114,7 +129,7 @@ int callback(const void* input, void* output, frame_t frameCount
114129

115130
memset(output, 0, sizeof(float) * state->output_channels * frameCount);
116131

117-
get_stats(statusFlags, &(state->stats));
132+
get_stats(frameCount, statusFlags, &(state->stats));
118133

119134
get_new_actions(state);
120135

@@ -249,9 +264,9 @@ int callback(const void* input, void* output, frame_t frameCount
249264
continue;
250265
}
251266

252-
// Store buffer over-/underflow information
267+
// Store buffer over-/underflow information etc.
253268

254-
get_stats(statusFlags, &(action->stats));
269+
get_stats(frameCount, statusFlags, &(action->stats));
255270

256271
// Get number of remaining frames in the current block
257272

src/rtmixer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ enum actiontype
2323
struct stats
2424
{
2525
frame_t blocks;
26+
frame_t min_blocksize;
27+
frame_t max_blocksize;
2628
frame_t input_underflows;
2729
frame_t input_overflows;
2830
frame_t output_underflows;

0 commit comments

Comments
 (0)