]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Suppress spurious warning in phrase macro playback
authorTravis Cross <tc@traviscross.com>
Wed, 9 Apr 2014 04:48:09 +0000 (04:48 +0000)
committerTravis Cross <tc@traviscross.com>
Wed, 9 Apr 2014 05:30:33 +0000 (05:30 +0000)
Prior to this commit, if anything at all went wrong in
switch_ivr_phrase_macro_event() we would generate a warning like this:

  [WARNING] switch_ivr_play_say.c:348 Macro [macro_name]: 'pattern_name' did not match any patterns

This is clearly misleading.  The natural thing to do on seeing that
message is to verify that the language files are there, and that the
pattern really does exist in that macro.  But none of that was usually
the problem.  The message would be generated if the language wasn't
found, or if the channel had gone away, for example.

With this commit, we verify that we actually tried looking for the
pattern before displaying the warning about the pattern not matching.

src/switch_ivr_play_say.c

index 690e8a2cbaa42fb77ae18677cfe9acb632fe4de8..3313b8c714f18da402b03b7b4173a020fc7ed5b8 100644 (file)
@@ -45,7 +45,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro_event(switch_core_sessio
        const char *old_sound_prefix = NULL, *sound_path = NULL, *tts_engine = NULL, *tts_voice = NULL;
        const char *module_name = NULL, *chan_lang = NULL;
        switch_channel_t *channel = switch_core_session_get_channel(session);
-       uint8_t done = 0;
+       uint8_t done = 0, searched = 0;
        int matches = 0;
        const char *pause_val;
        int pause = 100;
@@ -178,6 +178,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro_event(switch_core_sessio
                char *field_expanded = NULL;
                char *field_expanded_alloc = NULL;
 
+               searched = 1;
                if (!field) {
                        field = (char *) data;
                }
@@ -344,7 +345,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro_event(switch_core_sessio
                switch_event_destroy(&hint_data);
        }
 
-       if (!matches) {
+       if (searched && !matches) {
                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Macro [%s]: '%s' did not match any patterns\n", macro_name, data);
        }