Changed iso rcv handling to separate handlers per channel.

git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@6 53a565d1-3bb7-0310-b661-cf11e63c67ab
This commit is contained in:
abombe 2000-02-04 23:20:17 +00:00
parent 7ba9a46969
commit 9eb8df1247
6 changed files with 34 additions and 23 deletions

View File

@ -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 ])

View File

@ -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 \

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
/*

View File

@ -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];