-
Notifications
You must be signed in to change notification settings - Fork 34
Check if ASR grammars exist before access #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
a495ce7
937dd9a
a231761
7c5cef3
789a6f6
39c3b5e
6aaca77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1459,7 +1459,7 @@ static const char *speech_channel_type_to_string(speech_channel_type_t type) | |||||
static switch_status_t speech_channel_set_param(speech_channel_t *schannel, const char *param, const char *val) | ||||||
{ | ||||||
switch_mutex_lock(schannel->mutex); | ||||||
if (!zstr(param) && val != NULL) { | ||||||
if (!zstr(param) && val != NULL && schannel->params) { | ||||||
/* check if this is a FreeSWITCH param that needs to be translated to an MRCP param: e.g. voice ==> voice-name */ | ||||||
const char *v; | ||||||
const char *p = switch_core_hash_find(schannel->application->fs_param_map, param); | ||||||
|
@@ -2428,8 +2428,8 @@ static switch_status_t recog_channel_load_grammar(speech_channel_t *schannel, co | |||||
} | ||||||
|
||||||
/* Create the grammar and save it */ | ||||||
if ((status = grammar_create(&g, name, type, data, schannel->memory_pool)) == SWITCH_STATUS_SUCCESS) { | ||||||
recognizer_data_t *r = (recognizer_data_t *) schannel->data; | ||||||
recognizer_data_t *r = (recognizer_data_t *) schannel->data; | ||||||
if (r->grammars && (status = grammar_create(&g, name, type, data, schannel->memory_pool)) == SWITCH_STATUS_SUCCESS) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. grammars get destroyed in Line 3429 in 5eaae25
then used in Line 2433 in 5eaae25
so we check if exists in below cases same for |
||||||
switch_core_hash_insert(r->grammars, g->name, g); | ||||||
} | ||||||
|
||||||
|
@@ -2459,8 +2459,12 @@ static switch_status_t recog_channel_unload_grammar(speech_channel_t *schannel, | |||||
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) Unloading grammar %s\n", schannel->name, grammar_name); | ||||||
|
||||||
switch_mutex_lock(schannel->mutex); | ||||||
switch_core_hash_delete(r->enabled_grammars, grammar_name); | ||||||
switch_core_hash_delete(r->grammars, grammar_name); | ||||||
if (r->enabled_grammars) { | ||||||
switch_core_hash_delete(r->enabled_grammars, grammar_name); | ||||||
} | ||||||
if (r->grammars) { | ||||||
switch_core_hash_delete(r->grammars, grammar_name); | ||||||
} | ||||||
switch_mutex_unlock(schannel->mutex); | ||||||
} | ||||||
|
||||||
|
@@ -2485,13 +2489,12 @@ static switch_status_t recog_channel_enable_grammar(speech_channel_t *schannel, | |||||
grammar_t *grammar; | ||||||
|
||||||
switch_mutex_lock(schannel->mutex); | ||||||
grammar = (grammar_t *) switch_core_hash_find(r->grammars, grammar_name); | ||||||
if (grammar == NULL) | ||||||
if (r->grammars && (grammar = (grammar_t *) switch_core_hash_find(r->grammars, grammar_name)) == NULL) | ||||||
{ | ||||||
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_ERROR, "(%s) Undefined grammar, %s\n", schannel->name, grammar_name); | ||||||
status = SWITCH_STATUS_FALSE; | ||||||
} | ||||||
else { | ||||||
else if (r->enabled_grammars) { | ||||||
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) Enabling grammar %s\n", schannel->name, grammar_name); | ||||||
switch_core_hash_insert(r->enabled_grammars, grammar_name, grammar); | ||||||
} | ||||||
|
@@ -2519,7 +2522,9 @@ static switch_status_t recog_channel_disable_grammar(speech_channel_t *schannel, | |||||
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) Disabling grammar %s\n", schannel->name, grammar_name); | ||||||
|
||||||
switch_mutex_lock(schannel->mutex); | ||||||
switch_core_hash_delete(r->enabled_grammars, grammar_name); | ||||||
if (r->enabled_grammars) { | ||||||
switch_core_hash_delete(r->enabled_grammars, grammar_name); | ||||||
} | ||||||
switch_mutex_unlock(schannel->mutex); | ||||||
} | ||||||
|
||||||
|
@@ -2534,14 +2539,17 @@ static switch_status_t recog_channel_disable_grammar(speech_channel_t *schannel, | |||||
*/ | ||||||
static switch_status_t recog_channel_disable_all_grammars(speech_channel_t *schannel) | ||||||
{ | ||||||
switch_status_t status = SWITCH_STATUS_SUCCESS; | ||||||
switch_status_t status = SWITCH_STATUS_FALSE; | ||||||
|
||||||
recognizer_data_t *r = (recognizer_data_t *) schannel->data; | ||||||
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(schannel->session_uuid), SWITCH_LOG_DEBUG, "(%s) Disabling all grammars\n", schannel->name); | ||||||
|
||||||
switch_mutex_lock(schannel->mutex); | ||||||
switch_core_hash_destroy(&r->enabled_grammars); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
switch_core_hash_init(&r->enabled_grammars); | ||||||
if (r->enabled_grammars) { | ||||||
switch_core_hash_destroy(&r->enabled_grammars); | ||||||
switch_core_hash_init(&r->enabled_grammars); | ||||||
status = SWITCH_STATUS_SUCCESS; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so that we omit Line 3324 in 5eaae25
|
||||||
} | ||||||
switch_mutex_unlock(schannel->mutex); | ||||||
|
||||||
return status; | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get's destroyed in
speech_channel_destroy
mod_unimrcp/mod_unimrcp.c
Line 949 in 5eaae25
then used in
mod_unimrcp/mod_unimrcp.c
Line 1471 in 5eaae25
below core dump