check(sr_input_end(_structure));
}
+void Input::reset()
+{
+ check(sr_input_reset(_structure));
+}
+
Input::~Input()
{
sr_input_free(_structure);
void send(void *data, size_t length);
/** Signal end of input data. */
void end();
+ void reset();
private:
Input(shared_ptr<Context> context, const struct sr_input *structure);
~Input();
SR_API struct sr_dev_inst *sr_input_dev_inst_get(const struct sr_input *in);
SR_API int sr_input_send(const struct sr_input *in, GString *buf);
SR_API int sr_input_end(const struct sr_input *in);
+SR_API int sr_input_reset(const struct sr_input *in);
SR_API void sr_input_free(const struct sr_input *in);
/*--- output/output.c -------------------------------------------------------*/
return in->module->end((struct sr_input *)in);
}
+/**
+ * Reset the input module's input handling structures.
+ *
+ * Causes the input module to reset its internal state so that we can re-send
+ * the input data from the beginning without having to re-create the entire
+ * input module.
+ *
+ * @since 0.5.0
+ */
+SR_API int sr_input_reset(const struct sr_input *in)
+{
+ if (!in->module->reset) {
+ sr_spew("Tried to reset %s module but no reset handler found.",
+ in->module->id);
+ return SR_OK;
+ }
+
+ sr_spew("Resetting %s module.", in->module->id);
+ return in->module->reset((struct sr_input *)in);
+}
+
/**
* Free the specified input instance and all associated resources.
*
*/
int (*end) (struct sr_input *in);
+ /**
+ * Reset the input module's input handling structures.
+ *
+ * Causes the input module to reset its internal state so that we can
+ * re-send the input data from the beginning without having to
+ * re-create the entire input module.
+ *
+ * @retval SR_OK Success.
+ * @retval other Negative error code.
+ */
+ int (*reset) (struct sr_input *in);
+
/**
* This function is called after the caller is finished using
* the input module, and can be used to free any internal