libcvd-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcvd-members] libcvd cvd/Linux/dvbuffer.h cvd_src/Linux/dvbuf...


From: Georg Klein
Subject: [libcvd-members] libcvd cvd/Linux/dvbuffer.h cvd_src/Linux/dvbuf...
Date: Tue, 29 Jan 2008 14:43:20 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    libcvd
Changes by:     Georg Klein <georgklein>        08/01/29 14:43:20

Modified files:
        cvd/Linux      : dvbuffer.h 
        cvd_src/Linux  : dvbuffer.cc 

Log message:
        Replaced some more DVBuffer constructor exit()s with exceptions

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/Linux/dvbuffer.h?cvsroot=libcvd&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/Linux/dvbuffer.cc?cvsroot=libcvd&r1=1.13&r2=1.14

Patches:
Index: cvd/Linux/dvbuffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/Linux/dvbuffer.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- cvd/Linux/dvbuffer.h        31 Mar 2006 16:58:04 -0000      1.18
+++ cvd/Linux/dvbuffer.h        29 Jan 2008 14:43:20 -0000      1.19
@@ -69,9 +69,9 @@
                /// @ingroup gException
                struct DeviceOpen: public All {DeviceOpen(std::string dev); 
///< Construct from the device name
                };
-               /// Error setting up the device
+               /// Error doing some later setup action
                /// @ingroup gException
-               struct DeviceSetup: public All {DeviceSetup(std::string dev, 
std::string action);  ///< Construct from the device string and an error string
+               struct DeviceSetup: public All {DeviceSetup(std::string 
action);  ///< Construct from some action string
                };
                /// Error in a put_frame() call
                /// @ingroup gException

Index: cvd_src/Linux/dvbuffer.cc
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/Linux/dvbuffer.cc,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- cvd_src/Linux/dvbuffer.cc   25 May 2006 12:33:24 -0000      1.13
+++ cvd_src/Linux/dvbuffer.cc   29 Jan 2008 14:43:20 -0000      1.14
@@ -21,8 +21,8 @@
 /**************************************************************************
 **       Title: grab one gray image using libdc1394
 **    $RCSfile: dvbuffer.cc,v $
-**   $Revision: 1.13 $$Name:  $
-**       $Date: 2006/05/25 12:33:24 $
+**   $Revision: 1.14 $$Name:  $
+**       $Date: 2008/01/29 14:43:20 $
 **   Copyright: LGPL $Author: georgklein $
 ** Description:
 **
@@ -32,6 +32,9 @@
 **-------------------------------------------------------------------------
 **
 **  $Log: dvbuffer.cc,v $
+**  Revision 1.14  2008/01/29 14:43:20  georgklein
+**  Replaced some more DVBuffer constructor exit()s with exceptions
+**
 **  Revision 1.13  2006/05/25 12:33:24  georgklein
 **  Highly dubious fix without which my DVBuffer doesn't work (??)
 **
@@ -143,7 +146,6 @@
        what = "DVBuffer2 (in camera setup): " + action;// + ": " + 
strerror(errno);
 }
 
-
 Exceptions::DVBuffer::BadCameraSelection::BadCameraSelection(int nc, int cn)
 {
        ostringstream o;
@@ -174,6 +176,11 @@
              "\n";
 }
 
+Exceptions::DVBuffer::DeviceSetup::DeviceSetup(string action)
+{
+  what = "DVBuffer2 (in setup): Failed on " + action + ": " + strerror(errno);
+}
+
 namespace DC
 {
        const double cam_type<yuv411>::fps = 30;
@@ -571,10 +578,6 @@
   if ( (my_fd = open(dma_device_file,O_RDONLY)) < 0 )
        throw Exceptions::DVBuffer::DeviceOpen(dma_device_file);
  
-  //TODO Finish putting in exceptions
-  //then move this to the end of this function
-  holder.clear();
-
   vmmap.syncronization_tag= 1;
   vmmap.num_buffers= num_dma_buffers;
   vmmap.capture_flags= SYNC_FRAMES;
@@ -583,10 +586,8 @@
 
   /* tell the video1394 system that we want to listen to the given channel */
   if (ioctl(my_fd, LISTEN_CHANNEL, &vmmap) < 0) {
-    cerr << "LISTEN_CHANNEL ioctl failed!" << endl;
     tom_dc1394_dma_release_camera(my_handle,my_ring_buffer, 
my_frame_size*my_num_buffers, my_fd);
-    raw1394_destroy_handle(my_handle);
-    exit(1);
+    throw Exceptions::DVBuffer::DeviceSetup("LISTEN_CHANNEL ioctl");
   }
   
   my_frame_size= vmmap.buffer_size;
@@ -598,11 +599,9 @@
     vwait.buffer= i;
     
     if (ioctl(my_fd,LISTEN_QUEUE_BUFFER,&vwait) < 0) {
-      cerr << "LISTEN_QUEUE_BUFFER ioctl failed!" << endl;
       ioctl(my_fd, UNLISTEN_CHANNEL, &(vwait.channel_number));
       tom_dc1394_dma_release_camera(my_handle,my_ring_buffer, 
my_frame_size*my_num_buffers, my_fd);
-      raw1394_destroy_handle(my_handle);
-      exit(1);
+      throw Exceptions::DVBuffer::DeviceSetup("LISTEN_QUEUE_BUFFER ioctl");
     }  
   }
     
@@ -611,13 +610,12 @@
 
   // make sure the ring buffer was allocated
   if (my_ring_buffer == (unsigned char*)(-1)) {
-    cerr << "mmap failed!" << endl;
     ioctl(my_fd, UNLISTEN_CHANNEL, &vmmap.channel_number);
     tom_dc1394_dma_release_camera(my_handle,my_ring_buffer, 
my_frame_size*my_num_buffers, my_fd);
-    raw1394_destroy_handle(my_handle);
-    exit(1);
+    throw Exceptions::DVBuffer::DeviceSetup("mmap");
   }
 
+
   // camera_dma_buffer_size= vmmap.buffer_size * vmmap.num_buffers;
 
   // set trigger mode
@@ -651,13 +649,14 @@
 
   // this call is OK
   if (dc1394_start_iso_transmission(my_handle,my_node)!=DC1394_SUCCESS) {
-    fprintf( stderr, "unable to start RawDCVideo iso transmission\n");
     tom_dc1394_dma_release_camera(my_handle,my_ring_buffer, 
my_frame_size*my_num_buffers, my_fd);
-    raw1394_destroy_handle(my_handle);
-    exit(1);
+    throw Exceptions::DVBuffer::DC1394Setup("DC1394_start_iso_transmission");
   } else {
     fprintf( stderr, "started iso transmisssion\n");
   }
+
+  holder.clear();
+
 }
 
 VideoFrame<byte>* DC::RawDCVideo::get_frame(){




reply via email to

[Prev in Thread] Current Thread [Next in Thread]