get_media_devices: While not too late, change enum definitions
authorMauro Carvalho Chehab <mchehab@redhat.com>
Sat, 28 May 2011 20:53:22 +0000 (17:53 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sat, 28 May 2011 20:58:41 +0000 (17:58 -0300)
Enum definitions like "NONE" and "UNKNOWN" are dangerous, as
they may conflict with something else. So add MEDIA_ prefix
to all enums to avoid it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
utils/libmedia_dev/get_media_devices.c
utils/libmedia_dev/get_media_devices.h
utils/v4l2-sysfs-path/v4l2-sysfs-path.c

index 97202e3..7f3061d 100644 (file)
 #include "get_media_devices.h"
 
 static char *device_type_str[] = {
-       [V4L_VIDEO]     = "video",
-       [V4L_VBI]       = "vbi",
-       [DVB_FRONTEND]  = "dvb frontend",
-       [DVB_DEMUX]     = "dvb demux",
-       [DVB_DVR]       = "dvb dvr",
-       [DVB_NET]       = "dvb net",
-       [DVB_CA]        = "dvb conditional access",
-       [SND_CARD]      = "sound card",
-       [SND_CAP]       = "pcm capture",
-       [SND_OUT]       = "pcm output",
-       [SND_CONTROL]   = "mixer",
-       [SND_HW]        = "sound hardware",
+       [MEDIA_V4L_VIDEO]       = "video",
+       [MEDIA_V4L_VBI] = "vbi",
+       [MEDIA_DVB_FRONTEND]    = "dvb frontend",
+       [MEDIA_DVB_DEMUX]       = "dvb demux",
+       [MEDIA_DVB_DVR] = "dvb dvr",
+       [MEDIA_DVB_NET] = "dvb net",
+       [MEDIA_DVB_CA]  = "dvb conditional access",
+       [MEDIA_SND_CARD]        = "sound card",
+       [MEDIA_SND_CAP] = "pcm capture",
+       [MEDIA_SND_OUT] = "pcm output",
+       [MEDIA_SND_CONTROL]     = "mixer",
+       [MEDIA_SND_HW]  = "sound hardware",
 };
 
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
@@ -199,9 +199,9 @@ error:
 static int add_v4l_class(struct media_device_entry *md)
 {
        if (strstr(md->node, "video"))
-               md->type = V4L_VIDEO;
+               md->type = MEDIA_V4L_VIDEO;
        else if (strstr(md->node, "vbi"))
-               md->type = V4L_VBI;
+               md->type = MEDIA_V4L_VBI;
 
        return 0;
 };
@@ -213,19 +213,19 @@ static int add_snd_class(struct media_device_entry *md)
 
        if (strstr(md->node, "card")) {
                sscanf(md->node, "card%u", &c);
-               md->type = SND_CARD;
+               md->type = MEDIA_SND_CARD;
        } else if (strstr(md->node, "hw")) {
                sscanf(md->node, "hwC%uD%u", &c, &d);
-               md->type = SND_HW;
+               md->type = MEDIA_SND_HW;
        } else if (strstr(md->node, "control")) {
                sscanf(md->node, "controlC%u", &c);
-               md->type = SND_CONTROL;
+               md->type = MEDIA_SND_CONTROL;
        } else if (strstr(md->node, "pcm")) {
                sscanf(md->node, "pcmC%uD%u", &c, &d);
                if (md->node[strlen(md->node) - 1] == 'p')
-                       md->type = SND_OUT;
+                       md->type = MEDIA_SND_OUT;
                else if (md->node[strlen(md->node) - 1] == 'c')
-                       md->type = SND_CAP;
+                       md->type = MEDIA_SND_CAP;
        }
 
        if (c == 65535)
@@ -251,15 +251,15 @@ static int add_snd_class(struct media_device_entry *md)
 static int add_dvb_class(struct media_device_entry *md)
 {
        if (strstr(md->node, "frontend"))
-               md->type = DVB_FRONTEND;
+               md->type = MEDIA_DVB_FRONTEND;
        else if (strstr(md->node, "demux"))
-               md->type = DVB_DEMUX;
+               md->type = MEDIA_DVB_DEMUX;
        else if (strstr(md->node, "dvr"))
-               md->type = DVB_DVR;
+               md->type = MEDIA_DVB_DVR;
        else if (strstr(md->node, "net"))
-               md->type = DVB_NET;
+               md->type = MEDIA_DVB_NET;
        else if (strstr(md->node, "ca"))
-               md->type = DVB_CA;
+               md->type = MEDIA_DVB_CA;
 
        return 0;
 };
index 6d6e2d1..4d7a1f8 100644 (file)
@@ -20,7 +20,7 @@
 /*
  * Version of the API
  */
-#define GET_MEDIA_DEVICES_VERSION      0x0102
+#define GET_MEDIA_DEVICES_VERSION      0x0103
 
 /*
  A typical usecase for the above API is:
@@ -51,24 +51,24 @@ Where alsa_handler() is some function that will need to handle
  *
  * The device_type is used to sort the media devices array.
  * So, the order is relevant. The first device should be
- * V4L_VIDEO.
+ * MEDIA_V4L_VIDEO.
  */
 enum device_type {
        UNKNOWN = 65535,
        NONE    = 65534,
-       V4L_VIDEO = 0,
-       V4L_VBI,
-       DVB_FRONTEND,
-       DVB_DEMUX,
-       DVB_DVR,
-       DVB_NET,
-       DVB_CA,
+       MEDIA_V4L_VIDEO = 0,
+       MEDIA_V4L_VBI,
+       MEDIA_DVB_FRONTEND,
+       MEDIA_DVB_DEMUX,
+       MEDIA_DVB_DVR,
+       MEDIA_DVB_NET,
+       MEDIA_DVB_CA,
        /* TODO: Add dvb full-featured nodes */
-       SND_CARD,
-       SND_CAP,
-       SND_OUT,
-       SND_CONTROL,
-       SND_HW,
+       MEDIA_SND_CARD,
+       MEDIA_SND_CAP,
+       MEDIA_SND_OUT,
+       MEDIA_SND_CONTROL,
+       MEDIA_SND_HW,
 };
 
 /**
@@ -110,7 +110,7 @@ char *media_device_type(enum device_type type);
 void display_media_devices(void *opaque);
 
 /**
- * get_not_associated_device() - Return the next device not associated with
+ * get_associated_device() - Return the next device not associated with
  *                              an specific device type.
  *
  * @opaque:            media devices opaque descriptor
index 8ad0bda..dad2db1 100644 (file)
@@ -35,7 +35,7 @@ static void print_all_associated_devices(void *md, char *vid,
 
        do {
                devname = get_associated_device(md, devname, type,
-                                               vid, V4L_VIDEO);
+                                               vid, MEDIA_V4L_VIDEO);
                if (devname) {
                        if (first) {
                                printf("\t%s: ", media_device_type(type));
@@ -56,7 +56,7 @@ static void print_all_alsa_independent_playback(void *md)
 
        do {
                devname = get_not_associated_device(md, devname,
-                                                   SND_OUT, V4L_VIDEO);
+                                                   MEDIA_SND_OUT, MEDIA_V4L_VIDEO);
                if (devname) {
                        if (first) {
                                printf("Alsa playback device(s): ");
@@ -80,13 +80,13 @@ int main(void)
 
        vid = NULL;
        do {
-               vid = get_associated_device(md, vid, V4L_VIDEO,
+               vid = get_associated_device(md, vid, MEDIA_V4L_VIDEO,
                                                NULL, NONE);
                if (!vid)
                        break;
                printf("Video device: %s\n", vid);
 
-               for (i = 0; i <= SND_HW; i++)
+               for (i = 0; i <= MEDIA_SND_HW; i++)
                        print_all_associated_devices(md, vid, i);
        } while (vid);