From 8d478b91633c9e549cbd51fb6e18428707aa0cc8 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Tue, 22 Mar 2011 12:24:52 +0100 Subject: Fix potential bugs and use generic reorder function --- src/grabbers/me4.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/grabbers/me4.c') diff --git a/src/grabbers/me4.c b/src/grabbers/me4.c index 4c6420e..cc7af2c 100644 --- a/src/grabbers/me4.c +++ b/src/grabbers/me4.c @@ -99,15 +99,17 @@ uint32_t uca_me4_get_property(struct uca_grabber *grabber, enum uca_grabber_cons uint32_t uca_me4_alloc(struct uca_grabber *grabber, uint32_t pixel_size, uint32_t n_buffers) { - if (GET_MEM(grabber) != NULL) - /* FIXME: invent better error code */ - return UCA_ERR_PROP_GENERAL; + dma_mem *mem = GET_MEM(grabber); + /* If buffers are already allocated, we are freeing every buffer and start + * again. */ + if (mem != NULL) + Fg_FreeMemEx(GET_FG(grabber), mem); uint32_t width, height; uca_me4_get_property(grabber, UCA_GRABBER_WIDTH, &width); uca_me4_get_property(grabber, UCA_GRABBER_HEIGHT, &height); - dma_mem *mem = Fg_AllocMemEx(GET_FG(grabber), n_buffers*width*height*pixel_size, n_buffers); + mem = Fg_AllocMemEx(GET_FG(grabber), n_buffers*width*height*pixel_size, n_buffers); if (mem != NULL) { ((struct fg_apc_data *) grabber->user)->mem = mem; return UCA_NO_ERROR; -- cgit v1.2.3