Index: trunk/MagicSoft/Cosy/videodev/Camera.cc
===================================================================
--- trunk/MagicSoft/Cosy/videodev/Camera.cc	(revision 7230)
+++ trunk/MagicSoft/Cosy/videodev/Camera.cc	(revision 7787)
@@ -17,4 +17,10 @@
 inline int Camera::Ioctl(int req, void *opt, const char *str)
 {
+    if (fd<0)
+    {
+        cout << "Error! Called Ioctl with invalid filedescriptor." << endl;
+        return -1;
+    }
+
     while (1)
     {
@@ -181,5 +187,5 @@
 //        cout << "Camera::Camera - mutex is already locked by this thread" << endl;
     pthread_create(&fThread, NULL, MapThread, this);
-    cout << "done." << endl;
+    cout << "CameraInitialized..." << endl;
 
 }
@@ -216,9 +222,7 @@
 void Camera::ExitLoop()
 {
-    //    cout << "ExitLoop..." << endl;
     fStop = 1;
     while (IsRunning())
         usleep(1);
-    //    cout << "Loop exited." << endl;
 }
 
@@ -261,7 +265,5 @@
     while (1)
     {
-        //cout << "Wait..." << flush;
-        fCond.Wait();
-        //cout << "done." << endl;
+        fCond.Wait();;
         if (fd==-1)
             break;
@@ -319,5 +321,4 @@
     }
 
-    cout << "Loop..." << endl;
     ExitLoop();
 
@@ -329,4 +330,10 @@
     //
     fCond.Broadcast();
+
+    // I don't know what the reason for this line is, but it
+    // seems to solve some starnge crashes when switching
+    // between the two cameras and it ensures that cosy works
+    // with root 4.04/02g
+    fMutex->UnLock();
 }
 
Index: trunk/MagicSoft/Cosy/videodev/Makefile
===================================================================
--- trunk/MagicSoft/Cosy/videodev/Makefile	(revision 7230)
+++ trunk/MagicSoft/Cosy/videodev/Makefile	(revision 7787)
@@ -20,5 +20,5 @@
 # @endcode 
 
-INCLUDES = -I. -I.. -I../incl -I../base -I../caos -I/usr/X11R6/include
+INCLUDES = -I. -I.. -I../incl -I../base -I../caos -I/usr/X11R6/include -I../mars
 
 # @code 
