session: Auto-commit settings before acquisition.

(sr_session_start): Just before starting acquisition on
a device, call sr_config_commit() to apply pending config
changes to the hardware device.
(sr_session_dev_add): Ditto.  Also, return an error code
if starting acquisition failed.
This commit is contained in:
Daniel Elstner 2014-01-20 23:04:49 +01:00 committed by Bert Vermeulen
parent 8dd0b290eb
commit 32b7cd4f02
1 changed files with 17 additions and 4 deletions

View File

@ -176,12 +176,20 @@ SR_API int sr_session_dev_add(const struct sr_dev_inst *sdi)
session->devs = g_slist_append(session->devs, (gpointer)sdi);
if (session->running) {
/* Adding a device to a running session. Start acquisition
* on that device now. */
/* Adding a device to a running session. Commit settings
* and start acquisition on that device now. */
if ((ret = sr_config_commit(sdi)) != SR_OK) {
sr_err("Failed to commit device settings before "
"starting acquisition in running session (%s)",
sr_strerror(ret));
return ret;
}
if ((ret = sdi->driver->dev_acquisition_start(sdi,
(void *)sdi)) != SR_OK)
(void *)sdi)) != SR_OK) {
sr_err("Failed to start acquisition of device in "
"running session: %d", ret);
"running session (%s)", sr_strerror(ret));
return ret;
}
}
return SR_OK;
@ -354,6 +362,11 @@ SR_API int sr_session_start(void)
ret = SR_OK;
for (l = session->devs; l; l = l->next) {
sdi = l->data;
if ((ret = sr_config_commit(sdi)) != SR_OK) {
sr_err("Failed to commit device settings before "
"starting acquisition (%s)", sr_strerror(ret));
break;
}
if ((ret = sdi->driver->dev_acquisition_start(sdi, sdi)) != SR_OK) {
sr_err("%s: could not start an acquisition "
"(%s)", __func__, sr_strerror(ret));