Index: trunk/MagicSoft/Cosy/videodev/Camera.cc
===================================================================
--- trunk/MagicSoft/Cosy/videodev/Camera.cc	(revision 8856)
+++ trunk/MagicSoft/Cosy/videodev/Camera.cc	(revision 8859)
@@ -51,13 +51,4 @@
 }
 
-void Camera::ExitLoop()
-{
-    CancelThread();
-
-    // Some information
-    //cout << fNumFrame-1 << "frames processed." << endl;
-    //cout << fNumSkipped << "frames skipped." << endl;
-}
-
 void Camera::ProcessFrame(char *img)
 {
@@ -98,5 +89,5 @@
 {
     fNumSkipped = 0;
-    fNumFrame   = 1;
+    fNumFrame   = 0;
 
     if (!fVideo->IsOpen())
@@ -108,5 +99,5 @@
     //Print();
 
-    for (int f=0; f<fVideo->GetNumBuffers()-1; f++)
+    for (int f=1; f<fVideo->GetNumBuffers(); f++)
         if (!fVideo->CaptureStart(f))
             return kFALSE;
@@ -161,7 +152,7 @@
 }
 
-void Camera::Loop(unsigned long nof)
-{
-}
+//void Camera::Loop(unsigned long nof)
+//{
+//}
 
 void Camera::SetChannel(int chan)
Index: trunk/MagicSoft/Cosy/videodev/Camera.h
===================================================================
--- trunk/MagicSoft/Cosy/videodev/Camera.h	(revision 8856)
+++ trunk/MagicSoft/Cosy/videodev/Camera.h	(revision 8859)
@@ -40,12 +40,7 @@
     virtual ~Camera();
 
-    //
-    // Starts, stops the execution
-    //
-    void Loop(const unsigned long nof=0);
-    void ExitLoop();
-    //int  IsRunning() const;
+    void SetChannel(int);
 
-    void SetChannel(int);
+    void ExitLoop() { CancelThread(); }
 
     //ClassDef(Camera, 0)
Index: trunk/MagicSoft/Cosy/videodev/MVideo.cc
===================================================================
--- trunk/MagicSoft/Cosy/videodev/MVideo.cc	(revision 8856)
+++ trunk/MagicSoft/Cosy/videodev/MVideo.cc	(revision 8859)
@@ -263,6 +263,4 @@
         fCaps.maxheight, fCaps.maxwidth, // height, width
         VIDEO_PALETTE_RGB24              // palette
-        //768, 576, 
-        //VIDEO_PALETTE_RGB555             // palette
     };
 
@@ -274,5 +272,7 @@
 
 //    if (errno == EAGAIN)
-        gLog << err << "ERROR - Couldn't start capturing frame " << frame << " - unable to sync." << endl;
+    gLog << err;
+    gLog << "ERROR - Couldn't start capturing frame " << frame << " - unable to sync." << endl;
+    gLog << "        Maybe your card doesn't support VIDEO_PALETTE_RGB24." << endl;
 
     return kFALSE;
Index: trunk/MagicSoft/Cosy/videodev/PngReader.cc
===================================================================
--- trunk/MagicSoft/Cosy/videodev/PngReader.cc	(revision 8856)
+++ trunk/MagicSoft/Cosy/videodev/PngReader.cc	(revision 8859)
@@ -113,5 +113,5 @@
 {
     cout << "Starting thread..." << flush;
-    pthread_create(&fThread, NULL, MapThread, this);
+    RunThread();
     cout << "done." << endl;
 
@@ -121,33 +121,24 @@
 {
     cout << "Stopping thread..." << flush;
-    pthread_cancel(fThread);
+    CancelThread();
     cout << "done." << endl;
 }
 
-void *PngReader::MapThread(void *arg)
+Int_t PngReader::Thread()
 {
-    PngReader *cam = (PngReader*)arg;
+    Sleep(3000000);
 
-    // setpriority(PRIO_PROCESS, 0, 10);
-    pthread_detach(pthread_self());
-
-    cam->Thread();
-
-    return 0;
-}
-
-void PngReader::Thread()
-{
-    fIsRunning = 1;
-    usleep(3000000);
     int i=0;
 
     gettimeofday(&fTime, NULL);
 
-    while (!fStop)
+    while (1)
     {
         // if (i<536)
         // {
         GetImg(i);
+
+        TThread::CancelPoint();
+
         fClient.ProcessFrame(i++, (byte*)fImg, &fTime);
         // usleep(10000);
@@ -155,9 +146,8 @@
         // else exit();
         fTime.tv_sec += 1;
-        usleep(1000);
+        Sleep(1000);
     }
 
-
-    fIsRunning = 0;
+    return 0;
 }
 
Index: trunk/MagicSoft/Cosy/videodev/PngReader.h
===================================================================
--- trunk/MagicSoft/Cosy/videodev/PngReader.h	(revision 8856)
+++ trunk/MagicSoft/Cosy/videodev/PngReader.h	(revision 8859)
@@ -1,24 +1,16 @@
-#ifndef PngReader_H
-#define PngReader_H
+#ifndef COSY_PngReader
+#define COSY_PngReader
 
-#ifdef __CINT__
-typedef unsigned long int pthread_t;
-struct pthread_mutex_t;
-struct pthread_cond_t;
-struct timeval;
-#else
-#include <TROOT.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/time.h>
+#ifndef MARS_MThread
+#include "MThread.h"
 #endif
 
+#ifndef COSY_PixGetter
 #include "PixGetter.h"
+#endif
 
 class PixClient;
 
-typedef unsigned char byte;
-
-class PngReader : public PixGetter
+class PngReader : public PixGetter, public MThread
 {
 private:
@@ -30,7 +22,4 @@
     static const int gfDepth = 3;
 
-    int fStop;
-    int fIsRunning;
-
     //
     // Thread interface
@@ -40,6 +29,4 @@
     char fImg[gfCols*gfRows];
     struct timeval fTime;
-
-    pthread_t fThread;
 
     PixClient &fClient;
@@ -53,6 +40,5 @@
     // Execution thread which processes the pictures
     //
-    void Thread();
-    static void *MapThread(void *arg);
+    Int_t Thread();
 
 public:
@@ -60,18 +46,5 @@
     virtual ~PngReader();
 
-    //
-    // Starts, stops the execution
-    //
-    void ExitLoop()
-    {
-        fStop = 1;
-        while (IsRunning())
-            usleep(1);
-    }
-
-    //
-    // flag if the execution is running or not
-    //
-    int IsRunning() const { return fIsRunning; }
+    void ExitLoop() { CancelThread(); }
 
     ClassDef(PngReader, 0)
