aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorddennedy <ddennedy@53a565d1-3bb7-0310-b661-cf11e63c67ab>2006-04-09 01:26:41 +0000
committerddennedy <ddennedy@53a565d1-3bb7-0310-b661-cf11e63c67ab>2006-04-09 01:26:41 +0000
commit9c74e4a2956e38045b825e43e1a4b7ba1620dfc2 (patch)
tree69a8a9a41c2f494f941584f6536b4f1269e06fe5
parent96aaa4ca65d7ff51089ebb87dbb3303737735e9d (diff)
downloadlibraw1394-9c74e4a2956e38045b825e43e1a4b7ba1620dfc2.tar.gz
remove memory allocations for isochronous operations from the libraw1394 event loop to make them more respectful of realtime applications
git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@162 53a565d1-3bb7-0310-b661-cf11e63c67ab
-rw-r--r--src/iso.c24
-rw-r--r--src/raw1394_private.h3
2 files changed, 19 insertions, 8 deletions
diff --git a/src/iso.c b/src/iso.c
index 0d5aa9f..35fecb7 100644
--- a/src/iso.c
+++ b/src/iso.c
@@ -152,7 +152,15 @@ static int do_iso_init(raw1394handle_t handle,
handle->iso_state = ISO_STOP;
- return 0;
+ handle->iso_packet_infos = malloc(buf_packets * sizeof(struct raw1394_iso_packet_info));
+ if(handle->iso_packet_infos == NULL) {
+ munmap(handle->iso_buffer, handle->iso_status.config.data_buf_size);
+ handle->iso_buffer = NULL;
+ ioctl(handle->fd, RAW1394_IOC_ISO_SHUTDOWN, 0);
+ return -1;
+ }
+
+ return 0;
}
int raw1394_iso_xmit_init(raw1394handle_t handle,
@@ -287,7 +295,7 @@ static int _raw1394_iso_xmit_queue_packets(raw1394handle_t handle)
/* we could potentially send up to stat->n_packets packets */
packets.n_packets = 0;
- packets.infos = malloc(stat->n_packets * sizeof(struct raw1394_iso_packet_info));
+ packets.infos = handle->iso_packet_infos;
if(packets.infos == NULL)
goto out;
@@ -347,7 +355,6 @@ out_produce:
if(ioctl(handle->fd, RAW1394_IOC_ISO_XMIT_PACKETS, &packets))
retval = -1;
}
- free(packets.infos);
out:
if(stop_sync) {
if(raw1394_iso_xmit_sync(handle))
@@ -456,6 +463,11 @@ void raw1394_iso_shutdown(raw1394handle_t handle)
ioctl(handle->fd, RAW1394_IOC_ISO_SHUTDOWN, 0);
}
+ if(handle->iso_packet_infos) {
+ free(handle->iso_packet_infos);
+ handle->iso_packet_infos = NULL;
+ }
+
handle->iso_mode = ISO_INACTIVE;
}
@@ -473,12 +485,12 @@ static int _raw1394_iso_recv_packets(raw1394handle_t handle)
/* ask the kernel to fill an array with packet info structs */
packets.n_packets = stat->n_packets;
- packets.infos = malloc(packets.n_packets * sizeof(struct raw1394_iso_packet_info));
+ packets.infos = handle->iso_packet_infos;
if(packets.infos == NULL)
goto out;
if(ioctl(handle->fd, RAW1394_IOC_ISO_RECV_PACKETS, &packets) < 0)
- goto out_free;
+ goto out;
while(stat->n_packets > 0) {
struct raw1394_iso_packet_info *info;
@@ -519,8 +531,6 @@ out_consume:
if(ioctl(handle->fd, RAW1394_IOC_ISO_RECV_RELEASE_PACKETS, packets_done))
retval = -1;
}
-out_free:
- free(packets.infos);
out:
return retval;
}
diff --git a/src/raw1394_private.h b/src/raw1394_private.h
index 27683f8..8eb2c76 100644
--- a/src/raw1394_private.h
+++ b/src/raw1394_private.h
@@ -43,7 +43,8 @@ struct raw1394_handle {
raw1394_iso_xmit_handler_t iso_xmit_handler;
raw1394_iso_recv_handler_t iso_recv_handler;
- quadlet_t buffer[HBUF_SIZE/4]; /* 2048 */
+ quadlet_t buffer[HBUF_SIZE/4]; /* 2048 */
+ void *iso_packet_infos; /* actually a struct raw1394_iso_packet_info* */
};
struct sync_cb_data {