From 9d4f8e270d27556f277a14c567d516b3c090a027 Mon Sep 17 00:00:00 2001
From: Matthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>
Date: Mon, 28 Feb 2011 16:44:41 +0100
Subject: Move buffer allocation to frame grabber

---
 src/cameras/pco.c  |  5 -----
 src/grabbers/me4.c |  4 ++--
 src/uca-cam.c      |  8 +++++++-
 src/uca-cam.h      | 11 +++--------
 src/uca-grabber.h  |  4 ++--
 5 files changed, 14 insertions(+), 18 deletions(-)

(limited to 'src')

diff --git a/src/cameras/pco.c b/src/cameras/pco.c
index a556614..2547387 100644
--- a/src/cameras/pco.c
+++ b/src/cameras/pco.c
@@ -173,10 +173,6 @@ static uint32_t uca_pco_get_property(struct uca_camera_t *cam, enum uca_property
     return UCA_NO_ERROR;
 }
 
-uint32_t uca_pco_alloc(struct uca_camera_t *cam, uint32_t n_buffers)
-{
-
-}
 
 uint32_t uca_pco_init(struct uca_camera_t **cam, struct uca_grabber_t *grabber)
 {
@@ -199,7 +195,6 @@ uint32_t uca_pco_init(struct uca_camera_t **cam, struct uca_grabber_t *grabber)
     uca->destroy = &uca_pco_destroy;
     uca->set_property = &uca_pco_set_property;
     uca->get_property = &uca_pco_get_property;
-    uca->alloc = &uca_pco_alloc;
     uca->acquire_image = &uca_pco_acquire_image;
 
     /* Prepare camera for recording */
diff --git a/src/grabbers/me4.c b/src/grabbers/me4.c
index c879dfd..54ac060 100644
--- a/src/grabbers/me4.c
+++ b/src/grabbers/me4.c
@@ -30,7 +30,7 @@ uint32_t uca_me4_get_property(struct uca_grabber_t *grabber, enum uca_property_i
     return Fg_getParameter(GET_FG(grabber), property, data, PORT_A) == FG_OK ? UCA_NO_ERROR : UCA_ERR_PROP_GENERAL;
 }
 
-uint32_t uca_me4_allocate(struct uca_grabber_t *grabber, uint32_t n_buffers)
+uint32_t uca_me4_alloc(struct uca_grabber_t *grabber, uint32_t n_buffers)
 {
     if (GET_MEM(grabber) != NULL)
         /* FIXME: invent better error code */
@@ -59,7 +59,7 @@ uint32_t uca_me4_init(struct uca_grabber_t **grabber)
     uca->destroy = &uca_me4_destroy;
     uca->set_property = &uca_me4_set_property;
     uca->get_property = &uca_me4_get_property;
-    uca->allocate = &uca_me4_allocate;
+    uca->alloc = &uca_me4_alloc;
     
     *grabber = uca;
     return UCA_NO_ERROR;
diff --git a/src/uca-cam.c b/src/uca-cam.c
index 2618b84..b77d62b 100644
--- a/src/uca-cam.c
+++ b/src/uca-cam.c
@@ -2,8 +2,14 @@
 #include <stdlib.h>
 #include "uca.h"
 #include "uca-cam.h"
+#include "uca-grabber.h"
 
-enum uca_cam_state uca_get_camera_state(struct uca_camera_t *cam)
+uint32_t uca_cam_alloc(struct uca_camera_t *cam, uint32_t n_buffers)
+{
+    cam->grabber->alloc(cam->grabber, n_buffers);
+}
+
+enum uca_cam_state uca_cam_get_state(struct uca_camera_t *cam)
 {
     return cam->state;
 }
diff --git a/src/uca-cam.h b/src/uca-cam.h
index aacd5c3..9f0c057 100644
--- a/src/uca-cam.h
+++ b/src/uca-cam.h
@@ -12,7 +12,9 @@ enum uca_property_ids;
 /*
  * --- non-virtual methods ----------------------------------------------------
  */
-enum uca_cam_state uca_get_camera_state(struct uca_camera_t *cam);
+uint32_t uca_cam_alloc(struct uca_camera_t *cam, uint32_t n_buffers);
+
+enum uca_cam_state uca_cam_get_state(struct uca_camera_t *cam);
 
 
 /*
@@ -45,12 +47,6 @@ typedef uint32_t (*uca_cam_set_property) (struct uca_camera_t *cam, enum uca_pro
  */
 typedef uint32_t (*uca_cam_get_property) (struct uca_camera_t *cam, enum uca_property_ids property, void *data);
 
-/** \brief Allocate number of buffers
- *
- * The size of each buffer is width x height x bits
- */
-typedef uint32_t (*uca_cam_alloc) (struct uca_camera_t *cam, uint32_t n_buffers);
-
 /**
  * \brief Acquire one frame
  */
@@ -72,7 +68,6 @@ struct uca_camera_t {
     uca_cam_set_property    set_property;
     uca_cam_get_property    get_property;
     uca_cam_acquire_image   acquire_image;
-    uca_cam_alloc           alloc;
 
     /* Private */
     uca_cam_destroy         destroy;
diff --git a/src/uca-grabber.h b/src/uca-grabber.h
index 3c48681..0ae229d 100644
--- a/src/uca-grabber.h
+++ b/src/uca-grabber.h
@@ -35,7 +35,7 @@ typedef uint32_t (*uca_grabber_get_property) (struct uca_grabber_t *grabber, enu
  * \brief Allocate buffers with current width, height and bitdepth
  * \note Subsequent changes of width and height might corrupt memory
  */
-typedef uint32_t (*uca_grabber_allocate) (struct uca_grabber_t *grabber, uint32_t n_buffers);
+typedef uint32_t (*uca_grabber_alloc) (struct uca_grabber_t *grabber, uint32_t n_buffers);
 
 
 
@@ -46,7 +46,7 @@ struct uca_grabber_t {
     uca_grabber_destroy      destroy;
     uca_grabber_set_property set_property;
     uca_grabber_get_property get_property;
-    uca_grabber_allocate     allocate;
+    uca_grabber_alloc        alloc;
 
     /* Private */
     void *user;
-- 
cgit v1.2.3