- sr_spew("Resetting %s module.", in->module->id);
- return in->module->reset((struct sr_input *)in);
+ /*
+ * Handle input module status (kept in the 'in' variable) here
+ * in common logic. This agrees with how input module's receive()
+ * and end() routines "amend but never seed" the 'in' information.
+ *
+ * Void potentially accumulated receive() buffer content, and
+ * clear the sdi_ready flag. This makes sure that subsequent
+ * processing will scan the header again before sample data gets
+ * interpreted, and stale content from previous calls won't affect
+ * the result.
+ *
+ * This common logic does not harm when the input module implements
+ * .reset() and contains identical assignments. In the absence of
+ * an individual .reset() method, simple input modules can completely
+ * rely on common code and keep working across resets.
+ */
+ if (in->buf)
+ g_string_truncate(in->buf, 0);
+ in->sdi_ready = FALSE;
+
+ return rc;