From 0b0ad6b10e1667571f97bd8f2e73b35359f4b5ef Mon Sep 17 00:00:00 2001 From: ddennedy Date: Sun, 9 Apr 2006 02:13:44 +0000 Subject: [PATCH] lock allocated isochronous packet tracking memory git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@163 53a565d1-3bb7-0310-b661-cf11e63c67ab --- src/iso.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/iso.c b/src/iso.c index 35fecb7..fc45063 100644 --- a/src/iso.c +++ b/src/iso.c @@ -105,6 +105,7 @@ static int do_iso_init(raw1394handle_t handle, int cmd) { unsigned int stride; + int result; /* already initialized? */ if(handle->iso_mode != ISO_INACTIVE) @@ -159,7 +160,16 @@ static int do_iso_init(raw1394handle_t handle, ioctl(handle->fd, RAW1394_IOC_ISO_SHUTDOWN, 0); return -1; } - +#if _POSIX_MEMLOCK > 0 + result = mlock(handle->iso_packet_infos, buf_packets * sizeof(struct raw1394_iso_packet_info)); + /* Ignore a permission error - app is responsible for that, */ + if (result < 0 && result != -EPERM) { + 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; + } +#endif return 0; } @@ -464,6 +474,11 @@ void raw1394_iso_shutdown(raw1394handle_t handle) } if(handle->iso_packet_infos) { +#if _POSIX_MEMLOCK > 0 + munlock(handle->iso_packet_infos, + handle->iso_status.config.buf_packets * + sizeof(struct raw1394_iso_packet_info)); +#endif free(handle->iso_packet_infos); handle->iso_packet_infos = NULL; }