emotion: fix webcam detection.
authorcedric <cedric>
Wed, 3 Aug 2011 14:23:51 +0000 (14:23 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 3 Aug 2011 14:23:51 +0000 (14:23 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/emotion@62054 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/Emotion.h
src/lib/emotion_main.c

index 812e5df..198f26a 100644 (file)
@@ -843,9 +843,11 @@ EAPI Eina_Bool    emotion_object_extension_may_play_get(const char *file);
 
 typedef struct _Emotion_Webcam Emotion_Webcam;
 
+extern int EMOTION_WEBCAM_UPDATE;
+
 EAPI const Eina_List *emotion_webcams_get(void);
-EAPI const char      *emotion_webcam_name_get(Emotion_Webcam *ew);
-EAPI const char      *emotion_webcam_device_get(Emotion_Webcam *ew);
+EAPI const char      *emotion_webcam_name_get(const Emotion_Webcam *ew);
+EAPI const char      *emotion_webcam_device_get(const Emotion_Webcam *ew);
 
 /**
  * @}
index 9154ffc..f25fa37 100644 (file)
@@ -124,6 +124,8 @@ struct _Emotion_Webcam
    const char *syspath;
    const char *device;
    const char *name;
+
+   const char *filename;
 };
 
 static int _emotion_webcams_count = 0;
@@ -150,8 +152,8 @@ _emotion_check_device(Emotion_Webcam *ew)
    if (!ew) return ;
    if (!ew->device) goto on_error;
 
-   fd = open(ew->device, O_RDONLY);
-   if (!fd) goto on_error;
+   fd = open(ew->filename, O_RDONLY);
+   if (fd < 0) goto on_error;
 
    if (ioctl(fd, VIDIOC_QUERYCAP, &caps) == -1) goto on_error;
 
@@ -173,7 +175,7 @@ _emotion_check_device(Emotion_Webcam *ew)
    return ;
 
  on_error:
-   fprintf(stderr, "'%s' is not a webcam\n", ew->name);
+   fprintf(stderr, "'%s' is not a webcam ['%s']\n", ew->name, strerror(errno));
    eina_stringshare_del(ew->syspath);
    eina_stringshare_del(ew->device);
    eina_stringshare_del(ew->name);
@@ -198,6 +200,7 @@ _emotion_webcam_new(const char *syspath)
    snprintf(local, eina_stringshare_strlen(device) + 8, "v4l2://%s", device);
    test->device = eina_stringshare_add(local);
    eina_stringshare_del(device);
+   test->filename = test->device + 7;
 
    return test;
 }
@@ -303,7 +306,7 @@ emotion_webcams_get(void)
 }
 
 EAPI const char *
-emotion_webcam_name_get(Emotion_Webcam *ew)
+emotion_webcam_name_get(const Emotion_Webcam *ew)
 {
    if (!ew) return NULL;
 
@@ -315,7 +318,7 @@ emotion_webcam_name_get(Emotion_Webcam *ew)
 }
 
 EAPI const char *
-emotion_webcam_device_get(Emotion_Webcam *ew)
+emotion_webcam_device_get(const Emotion_Webcam *ew)
 {
    if (!ew) return NULL;