hantek-dso: remove sources from session when done
This commit is contained in:
parent
26bf9d56c0
commit
a3508e33f9
|
@ -709,9 +709,7 @@ static void receive_transfer(struct libusb_transfer *transfer)
|
||||||
|
|
||||||
if (devc->limit_frames && ++devc->num_frames == devc->limit_frames) {
|
if (devc->limit_frames && ++devc->num_frames == devc->limit_frames) {
|
||||||
/* Terminate session */
|
/* Terminate session */
|
||||||
/* TODO: don't leave pending USB transfers hanging */
|
devc->dev_state = STOPPING;
|
||||||
packet.type = SR_DF_END;
|
|
||||||
sr_session_send(ctx->cb_data, &packet);
|
|
||||||
} else {
|
} else {
|
||||||
devc->dev_state = NEW_CAPTURE;
|
devc->dev_state = NEW_CAPTURE;
|
||||||
}
|
}
|
||||||
|
@ -721,11 +719,13 @@ static void receive_transfer(struct libusb_transfer *transfer)
|
||||||
|
|
||||||
static int handle_event(int fd, int revents, void *cb_data)
|
static int handle_event(int fd, int revents, void *cb_data)
|
||||||
{
|
{
|
||||||
|
const struct sr_dev_inst *sdi;
|
||||||
struct sr_datafeed_packet packet;
|
struct sr_datafeed_packet packet;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
int num_probes;
|
|
||||||
struct drv_context *drvc;
|
struct drv_context *drvc;
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
const struct libusb_pollfd **lupfd;
|
||||||
|
int num_probes, i;
|
||||||
uint32_t trigger_offset;
|
uint32_t trigger_offset;
|
||||||
uint8_t capturestate;
|
uint8_t capturestate;
|
||||||
|
|
||||||
|
@ -736,11 +736,28 @@ static int handle_event(int fd, int revents, void *cb_data)
|
||||||
drvc = hdi->priv;
|
drvc = hdi->priv;
|
||||||
sdi = cb_data;
|
sdi = cb_data;
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
if (devc->dev_state == STOPPING) {
|
||||||
|
/* We've been told to wind up the acquisition. */
|
||||||
|
sr_dbg("hantek-dso: stopping acquisition");
|
||||||
|
/* TODO: doesn't really cancel pending transfers so they might
|
||||||
|
* come in after SR_DF_END is sent. */
|
||||||
|
lupfd = libusb_get_pollfds(drvc->usb_context);
|
||||||
|
for (i = 0; lupfd[i]; i++)
|
||||||
|
sr_source_remove(lupfd[i]->fd);
|
||||||
|
free(lupfd);
|
||||||
|
|
||||||
|
packet.type = SR_DF_END;
|
||||||
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
|
devc->dev_state = IDLE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Always handle pending libusb events. */
|
/* Always handle pending libusb events. */
|
||||||
tv.tv_sec = tv.tv_usec = 0;
|
tv.tv_sec = tv.tv_usec = 0;
|
||||||
libusb_handle_events_timeout(drvc->usb_context, &tv);
|
libusb_handle_events_timeout(drvc->usb_context, &tv);
|
||||||
|
|
||||||
ctx = cb_data;
|
|
||||||
/* TODO: ugh */
|
/* TODO: ugh */
|
||||||
if (devc->dev_state == NEW_CAPTURE) {
|
if (devc->dev_state == NEW_CAPTURE) {
|
||||||
if (dso_capture_start(devc) != SR_OK)
|
if (dso_capture_start(devc) != SR_OK)
|
||||||
|
@ -840,7 +857,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
lupfd = libusb_get_pollfds(drvc->usb_context);
|
lupfd = libusb_get_pollfds(drvc->usb_context);
|
||||||
for (i = 0; lupfd[i]; i++)
|
for (i = 0; lupfd[i]; i++)
|
||||||
sr_source_add(lupfd[i]->fd, lupfd[i]->events, TICK, handle_event,
|
sr_source_add(lupfd[i]->fd, lupfd[i]->events, TICK, handle_event,
|
||||||
ctx);
|
(void *)sdi);
|
||||||
free(lupfd);
|
free(lupfd);
|
||||||
|
|
||||||
/* Send header packet to the session bus. */
|
/* Send header packet to the session bus. */
|
||||||
|
@ -859,9 +876,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: doesn't really cancel pending transfers so they might come in after
|
|
||||||
* SR_DF_END is sent.
|
|
||||||
*/
|
|
||||||
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
|
static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
|
||||||
void *cb_data)
|
void *cb_data)
|
||||||
{
|
{
|
||||||
|
@ -872,11 +886,8 @@ static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
|
||||||
ctx = sdi->priv;
|
devc = sdi->priv;
|
||||||
ctx->dev_state = IDLE;
|
devc->dev_state = STOPPING;
|
||||||
|
|
||||||
packet.type = SR_DF_END;
|
|
||||||
sr_session_send(cb_data, &packet);
|
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,8 @@ enum states {
|
||||||
IDLE,
|
IDLE,
|
||||||
NEW_CAPTURE,
|
NEW_CAPTURE,
|
||||||
CAPTURE,
|
CAPTURE,
|
||||||
FETCH_DATA
|
FETCH_DATA,
|
||||||
|
STOPPING,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct dso_profile {
|
struct dso_profile {
|
||||||
|
|
Loading…
Reference in New Issue