packages feed

simple-firewire 0.1.1 → 0.1.2

raw patch · 2 files changed

+15/−15 lines, 2 files

Files

System/Camera/Firewire/Simple.hs view
@@ -22,7 +22,7 @@                                     -- * Setting up the context, cameras and the transmission                 , getCameras -                , getDC1394 +                , withDC1394                  , startVideoTransmission                  , stopVideoTransmission                  , stopCapture @@ -68,7 +68,7 @@ -- | Get list of available cameras getCameras :: DC1394 -> IO [CameraId] getCameras dc = -            withDC1394 dc $ \c_dc ->+            withDCPtr dc $ \c_dc ->             alloca $ \list        -> bracket                 (checking $ c'dc1394_camera_enumerate c_dc list)                (\_ -> peek list >>= c'dc1394_camera_free_list)@@ -76,7 +76,7 @@  -- | Grab a frame from the camera. Currently does only 640x480 RGB D8 Images. getFrame :: Camera -> IO (Maybe (Image RGB D8))-getFrame camera' = alloca $ \(framePtr :: Ptr (Ptr (C'dc1394video_frame_t))) ->+getFrame camera' = alloca $ \(framePtr :: Ptr (Ptr C'dc1394video_frame_t)) ->                     withCameraPtr camera' $ \camera -> do      mode <- getMode camera@@ -119,26 +119,27 @@ cameraFromID :: DC1394 -> CameraId -> IO Camera cameraFromID dc e = do     let guid = c'dc1394camera_id_t'guid e-    camera <- withDC1394 dc $ \c_dc -> c'dc1394_camera_new c_dc guid+    camera <- withDCPtr dc $ \c_dc -> c'dc1394_camera_new c_dc guid     when (camera==nullPtr) $ error "Could not create camera"     Camera <$> newForeignPtr camera (c'dc1394_camera_free camera)     -- #TODO What else should be cleaned up? -withCameraPtr (Camera fptr) op = withForeignPtr fptr op+withCameraPtr (Camera fptr) = withForeignPtr fptr withCamera    (Camera fptr) op = withForeignPtr fptr (\ptr -> peek ptr >>= op)  -- | DC1394 context used for creating cameras, etc.-newtype DC1394 = DC1394 (ForeignPtr C'dc1394_t)+newtype DC1394 = DC1394 (Ptr C'dc1394_t)  -- | Create a new DC1394 context-getDC1394 :: IO DC1394-getDC1394 = do-    dc <- c'dc1394_new -    when (dc==nullPtr) $ error "Could not get dc1394 context"-    DC1394 <$> newForeignPtr dc (c'dc1394_free dc)+withDC1394 :: (DC1394 -> IO a) -> IO a+withDC1394 op = bracket +               c'dc1394_new+               c'dc1394_free+               (\dc -> when (dc==nullPtr) (error "Could not get dc1394 context")+                       >> op (DC1394 dc))  -withDC1394 :: DC1394 -> (Ptr C'dc1394_t -> IO b) -> IO b-withDC1394 (DC1394 fptr) op = withForeignPtr fptr op+withDCPtr :: DC1394 -> (Ptr C'dc1394_t -> IO b) -> IO b+withDCPtr (DC1394 ptr) op = op ptr  -- | Set the video transmission on startVideoTransmission :: Camera -> IO ()
simple-firewire.cabal view
@@ -1,5 +1,5 @@ Name:                simple-firewire-Version:             0.1.1+Version:             0.1.2 Synopsis:            Simplified interface for firewire cameras Description:         A simplified interface for firewire cameras based on libdc1394 <http://damien.douxchamps.net/ieee1394/libdc1394/>                      .@@ -7,7 +7,6 @@                      provides both plain IO based interface for                      controlling the cameras.                      .-                      .                      The interface will most likely change in the future. Homepage:            https://github.com/aleator/simple-firewire