Use g_strv_contains() to search string in string array 90/240490/3
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 7 Aug 2020 00:57:21 +0000 (09:57 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 7 Aug 2020 06:45:12 +0000 (15:45 +0900)
[Version] 0.1.108
[Issue Type] Improvement

Change-Id: Ia6043058809f68138cf10ba27b4e16945796b7f5
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/capi-media-streamer.spec
src/media_streamer_util.c

index 8beba1a..d4175a1 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-streamer
 Summary:    A Media Streamer API
-Version:    0.1.107
+Version:    0.1.108
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index d871ac5..5c800c3 100644 (file)
@@ -296,9 +296,7 @@ const gchar *ms_convert_audio_mime_to_string_format(media_format_mimetype_e mime
 const gchar *ms_convert_video_mime_to_string_format(media_format_mimetype_e mime, const char *node_name)
 {
        const gchar *format_name = NULL;
-       int index;
        gboolean use_zerocopy_fmt = DEFAULT_USE_ZEROCOPY;
-       gboolean need_to_check_zerocopy_format = FALSE;
 
        ms_retvm_if(node_name == NULL, NULL, "node_name is null");
 
@@ -307,38 +305,31 @@ const gchar *ms_convert_video_mime_to_string_format(media_format_mimetype_e mime
                gchar **zerocopy_node_names = NULL;
                ms_ini_read_list("general:zerocopy node names", &zerocopy_node_names);
 
-               for (index = 0; zerocopy_node_names && zerocopy_node_names[index]; index++) {
-                       if (!strcmp(node_name, zerocopy_node_names[index])) {
-                               need_to_check_zerocopy_format = TRUE;
-                               ms_debug("node_name[%s] can use zerocopy format", node_name);
-                               break;
-                       }
-               }
-               g_strfreev(zerocopy_node_names);
-       }
+               if (zerocopy_node_names && g_strv_contains((const gchar * const *)zerocopy_node_names, node_name)) {
+                       ms_debug("node_name[%s] can use zerocopy format", node_name);
 
-       if (need_to_check_zerocopy_format) {
-               format_name = __ms_find_item(zerocopy_video_format_table, mime);
-               if (format_name) {
-                       gchar **zerocopy_formats = NULL;
-                       ms_ini_read_list("general:zerocopy formats", &zerocopy_formats);
+                       format_name = __ms_find_item(zerocopy_video_format_table, mime);
+                       if (format_name) {
+                               gchar **zerocopy_formats = NULL;
+                               ms_ini_read_list("general:zerocopy formats", &zerocopy_formats);
 
-                       for (index = 0; zerocopy_formats && zerocopy_formats[index]; index++) {
-                               if (!strcmp(format_name, zerocopy_formats[index])) {
+                               if (zerocopy_formats && g_strv_contains((const gchar * const *)zerocopy_formats, format_name)) {
                                        ms_info("mimetype[0x%x] -> zerocopy format[%s]", mime, format_name);
                                        g_strfreev(zerocopy_formats);
                                        return format_name;
                                }
+
+                               g_strfreev(zerocopy_formats);
+                               ms_debug("[%s] is not supported in this target", format_name);
+                       } else {
+                               ms_debug("Not supported this mimetype[0x%x] for zerocopy", mime);
                        }
-                       g_strfreev(zerocopy_formats);
-                       ms_debug("[%s] is not supported in this target", format_name);
-               } else {
-                       ms_debug("Not supported this mimetype[0x%x] for zerocopy", mime);
                }
+
+               g_strfreev(zerocopy_node_names);
        }
 
        format_name = __ms_find_item(video_format_table, mime);
-
        if (!format_name)
                ms_warning("Not supported this mimetype[0x%x]", mime);
        else