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
This commit is contained in:
parent
96aaa4ca65
commit
9c74e4a295
22
src/iso.c
22
src/iso.c
|
@ -152,6 +152,14 @@ static int do_iso_init(raw1394handle_t handle,
|
||||||
|
|
||||||
handle->iso_state = ISO_STOP;
|
handle->iso_state = ISO_STOP;
|
||||||
|
|
||||||
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,7 +295,7 @@ static int _raw1394_iso_xmit_queue_packets(raw1394handle_t handle)
|
||||||
|
|
||||||
/* we could potentially send up to stat->n_packets packets */
|
/* we could potentially send up to stat->n_packets packets */
|
||||||
packets.n_packets = 0;
|
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)
|
if(packets.infos == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -347,7 +355,6 @@ out_produce:
|
||||||
if(ioctl(handle->fd, RAW1394_IOC_ISO_XMIT_PACKETS, &packets))
|
if(ioctl(handle->fd, RAW1394_IOC_ISO_XMIT_PACKETS, &packets))
|
||||||
retval = -1;
|
retval = -1;
|
||||||
}
|
}
|
||||||
free(packets.infos);
|
|
||||||
out:
|
out:
|
||||||
if(stop_sync) {
|
if(stop_sync) {
|
||||||
if(raw1394_iso_xmit_sync(handle))
|
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);
|
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;
|
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 */
|
/* ask the kernel to fill an array with packet info structs */
|
||||||
packets.n_packets = stat->n_packets;
|
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)
|
if(packets.infos == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if(ioctl(handle->fd, RAW1394_IOC_ISO_RECV_PACKETS, &packets) < 0)
|
if(ioctl(handle->fd, RAW1394_IOC_ISO_RECV_PACKETS, &packets) < 0)
|
||||||
goto out_free;
|
goto out;
|
||||||
|
|
||||||
while(stat->n_packets > 0) {
|
while(stat->n_packets > 0) {
|
||||||
struct raw1394_iso_packet_info *info;
|
struct raw1394_iso_packet_info *info;
|
||||||
|
@ -519,8 +531,6 @@ out_consume:
|
||||||
if(ioctl(handle->fd, RAW1394_IOC_ISO_RECV_RELEASE_PACKETS, packets_done))
|
if(ioctl(handle->fd, RAW1394_IOC_ISO_RECV_RELEASE_PACKETS, packets_done))
|
||||||
retval = -1;
|
retval = -1;
|
||||||
}
|
}
|
||||||
out_free:
|
|
||||||
free(packets.infos);
|
|
||||||
out:
|
out:
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,8 @@ struct raw1394_handle {
|
||||||
raw1394_iso_xmit_handler_t iso_xmit_handler;
|
raw1394_iso_xmit_handler_t iso_xmit_handler;
|
||||||
raw1394_iso_recv_handler_t iso_recv_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 {
|
struct sync_cb_data {
|
||||||
|
|
Reference in New Issue