From 8a90741aa6ec13a40466777c7b8832343c2e0e46 Mon Sep 17 00:00:00 2001 From: Leandro Dorileo Date: Wed, 7 Jan 2015 16:20:04 -0200 Subject: [PATCH] dlna: don't match if no profile/level identified Instead of providing an empty string for profile and level if we haven't parsed one from codec identifier initialize it to NULL and only use it to match the rules if we found the respective identifiers. --- src/lib/lightmediascanner_dlna.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/lib/lightmediascanner_dlna.c b/src/lib/lightmediascanner_dlna.c index 0548c8e..764a207 100644 --- a/src/lib/lightmediascanner_dlna.c +++ b/src/lib/lightmediascanner_dlna.c @@ -194,12 +194,12 @@ _video_rule_match_stream(const struct lms_dlna_video_rule *rule, video->video.bitrate <= rule->bitrate->max)) return false; - if (rule->levels && + if (rule->levels && level && !_string_vector_has_value ((const char **)rule->levels->levels, level)) return false; - if (rule->profiles && + if (rule->profiles && profile && !_string_vector_has_value ((const char **)rule->profiles->profiles, profile)) return false; @@ -221,19 +221,17 @@ _match_video_profile(const struct lms_dlna_video_profile *video_rules, int i; const struct lms_dlna_video_profile *curr; char *tmp, *p; - const char *profile, *level; + const char *profile = NULL, *level = NULL; tmp = strdupa(video->codec.str); p = strstr(tmp, "-p"); - if (!p) profile = ""; - else { + if (p) { p[0] = '\0'; profile = p + 2; } p = strstr(profile, "-l"); - if (!p) level = ""; - else { + if (p) { p[0] = '\0'; level = p + 2; } -- 2.7.4