sw_limits: add support for maximum frame counts
This commit is contained in:
parent
e86cc12b66
commit
67785f2568
|
@ -1732,8 +1732,10 @@ SR_PRIV int sr_kern_parse(const uint8_t *buf, float *floatval,
|
||||||
|
|
||||||
struct sr_sw_limits {
|
struct sr_sw_limits {
|
||||||
uint64_t limit_samples;
|
uint64_t limit_samples;
|
||||||
|
uint64_t limit_frames;
|
||||||
uint64_t limit_msec;
|
uint64_t limit_msec;
|
||||||
uint64_t samples_read;
|
uint64_t samples_read;
|
||||||
|
uint64_t frames_read;
|
||||||
uint64_t start_time;
|
uint64_t start_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1745,6 +1747,8 @@ SR_PRIV void sr_sw_limits_acquisition_start(struct sr_sw_limits *limits);
|
||||||
SR_PRIV gboolean sr_sw_limits_check(struct sr_sw_limits *limits);
|
SR_PRIV gboolean sr_sw_limits_check(struct sr_sw_limits *limits);
|
||||||
SR_PRIV void sr_sw_limits_update_samples_read(struct sr_sw_limits *limits,
|
SR_PRIV void sr_sw_limits_update_samples_read(struct sr_sw_limits *limits,
|
||||||
uint64_t samples_read);
|
uint64_t samples_read);
|
||||||
|
SR_PRIV void sr_sw_limits_update_frames_read(struct sr_sw_limits *limits,
|
||||||
|
uint64_t frames_read);
|
||||||
SR_PRIV void sr_sw_limits_init(struct sr_sw_limits *limits);
|
SR_PRIV void sr_sw_limits_init(struct sr_sw_limits *limits);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
SR_PRIV void sr_sw_limits_init(struct sr_sw_limits *limits)
|
SR_PRIV void sr_sw_limits_init(struct sr_sw_limits *limits)
|
||||||
{
|
{
|
||||||
limits->limit_samples = 0;
|
limits->limit_samples = 0;
|
||||||
|
limits->limit_frames = 0;
|
||||||
limits->limit_msec = 0;
|
limits->limit_msec = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +67,9 @@ SR_PRIV int sr_sw_limits_config_get(struct sr_sw_limits *limits, uint32_t key,
|
||||||
case SR_CONF_LIMIT_SAMPLES:
|
case SR_CONF_LIMIT_SAMPLES:
|
||||||
*data = g_variant_new_uint64(limits->limit_samples);
|
*data = g_variant_new_uint64(limits->limit_samples);
|
||||||
break;
|
break;
|
||||||
|
case SR_CONF_LIMIT_FRAMES:
|
||||||
|
*data = g_variant_new_uint64(limits->limit_frames);
|
||||||
|
break;
|
||||||
case SR_CONF_LIMIT_MSEC:
|
case SR_CONF_LIMIT_MSEC:
|
||||||
*data = g_variant_new_uint64(limits->limit_msec / 1000);
|
*data = g_variant_new_uint64(limits->limit_msec / 1000);
|
||||||
break;
|
break;
|
||||||
|
@ -94,6 +98,9 @@ SR_PRIV int sr_sw_limits_config_set(struct sr_sw_limits *limits, uint32_t key,
|
||||||
case SR_CONF_LIMIT_SAMPLES:
|
case SR_CONF_LIMIT_SAMPLES:
|
||||||
limits->limit_samples = g_variant_get_uint64(data);
|
limits->limit_samples = g_variant_get_uint64(data);
|
||||||
break;
|
break;
|
||||||
|
case SR_CONF_LIMIT_FRAMES:
|
||||||
|
limits->limit_frames = g_variant_get_uint64(data);
|
||||||
|
break;
|
||||||
case SR_CONF_LIMIT_MSEC:
|
case SR_CONF_LIMIT_MSEC:
|
||||||
limits->limit_msec = g_variant_get_uint64(data) * 1000;
|
limits->limit_msec = g_variant_get_uint64(data) * 1000;
|
||||||
break;
|
break;
|
||||||
|
@ -115,6 +122,7 @@ SR_PRIV int sr_sw_limits_config_set(struct sr_sw_limits *limits, uint32_t key,
|
||||||
SR_PRIV void sr_sw_limits_acquisition_start(struct sr_sw_limits *limits)
|
SR_PRIV void sr_sw_limits_acquisition_start(struct sr_sw_limits *limits)
|
||||||
{
|
{
|
||||||
limits->samples_read = 0;
|
limits->samples_read = 0;
|
||||||
|
limits->frames_read = 0;
|
||||||
limits->start_time = g_get_monotonic_time();
|
limits->start_time = g_get_monotonic_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,6 +146,14 @@ SR_PRIV gboolean sr_sw_limits_check(struct sr_sw_limits *limits)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (limits->limit_frames) {
|
||||||
|
if (limits->frames_read >= limits->limit_frames) {
|
||||||
|
sr_dbg("Requested number of frames (%" PRIu64
|
||||||
|
") reached.", limits->limit_frames);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (limits->limit_msec) {
|
if (limits->limit_msec) {
|
||||||
guint64 now;
|
guint64 now;
|
||||||
now = g_get_monotonic_time();
|
now = g_get_monotonic_time();
|
||||||
|
@ -153,7 +169,7 @@ SR_PRIV gboolean sr_sw_limits_check(struct sr_sw_limits *limits)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the amount samples that have been read
|
* Update the amount of samples that have been read
|
||||||
*
|
*
|
||||||
* Update the amount of samples that have been read in the current data
|
* Update the amount of samples that have been read in the current data
|
||||||
* acquisition run. For each invocation @p samples_read will be accumulated and
|
* acquisition run. For each invocation @p samples_read will be accumulated and
|
||||||
|
@ -168,3 +184,20 @@ SR_PRIV void sr_sw_limits_update_samples_read(struct sr_sw_limits *limits,
|
||||||
{
|
{
|
||||||
limits->samples_read += samples_read;
|
limits->samples_read += samples_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the amount of frames that have been read
|
||||||
|
*
|
||||||
|
* Update the amount of frames that have been read in the current data
|
||||||
|
* acquisition run. For each invocation @p frames_read will be accumulated and
|
||||||
|
* once the configured frame limit has been reached sr_sw_limits_check() will
|
||||||
|
* return TRUE.
|
||||||
|
*
|
||||||
|
* @param limits software limits instance
|
||||||
|
* @param frames_read the amount of frames that have been read
|
||||||
|
*/
|
||||||
|
SR_PRIV void sr_sw_limits_update_frames_read(struct sr_sw_limits *limits,
|
||||||
|
uint64_t frames_read)
|
||||||
|
{
|
||||||
|
limits->frames_read += frames_read;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue