[aravis] camera: strip multiple separators in chunk list



commit 119286288289ecb1870fb4a2c410da046e7fac0c
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Wed Aug 20 22:58:49 2014 +0200

    camera: strip multiple separators in chunk list

 src/arvcamera.c       |   10 ++++++++--
 src/arvchunkparser.h  |    3 ++-
 tests/arvcameratest.c |    9 ++++++++-
 3 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/src/arvcamera.c b/src/arvcamera.c
index 0ff670e..95b7eb7 100644
--- a/src/arvcamera.c
+++ b/src/arvcamera.c
@@ -50,6 +50,7 @@
 #include <arvgc.h>
 #include <arvdevice.h>
 #include <arvenums.h>
+#include <arvstr.h>
 
 /**
  * ArvCameraVendor:
@@ -1385,6 +1386,7 @@ void
 arv_camera_set_chunks (ArvCamera *camera, const char *chunk_list)
 {
        char **chunks;
+       char *striped_chunk_list;
        gboolean enable_chunk_data = FALSE;
        int i;
        guint n_values;
@@ -1398,10 +1400,14 @@ arv_camera_set_chunks (ArvCamera *camera, const char *chunk_list)
 
        chunks = (char **) arv_device_get_available_enumeration_feature_values_as_strings 
(camera->priv->device,
                                                                                           "ChunkSelector", 
&n_values);
-       for (i = 0; i < n_values; i++)
+       for (i = 0; i < n_values; i++) {
                arv_camera_set_chunk_state (camera, chunks[i], FALSE);
+       }
 
-       chunks = g_strsplit_set (chunk_list, " ,:;", -1);
+       striped_chunk_list = g_strdup (chunk_list);
+       arv_str_strip (striped_chunk_list, " ,:;", ',');
+       chunks = g_strsplit_set (striped_chunk_list, " ,:;", -1);
+       g_free (striped_chunk_list);
 
        for (i = 0; chunks[i] != NULL; i++) {
                arv_camera_set_chunk_state (camera, chunks[i], TRUE);
diff --git a/src/arvchunkparser.h b/src/arvchunkparser.h
index fd2a20d..4b37cf7 100644
--- a/src/arvchunkparser.h
+++ b/src/arvchunkparser.h
@@ -41,7 +41,8 @@ typedef enum {
        ARV_CHUNK_PARSER_STATUS_UNKNOWN = -1,
        ARV_CHUNK_PARSER_STATUS_SUCCESS =  0,
        ARV_CHUNK_PARSER_STATUS_BUFFER_NOT_FOUND,
-       ARV_CHUNK_PARSER_STATUS_CHUNK_NOT_FOUND
+       ARV_CHUNK_PARSER_STATUS_CHUNK_NOT_FOUND,
+       ARV_CHUNK_PARSER_STATUS_INVALID_FEATURE_NAME
 } ArvChunkParserStatus;
 
 #define ARV_TYPE_CHUNK_PARSER             (arv_chunk_parser_get_type ())
diff --git a/tests/arvcameratest.c b/tests/arvcameratest.c
index 82de8ef..cf8f3de 100644
--- a/tests/arvcameratest.c
+++ b/tests/arvcameratest.c
@@ -1,4 +1,5 @@
 #include <arv.h>
+#include <arvstr.h>
 #include <stdlib.h>
 #include <signal.h>
 #include <stdio.h>
@@ -217,7 +218,13 @@ main (int argc, char **argv)
                guint software_trigger_source = 0;
 
                if (arv_option_chunks != NULL) {
-                       data.chunks = g_strsplit_set (arv_option_chunks, " ,:;", -1);
+                       char *striped_chunks;
+
+                       striped_chunks = g_strdup (arv_option_chunks);
+                       arv_str_strip (striped_chunks, " ,:;", ',');
+                       data.chunks = g_strsplit_set (striped_chunks, ",", -1);
+                       g_free (striped_chunks);
+
                        data.chunk_parser = arv_camera_create_chunk_parser (camera);
 
                        for (i = 0; data.chunks[i] != NULL; i++) {


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