Input: Add reset() function
This commit is contained in:
parent
0221cbdde3
commit
b6b4f03e40
|
@ -1329,6 +1329,11 @@ void Input::end()
|
||||||
check(sr_input_end(_structure));
|
check(sr_input_end(_structure));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Input::reset()
|
||||||
|
{
|
||||||
|
check(sr_input_reset(_structure));
|
||||||
|
}
|
||||||
|
|
||||||
Input::~Input()
|
Input::~Input()
|
||||||
{
|
{
|
||||||
sr_input_free(_structure);
|
sr_input_free(_structure);
|
||||||
|
|
|
@ -828,6 +828,7 @@ public:
|
||||||
void send(void *data, size_t length);
|
void send(void *data, size_t length);
|
||||||
/** Signal end of input data. */
|
/** Signal end of input data. */
|
||||||
void end();
|
void end();
|
||||||
|
void reset();
|
||||||
private:
|
private:
|
||||||
Input(shared_ptr<Context> context, const struct sr_input *structure);
|
Input(shared_ptr<Context> context, const struct sr_input *structure);
|
||||||
~Input();
|
~Input();
|
||||||
|
|
|
@ -154,6 +154,7 @@ SR_API int sr_input_scan_file(const char *filename, const struct sr_input **in);
|
||||||
SR_API struct sr_dev_inst *sr_input_dev_inst_get(const struct sr_input *in);
|
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_send(const struct sr_input *in, GString *buf);
|
||||||
SR_API int sr_input_end(const struct sr_input *in);
|
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);
|
SR_API void sr_input_free(const struct sr_input *in);
|
||||||
|
|
||||||
/*--- output/output.c -------------------------------------------------------*/
|
/*--- output/output.c -------------------------------------------------------*/
|
||||||
|
|
|
@ -559,6 +559,27 @@ SR_API int sr_input_end(const struct sr_input *in)
|
||||||
return in->module->end((struct sr_input *)in);
|
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.
|
* Free the specified input instance and all associated resources.
|
||||||
*
|
*
|
||||||
|
|
|
@ -401,6 +401,18 @@ struct sr_input_module {
|
||||||
*/
|
*/
|
||||||
int (*end) (struct sr_input *in);
|
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
|
* This function is called after the caller is finished using
|
||||||
* the input module, and can be used to free any internal
|
* the input module, and can be used to free any internal
|
||||||
|
|
Loading…
Reference in New Issue