sr: drivers should remove their sources from the session when done
This commit is contained in:
parent
310e9e9be4
commit
2cbeb2b7fb
|
@ -509,7 +509,6 @@ struct sr_session {
|
||||||
/* list of sr_receive_data_callback_t */
|
/* list of sr_receive_data_callback_t */
|
||||||
GSList *datafeed_callbacks;
|
GSList *datafeed_callbacks;
|
||||||
GTimeVal starttime;
|
GTimeVal starttime;
|
||||||
gboolean running;
|
|
||||||
|
|
||||||
unsigned int num_sources;
|
unsigned int num_sources;
|
||||||
|
|
||||||
|
|
18
session.c
18
session.c
|
@ -205,26 +205,24 @@ SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback_t cb)
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO.
|
|
||||||
*/
|
|
||||||
static int sr_session_run_poll(void)
|
static int sr_session_run_poll(void)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
while (session->running) {
|
while (session->num_sources > 0) {
|
||||||
ret = g_poll(session->pollfds, session->num_sources, session->source_timeout);
|
ret = g_poll(session->pollfds, session->num_sources,
|
||||||
|
session->source_timeout);
|
||||||
for (i = 0; i < session->num_sources; i++) {
|
for (i = 0; i < session->num_sources; i++) {
|
||||||
if (session->pollfds[i].revents > 0 || (ret == 0
|
if (session->pollfds[i].revents > 0 || (ret == 0
|
||||||
&& session->source_timeout == session->sources[i].timeout)) {
|
&& session->source_timeout == session->sources[i].timeout)) {
|
||||||
/*
|
/*
|
||||||
* Invoke the source's callback on an event,
|
* Invoke the source's callback on an event,
|
||||||
* or if the poll timeout out and this source
|
* or if the poll timed out and this source
|
||||||
* asked for that timeout.
|
* asked for that timeout.
|
||||||
*/
|
*/
|
||||||
if (!session->sources[i].cb(session->pollfds[i].fd, session->pollfds[i].revents,
|
if (!session->sources[i].cb(session->pollfds[i].fd,
|
||||||
|
session->pollfds[i].revents,
|
||||||
session->sources[i].cb_data))
|
session->sources[i].cb_data))
|
||||||
sr_session_source_remove(session->sources[i].poll_object);
|
sr_session_source_remove(session->sources[i].poll_object);
|
||||||
}
|
}
|
||||||
|
@ -298,12 +296,11 @@ SR_API int sr_session_run(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
sr_info("session: running");
|
sr_info("session: running");
|
||||||
session->running = TRUE;
|
|
||||||
|
|
||||||
/* Do we have real sources? */
|
/* Do we have real sources? */
|
||||||
if (session->num_sources == 1 && session->pollfds[0].fd == -1) {
|
if (session->num_sources == 1 && session->pollfds[0].fd == -1) {
|
||||||
/* Dummy source, freewheel over it. */
|
/* Dummy source, freewheel over it. */
|
||||||
while (session->running)
|
while (session->num_sources)
|
||||||
session->sources[0].cb(-1, 0, session->sources[0].cb_data);
|
session->sources[0].cb(-1, 0, session->sources[0].cb_data);
|
||||||
} else {
|
} else {
|
||||||
/* Real sources, use g_poll() main loop. */
|
/* Real sources, use g_poll() main loop. */
|
||||||
|
@ -346,7 +343,6 @@ SR_API int sr_session_stop(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
sr_info("session: stopping");
|
sr_info("session: stopping");
|
||||||
session->running = FALSE;
|
|
||||||
|
|
||||||
for (l = session->devs; l; l = l->next) {
|
for (l = session->devs; l; l = l->next) {
|
||||||
sdi = l->data;
|
sdi = l->data;
|
||||||
|
|
Loading…
Reference in New Issue