runloop: pass callback type to data source process functions

This commit is contained in:
Matthias Ringwald 2016-03-24 20:50:00 +01:00
parent 7cd5ef9557
commit f912b310ca
2 changed files with 5 additions and 6 deletions

View File

@ -172,7 +172,7 @@ void btstack_run_loop_embedded_execute_once(void) {
btstack_data_source_t *next;
for (ds = (btstack_data_source_t *) data_sources; ds != NULL ; ds = next){
next = (btstack_data_source_t *) ds->item.next; // cache pointer to next data_source to allow data source to remove itself
ds->process(ds);
ds->process(ds, DATA_SOURCE_CALLBACK_POLL);
}
#ifdef HAVE_TICK
@ -187,7 +187,7 @@ void btstack_run_loop_embedded_execute_once(void) {
btstack_timer_source_t *ts = (btstack_timer_source_t *) timers;
if (ts->timeout > now) break;
btstack_run_loop_remove_timer(ts);
ts->process(ts, DATA_SOURCE_CALLBACK_POLL);
ts->process(ts);
}
#endif

View File

@ -401,7 +401,7 @@ static void handle_completed_transfer(struct libusb_transfer *transfer){
}
static void usb_process_ds(btstack_data_source_t *ds, btstack_data_source_callback_type_t callback_type) {
if (libusb_state != LIB_USB_TRANSFERS_ALLOCATED) return -1;
if (libusb_state != LIB_USB_TRANSFERS_ALLOCATED) return;
// log_info("begin usb_process_ds");
// always handling an event as we're called when data is ready
@ -415,7 +415,7 @@ static void usb_process_ds(btstack_data_source_t *ds, btstack_data_source_callba
void * next = handle_packet->user_data;
handle_completed_transfer(handle_packet);
// handle case where libusb_close might be called by hci packet handler
if (libusb_state != LIB_USB_TRANSFERS_ALLOCATED) return -1;
if (libusb_state != LIB_USB_TRANSFERS_ALLOCATED) return;
// Move to next in the list of packets to handle
if (next) {
@ -425,7 +425,6 @@ static void usb_process_ds(btstack_data_source_t *ds, btstack_data_source_callba
}
}
// log_info("end usb_process_ds");
return 0;
}
static void usb_process_ts(btstack_timer_source_t *timer) {
@ -437,7 +436,7 @@ static void usb_process_ts(btstack_timer_source_t *timer) {
if (libusb_state != LIB_USB_TRANSFERS_ALLOCATED) return;
// actually handled the packet in the pollfds function
usb_process_ds((struct btstack_data_source *) NULL);
usb_process_ds((struct btstack_data_source *) NULL, DATA_SOURCE_CALLBACK_READ);
// Get the amount of time until next event is due
long msec = AYSNC_POLLING_INTERVAL_MS;