The thing is it does not even get to the point where it unlocks the mutex. if i comment out the mutex stuff, and put a print before and after the open() call, it will print before, but not after. its just dying on the open().
Here is the qcam_read()
int qcam_read( int device, int *imgwidth, int * imgheight, int * imgdepth,
unsigned char ** image, pthread_mutex_t the_mutex) {
int rc;
ioctl(device, VIDIOCGCAP, &vidcap);
ioctl(device, VIDIOCGWIN, &vidwin);
ioctl(device, VIDIOCGPICT, &vidpic);
*imgwidth= vidwin.width;
*imgheight= vidwin.height;
*imgdepth= vidpic.depth/8;
*image = malloc(vidcap.maxwidth * vidcap.maxheight * 3);
rc = pthread_mutex_lock(&a_mutex);
printf( "device %d\twidth %d\theight %d\n", device, vidcap.maxwidth, vidcap.maxheight );
printf( "%x\n", *image );
if( !rc )
{
printf( "Mutex locked in qcam_read\n" );
}
else
{
printf( "Cant lock mutex in cam_read\n" );
}
read(device, *image, (vidcap.maxwidth * vidcap.maxheight * 3));
rc = pthread_mutex_unlock(&a_mutex);
if( !rc )
{
printf( "Mutex unlocked in qcam_read\n" );
}
printf( "Qcam_read %d\n", device );
return 1;
}
Thx for you help :)