aboutsummaryrefslogtreecommitdiff
path: root/src/ui/new_contact.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/new_contact.c')
-rw-r--r--src/ui/new_contact.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/ui/new_contact.c b/src/ui/new_contact.c
index 5a74089..c193629 100644
--- a/src/ui/new_contact.c
+++ b/src/ui/new_contact.c
@@ -147,6 +147,28 @@ render_image:
147 return FALSE; 147 return FALSE;
148} 148}
149 149
150static void
151_disable_video_processing(UI_NEW_CONTACT_Handle *handle)
152{
153 if (!(handle->video))
154 return;
155
156 const zbar_error_t error_code = zbar_video_get_error_code(handle->video);
157
158 if (ZBAR_OK != error_code)
159 {
160 const char *error_msg = zbar_video_error_string(handle->video, 0);
161
162 if (error_msg)
163 fprintf(stderr, "%s", error_msg);
164 else
165 fprintf(stderr, "ERROR: Unknown error with zbar (%d)\n",
166 (int) error_code);
167 }
168
169 handle->idle_processing = 0;
170}
171
150static gboolean 172static gboolean
151idle_video_processing(gpointer user_data) 173idle_video_processing(gpointer user_data)
152{ 174{
@@ -158,7 +180,10 @@ idle_video_processing(gpointer user_data)
158 zbar_image_t *image = zbar_video_next_image(handle->video); 180 zbar_image_t *image = zbar_video_next_image(handle->video);
159 181
160 if (!image) 182 if (!image)
161 return TRUE; 183 {
184 _disable_video_processing(handle);
185 return FALSE;
186 }
162 187
163 GString *scan_result = NULL; 188 GString *scan_result = NULL;
164 189
@@ -226,10 +251,16 @@ _ui_new_contact_video_thread(void *args)
226 UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) args; 251 UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) args;
227 252
228 if (0 != zbar_video_open(handle->video, "")) 253 if (0 != zbar_video_open(handle->video, ""))
254 {
255 _disable_video_processing(handle);
229 return NULL; 256 return NULL;
257 }
230 258
231 if (0 != zbar_video_enable(handle->video, 1)) 259 if (0 != zbar_video_enable(handle->video, 1))
260 {
261 _disable_video_processing(handle);
232 return NULL; 262 return NULL;
263 }
233 264
234 zbar_image_scanner_set_config( 265 zbar_image_scanner_set_config(
235 handle->scanner, 266 handle->scanner,