Index: trunk/lib/FlairCore/src/ConditionVariable.cpp
===================================================================
--- trunk/lib/FlairCore/src/ConditionVariable.cpp	(revision 318)
+++ trunk/lib/FlairCore/src/ConditionVariable.cpp	(revision 330)
@@ -31,5 +31,5 @@
 ConditionVariable::~ConditionVariable() { delete pimpl_; }
 
-void ConditionVariable::CondWait(void) { pimpl_->CondWait(); }
+bool ConditionVariable::CondWait(Time timeout) { return pimpl_->CondWait(timeout); }
 
 bool ConditionVariable::CondWaitUntil(Time date) {
Index: trunk/lib/FlairCore/src/ConditionVariable.h
===================================================================
--- trunk/lib/FlairCore/src/ConditionVariable.h	(revision 318)
+++ trunk/lib/FlairCore/src/ConditionVariable.h	(revision 330)
@@ -55,6 +55,10 @@
   * Upon successful return, the mutex has been locked and is owned by the
   *calling thread which should unlock it (see Mutex::ReleaseMutex).
+  * 
+  * \param timeout timeout
+  * \return true if the condition variable is signaled before the tipeout specified
+  *  in parameter elapses or if timeout elapses, false otherwise
   */
-  void CondWait(void);
+  bool CondWait(Time timeout=TIME_INFINITE);
 
   /*!
Index: trunk/lib/FlairCore/src/ConditionVariable_impl.cpp
===================================================================
--- trunk/lib/FlairCore/src/ConditionVariable_impl.cpp	(revision 318)
+++ trunk/lib/FlairCore/src/ConditionVariable_impl.cpp	(revision 330)
@@ -53,16 +53,21 @@
 }
 
-void ConditionVariable_impl::CondWait(void) {
+bool ConditionVariable_impl::CondWait(Time timeout) {
   int status;
+  if(timeout==TIME_INFINITE) {
 #ifdef __XENO__
-  status =
-      rt_cond_wait(&m_ResumeCond, &self->Mutex::pimpl_->mutex, TM_INFINITE);
+    status=rt_cond_wait(&m_ResumeCond, &self->Mutex::pimpl_->mutex, TM_INFINITE);
 #else
-  status = pthread_cond_wait(&m_ResumeCond, &self->Mutex::pimpl_->mutex);
+    status=pthread_cond_wait(&m_ResumeCond, &self->Mutex::pimpl_->mutex);
 #endif
-  if (status != 0) {
-		char errorMsg[256];
-    self->Err("error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
-	}
+    if(status != 0) {
+      char errorMsg[256];
+      self->Err("error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
+      return false;
+    }
+    return true;
+  } else {
+    return CondWaitUntil(GetTime()+timeout);
+  }
 }
 
@@ -72,12 +77,11 @@
   status = rt_cond_wait_until(&m_ResumeCond, &self->Mutex::pimpl_->mutex, date);
 #else
-  struct timespec restrict;
-  restrict.tv_sec = date / 1000000000;
-  restrict.tv_nsec = date % 1000000000;
+  struct timespec abstime;
+  abstime.tv_sec = date / 1000000000;
+  abstime.tv_nsec = date % 1000000000;
   status = pthread_cond_timedwait(&m_ResumeCond, &self->Mutex::pimpl_->mutex,
-                                  &restrict);
+                                  &abstime);
 #endif
-  if (status == 0)
-    return true;
+  if (status == 0) return true;
   if (status != ETIMEDOUT) {
 		char errorMsg[256];
Index: trunk/lib/FlairCore/src/IODevice_impl.cpp
===================================================================
--- trunk/lib/FlairCore/src/IODevice_impl.cpp	(revision 318)
+++ trunk/lib/FlairCore/src/IODevice_impl.cpp	(revision 330)
@@ -225,8 +225,12 @@
 
   wake_mutex->GetMutex();
-  if (thread_to_wake == NULL) {
-    thread_to_wake = (Thread *)thread;
-  } else {
-    status = -1;
+  if(thread==NULL) {
+    thread_to_wake=NULL;
+  } else {
+    if (thread_to_wake == NULL) {
+      thread_to_wake = (Thread *)thread;
+    } else {
+      status = -1;
+    }
   }
   wake_mutex->ReleaseMutex();
Index: trunk/lib/FlairCore/src/Picture.cpp
===================================================================
--- trunk/lib/FlairCore/src/Picture.cpp	(revision 318)
+++ trunk/lib/FlairCore/src/Picture.cpp	(revision 330)
@@ -20,4 +20,5 @@
 #include "Layout.h"
 #include "LayoutPosition.h"
+#include <string.h>
 
 using std::string;
@@ -45,5 +46,5 @@
   if (image != NULL) {
     image->GetMutex();
-    memcpy(buf, image->img->imageData, image->GetDataType().GetSize());
+    memcpy(buf, image->buffer, image->GetDataType().GetSize());
     image->ReleaseMutex();
   }
Index: trunk/lib/FlairCore/src/Picture.h
===================================================================
--- trunk/lib/FlairCore/src/Picture.h	(revision 318)
+++ trunk/lib/FlairCore/src/Picture.h	(revision 330)
@@ -15,5 +15,4 @@
 
 #include <SendData.h>
-#include <cxtypes.h>
 
 namespace flair {
Index: trunk/lib/FlairCore/src/RangeFinderPlot.cpp
===================================================================
--- trunk/lib/FlairCore/src/RangeFinderPlot.cpp	(revision 318)
+++ trunk/lib/FlairCore/src/RangeFinderPlot.cpp	(revision 330)
@@ -20,5 +20,4 @@
 #include "Matrix.h"
 #include "LayoutPosition.h"
-#include <cxcore.h>
 
 using std::string;
Index: trunk/lib/FlairCore/src/Thread.cpp
===================================================================
--- trunk/lib/FlairCore/src/Thread.cpp	(revision 318)
+++ trunk/lib/FlairCore/src/Thread.cpp	(revision 330)
@@ -82,6 +82,6 @@
 void Thread::Resume(void) { pimpl_->Resume(); }
 
-int Thread::WaitUpdate(const IODevice *device) {
-  return pimpl_->WaitUpdate(device);
+bool Thread::WaitUpdate(const IODevice *device,Time timeout) {
+  return pimpl_->WaitUpdate(device,timeout);
 }
 
Index: trunk/lib/FlairCore/src/Thread.h
===================================================================
--- trunk/lib/FlairCore/src/Thread.h	(revision 318)
+++ trunk/lib/FlairCore/src/Thread.h	(revision 330)
@@ -140,6 +140,7 @@
   *
   * \param device IODevice to wait update from
-  */
-  int WaitUpdate(const IODevice *device);
+  * \return true if device was updated, false otherwise (timeout, etc)
+  */
+  bool WaitUpdate(const IODevice *device,Time timeout=TIME_INFINITE);
 
   /*!
Index: trunk/lib/FlairCore/src/Thread_impl.cpp
===================================================================
--- trunk/lib/FlairCore/src/Thread_impl.cpp	(revision 318)
+++ trunk/lib/FlairCore/src/Thread_impl.cpp	(revision 330)
@@ -276,10 +276,10 @@
 }
 
-int Thread_impl::WaitUpdate(const IODevice *device) {
-  int status = 0;
+bool Thread_impl::WaitUpdate(const IODevice *device,Time timeout) {
+  bool status = true;
 
   if (IsSuspended() == true) {
     self->Err("thread is already supended\n");
-    status = -1;
+    status = false;
   } else {
     cond->GetMutex();
@@ -287,10 +287,10 @@
     if (device->pimpl_->SetToWake(self) == 0) {
       is_suspended = true;
-      cond->CondWait();
+      status=cond->CondWait(timeout);
+      if(status==false) device->pimpl_->SetToWake(NULL);//condwait timedout
       is_suspended = false;
     } else {
-      self->Err("%s is already waiting an update\n",
-                device->ObjectName().c_str());
-      status = -1;
+      self->Err("%s is already waiting an update\n", device->ObjectName().c_str());
+      status = false;
     }
 
Index: trunk/lib/FlairCore/src/cvimage.cpp
===================================================================
--- trunk/lib/FlairCore/src/cvimage.cpp	(revision 318)
+++ trunk/lib/FlairCore/src/cvimage.cpp	(revision 330)
@@ -22,23 +22,26 @@
 namespace core {
 
+char* (*cvimage::allocFunction)(ssize_t)=cvimage::DefaultAllocFunction;
+void (*cvimage::freeFunction)(char*)=cvimage::DefaultFreeFunction;
+   
 cvimage::cvimage(const Object *parent, uint16_t width, uint16_t height,
                  Type::Format format, string name, bool allocate_data, int n)
     : io_data(parent, name, n), dataType(width, height, format) {
   this->allocate_data = allocate_data;
-
+//Printf("cvimage %s\n",ObjectName().c_str());
   if (allocate_data) {
     switch (format) {
     case Type::Format::YUYV:
     case Type::Format::UYVY:
-      img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 2);
+      buffer=allocFunction(width*height*2);
       break;
     case Type::Format::BGR:
-      img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
+      buffer=allocFunction(width*height*3);
       break;
     case Type::Format::Gray:
-      img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 1);
+      buffer=allocFunction(width*height*1);
       break;
     default:
-      Err("format no supported");
+      Err("format not supported");
       break;
     }
@@ -47,22 +50,7 @@
       Err("number of samples!=1 not possible when not allocating data\n");
     n = 1;
-    switch (format) {
-    case Type::Format::YUYV:
-    case Type::Format::UYVY:
-      img = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 2);
-      break;
-    case Type::Format::BGR:
-      img = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 3);
-      break;
-    case Type::Format::Gray:
-      img = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 1);
-      break;
-    default:
-      Err("format no supported");
-      break;
-    }
   }
 
-  SetPtrToCircle((void **)&img);
+  SetPtrToCircle((void **)&buffer);
 
   if (n > 1)
@@ -72,10 +60,27 @@
 cvimage::~cvimage() {
   // printf("destructeur cvimage\n");
-
-  cvReleaseImage(&img);
+  if(allocate_data) freeFunction(buffer);
 }
 
 void cvimage::RawRead(char *dst) const { Warn("non implementé\n"); }
 
+void cvimage::RegisterAllocFunction(char*(*func)(ssize_t size)) {
+  if(allocFunction==DefaultAllocFunction) allocFunction=func;
+}
+
+void cvimage::RegisterFreeFunction(void(*func)(char* buffer)) {
+  if(freeFunction==DefaultFreeFunction) freeFunction=func;
+}
+
+char* cvimage::DefaultAllocFunction(ssize_t size){
+  Printf("default alloc %i\n",size);
+  return (char*)malloc(size);
+}
+
+void cvimage::DefaultFreeFunction(char* buffer){
+  Printf("default free\n");
+  free(buffer);
+}
+
 } // end namespace core
 } // end namespace flair
Index: trunk/lib/FlairCore/src/cvimage.h
===================================================================
--- trunk/lib/FlairCore/src/cvimage.h	(revision 318)
+++ trunk/lib/FlairCore/src/cvimage.h	(revision 330)
@@ -14,7 +14,14 @@
 #define CVIMAGE_H
 
-#include <cxcore.h>
 #include <io_data.h>
 #include <stdint.h>
+
+
+namespace flair {
+namespace sensor {
+class V4LCamera;
+}
+}
+
 
 namespace flair {
@@ -28,5 +35,6 @@
 */
 class cvimage : public io_data {
-public:
+    public:
+  friend class flair::sensor::V4LCamera;
   class Type : public DataType {
   public:
@@ -97,12 +105,11 @@
   ~cvimage();
 
-  /*!
-  * \brief IplImage
-  *
-  * \return IplImage
-  */
-  IplImage *img;
+  
+  char *buffer;
 
   Type const &GetDataType() const { return dataType; };
+  
+  static void RegisterAllocFunction(char*(*func)(ssize_t size));
+  static void RegisterFreeFunction(void(*func)(char* buffer));
 
 private:
@@ -119,4 +126,9 @@
   bool allocate_data;
   Type dataType;
+  static char* (*allocFunction)(ssize_t);
+  static void (*freeFunction)(char*);
+  static char* DefaultAllocFunction(ssize_t size);
+  static void DefaultFreeFunction(char* buffer);
+  
 };
 
Index: trunk/lib/FlairCore/src/unexported/ConditionVariable_impl.h
===================================================================
--- trunk/lib/FlairCore/src/unexported/ConditionVariable_impl.h	(revision 318)
+++ trunk/lib/FlairCore/src/unexported/ConditionVariable_impl.h	(revision 330)
@@ -37,5 +37,5 @@
   ConditionVariable_impl(flair::core::ConditionVariable *self);
   ~ConditionVariable_impl();
-  void CondWait(void);
+  bool CondWait(flair::core::Time timeout);
   bool CondWaitUntil(flair::core::Time date);
   void CondSignal(void);
Index: trunk/lib/FlairCore/src/unexported/Thread_impl.h
===================================================================
--- trunk/lib/FlairCore/src/unexported/Thread_impl.h	(revision 318)
+++ trunk/lib/FlairCore/src/unexported/Thread_impl.h	(revision 330)
@@ -47,5 +47,5 @@
   void Resume(void);
   bool IsSuspended(void);
-  int WaitUpdate(const flair::core::IODevice *device);
+  bool WaitUpdate(const flair::core::IODevice *device,flair::core::Time timeout);
   bool period_set;
    bool isRunning;
