X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=aoview%2Faoview_serial.c;h=1d8fefcedc94cb9ee1df1135bbb57cef005cbf56;hp=5cb286f88a924c30fb656c32f379f75bf5b1870c;hb=e506ed4b6efb86eab50204658fcd433b987e3831;hpb=09771c644de54ae354e8f98af7ba74289b3c0fcc diff --git a/aoview/aoview_serial.c b/aoview/aoview_serial.c index 5cb286f8..1d8fefce 100644 --- a/aoview/aoview_serial.c +++ b/aoview/aoview_serial.c @@ -191,6 +191,7 @@ serial_dispatch(GSource *source, gpointer user_data) { struct aoview_serial *serial = (struct aoview_serial *) source; + aoview_serial_callback func = (aoview_serial_callback) callback; gint revents = serial->poll_fd.revents; if (revents & G_IO_IN) @@ -199,8 +200,8 @@ serial_dispatch(GSource *source, if (revents & G_IO_OUT) aoview_buf_flush(&serial->out_buf, serial->fd); - if (callback && (revents & G_IO_IN)) - (*callback)(user_data); + if (func) + (*func)(user_data, serial, revents); return TRUE; } @@ -258,13 +259,14 @@ aoview_serial_close(struct aoview_serial *serial) g_source_remove_poll(&serial->source, &serial->poll_fd); g_source_destroy(&serial->source); g_source_unref(&serial->source); + free(serial); } void aoview_serial_set_callback(struct aoview_serial *serial, - GSourceFunc func, + aoview_serial_callback func, gpointer data, GDestroyNotify notify) { - g_source_set_callback(&serial->source, func, data, notify); + g_source_set_callback(&serial->source, (GSourceFunc) func, data, notify); }