X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fsw_limits.c;h=37c28667987df4f643e584466ae0b3e3eb15453f;hb=82b9f3d116ce0c982291a2dfdd15cd8a1c4cc16e;hp=bea14692749a679f6be57c0cf2451b769ac4a856;hpb=d9251a2c9f1ca4380c27240ccca90c9f9ed46d3f;p=libsigrok.git diff --git a/src/sw_limits.c b/src/sw_limits.c index bea14692..37c28667 100644 --- a/src/sw_limits.c +++ b/src/sw_limits.c @@ -20,7 +20,6 @@ /** * @file * Software limits helper functions - * @internal */ #include @@ -45,6 +44,7 @@ SR_PRIV void sr_sw_limits_init(struct sr_sw_limits *limits) { limits->limit_samples = 0; + limits->limit_frames = 0; limits->limit_msec = 0; } @@ -66,6 +66,9 @@ SR_PRIV int sr_sw_limits_config_get(struct sr_sw_limits *limits, uint32_t key, case SR_CONF_LIMIT_SAMPLES: *data = g_variant_new_uint64(limits->limit_samples); break; + case SR_CONF_LIMIT_FRAMES: + *data = g_variant_new_uint64(limits->limit_frames); + break; case SR_CONF_LIMIT_MSEC: *data = g_variant_new_uint64(limits->limit_msec / 1000); break; @@ -94,6 +97,9 @@ SR_PRIV int sr_sw_limits_config_set(struct sr_sw_limits *limits, uint32_t key, case SR_CONF_LIMIT_SAMPLES: limits->limit_samples = g_variant_get_uint64(data); break; + case SR_CONF_LIMIT_FRAMES: + limits->limit_frames = g_variant_get_uint64(data); + break; case SR_CONF_LIMIT_MSEC: limits->limit_msec = g_variant_get_uint64(data) * 1000; break; @@ -115,6 +121,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) { limits->samples_read = 0; + limits->frames_read = 0; limits->start_time = g_get_monotonic_time(); } @@ -138,6 +145,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) { guint64 now; now = g_get_monotonic_time(); @@ -153,7 +168,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 * acquisition run. For each invocation @p samples_read will be accumulated and @@ -168,3 +183,20 @@ SR_PRIV void sr_sw_limits_update_samples_read(struct sr_sw_limits *limits, { 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; +}