diff --git a/configure.in b/configure.in index 39802f8..1b966fc 100644 --- a/configure.in +++ b/configure.in @@ -4,6 +4,7 @@ AC_INIT(Makefile.am) AM_INIT_AUTOMAKE(libraw1394, 0.4) AC_PROG_CC +AC_PROG_RANLIB AM_PROG_LIBTOOL AC_OUTPUT([ Makefile src/Makefile ]) diff --git a/src/Makefile.am b/src/Makefile.am index ab32929..c40ac89 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,7 +3,7 @@ lib_LTLIBRARIES = libraw1394.la -libraw1394_la_LDFLAGS = -version-info 1:0:1 +libraw1394_la_LDFLAGS = -version-info 2:0:0 libraw1394_la_SOURCES = \ main.c \ diff --git a/src/eventloop.c b/src/eventloop.c index 32b053c..62f5202 100644 --- a/src/eventloop.c +++ b/src/eventloop.c @@ -9,7 +9,7 @@ int raw1394_loop_iterate(struct raw1394_handle *handle) { struct raw1394_request *req = &handle->req; - int retval = 0; + int retval = 0, channel; if (read(handle->fd, req, sizeof(*req)) < 0) { return -1; @@ -27,11 +27,12 @@ int raw1394_loop_iterate(struct raw1394_handle *handle) break; case RAW1394_REQ_ISO_RECEIVE: - if (handle->iso_handler) { - retval = handle->iso_handler(handle, - (handle->buffer[0] >> 8) - & 0x3f, req->length, - handle->buffer); + channel = (handle->buffer[0] >> 8) & 0x3f; + + if (handle->iso_handler[channel]) { + retval = handle->iso_handler[channel](handle, channel, + req->length, + handle->buffer); } break; @@ -70,12 +71,22 @@ tag_handler_t raw1394_set_tag_handler(struct raw1394_handle *handle, } iso_handler_t raw1394_set_iso_handler(struct raw1394_handle *handle, - iso_handler_t new) + unsigned int channel, iso_handler_t new) { - iso_handler_t old; + if (channel >= 64) { + return (iso_handler_t)-1; + } - old = handle->iso_handler; - handle->iso_handler = new; + if (new == NULL) { + iso_handler_t old = handle->iso_handler[channel]; + handle->iso_handler[channel] = NULL; + return old; + } - return old; + if (handle->iso_handler[channel] != NULL) { + return (iso_handler_t)-1; + } + + handle->iso_handler[channel] = new; + return NULL; } diff --git a/src/main.c b/src/main.c index d268f0b..f7d9439 100644 --- a/src/main.c +++ b/src/main.c @@ -27,12 +27,6 @@ static int tag_handler_default(struct raw1394_handle *handle, unsigned long tag, } } -static int iso_handler_default(struct raw1394_handle *handle, int channel, - size_t length, quadlet_t *data) -{ - return 0; -} - int _raw1394_sync_cb(struct raw1394_handle *unused, struct sync_cb_data *data, int error) { @@ -88,7 +82,7 @@ struct raw1394_handle *raw1394_get_handle(void) handle->bus_reset_handler = bus_reset_default; handle->tag_handler = tag_handler_default; - handle->iso_handler = iso_handler_default; + memset(handle->iso_handler, 0, sizeof(handle->iso_handler)); return handle; } diff --git a/src/raw1394.h b/src/raw1394.h index 849369e..9cf4c34 100644 --- a/src/raw1394.h +++ b/src/raw1394.h @@ -90,13 +90,18 @@ tag_handler_t raw1394_set_tag_handler(raw1394handle_t handle, /* * Set the handler that will be called when an iso packet arrives (data points - * to the iso packet header). The default action is to do nothing. Returns old - * handler. + * to the iso packet header). The default action is to do nothing. + * + * Handlers have to be set separately for each channel, it is not possible to + * set a handler when there is already one set for that channel. Handlers can + * be cleared by passing NULL for "new" parameter, in that case the old handler + * will be returned. Otherwise the return value is NULL for success and -1 for + * failure. */ typedef int (*iso_handler_t)(raw1394handle_t, int channel, size_t length, quadlet_t *data); iso_handler_t raw1394_set_iso_handler(raw1394handle_t handle, - iso_handler_t new); + unsigned int channel, iso_handler_t new); /* diff --git a/src/raw1394_private.h b/src/raw1394_private.h index c570d4b..570bc00 100644 --- a/src/raw1394_private.h +++ b/src/raw1394_private.h @@ -11,7 +11,7 @@ struct raw1394_handle { bus_reset_handler_t bus_reset_handler; tag_handler_t tag_handler; - iso_handler_t iso_handler; + iso_handler_t iso_handler[64]; struct raw1394_request req; quadlet_t buffer[2048];