Compare commits

...

3 Commits

Author SHA1 Message Date
Aron Podrigal 98c0f1e4a0
Merge 905200d682 into 5cb74797fe 2025-01-17 16:41:40 +00:00
Aron Podrigal 5cb74797fe
[mod_pgsql] err is now set correctly (dbh:last_error())
New function, `void pgsql_handle_set_error_if_not_set(switch_pgsql_handle_t *handle, char **err)` has been added to mod_pgsql module. This function is now called at several points where an error occurred but *err was not yet set.
2025-01-17 18:51:45 +03:00
Aron Podrigal 905200d682 [mod_conference] Refactor alone sound playback.
- Refactor the handling of "alone sound" playback for conference member directly so it does not get recorded in the conference recording.
- Use a function so it is handled in the same way consistently.
- when set to "none" it is simply disabled.
2025-01-15 14:00:08 -06:00
3 changed files with 46 additions and 13 deletions

View File

@ -714,7 +714,14 @@ switch_status_t conference_member_del_relationship(conference_member_t *member,
return status;
}
switch_status_t conference_member_play_alone_sound(conference_member_t *member)
{
char *sound = member->conference->alone_sound ? member->conference->alone_sound : "say:You are currently the only person in this conference.";
if (!strcasecmp(sound, "none")) {
return SWITCH_STATUS_SUCCESS;
}
return conference_member_play_file(member, sound, 0, SWITCH_TRUE);
}
/* Gain exclusive access and add the member to the list */
switch_status_t conference_member_add(conference_obj_t *conference, conference_member_t *member)
@ -940,15 +947,8 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m
conference_member_say(member, msg, CONF_DEFAULT_LEADIN);
} else if (conference->count == 1 && !conference->perpetual_sound && !conference_utils_test_flag(conference, CFLAG_WAIT_MOD)) {
/* as long as its not a bridge_to conference, announce if person is alone */
if (!conference_utils_test_flag(conference, CFLAG_BRIDGE_TO)) {
if (conference->alone_sound && !conference_utils_member_test_flag(member, MFLAG_GHOST)) {
conference_file_stop(conference, FILE_STOP_ASYNC);
conference_file_play(conference, conference->alone_sound, CONF_DEFAULT_LEADIN,
switch_core_session_get_channel(member->session), 0);
} else {
switch_snprintf(msg, sizeof(msg), "You are currently the only person in this conference.");
conference_member_say(member, msg, CONF_DEFAULT_LEADIN);
}
if (!conference_utils_test_flag(conference, CFLAG_BRIDGE_TO) && !conference_utils_member_test_flag(member, MFLAG_GHOST)) {
conference_member_play_alone_sound(member);
}
}
}
@ -1346,8 +1346,13 @@ switch_status_t conference_member_del(conference_obj_t *conference, conference_m
conference_file_play(conference, conference->exit_sound, 0, channel, 0);
}
if (conference->count == 1 && conference->alone_sound && !conference_utils_test_flag(conference, CFLAG_WAIT_MOD) && !conference_utils_member_test_flag(member, MFLAG_GHOST)) {
conference_file_stop(conference, FILE_STOP_ASYNC);
conference_file_play(conference, conference->alone_sound, 0, channel, 0);
/* play file to single member that was left in the conference */
for (imember = conference->members; imember; imember = imember->next) {
if (!conference_utils_member_test_flag(imember, MFLAG_GHOST)) {
conference_member_play_alone_sound(imember);
break;
}
}
}
}

View File

@ -1152,6 +1152,7 @@ void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, void *ob
switch_status_t conference_file_local_play(conference_obj_t *conference, switch_core_session_t *session, char *path, uint32_t leadin, void *buf,
uint32_t buflen);
switch_status_t conference_member_play_file(conference_member_t *member, char *file, uint32_t leadin, switch_bool_t mux);
switch_status_t conference_member_play_alone_sound(conference_member_t *member);
switch_status_t conference_member_say(conference_member_t *member, char *text, uint32_t leadin);
uint32_t conference_member_stop_file(conference_member_t *member, file_stop_t stop);
conference_obj_t *conference_new(char *name, conference_xml_cfg_t cfg, switch_core_session_t *session, switch_memory_pool_t *pool);

View File

@ -106,6 +106,22 @@ char * pgsql_handle_get_error(switch_pgsql_handle_t *handle)
return err_str;
}
void pgsql_handle_set_error_if_not_set(switch_pgsql_handle_t *handle, char **err)
{
char *err_str;
if (err && !(*err)) {
err_str = pgsql_handle_get_error(handle);
if (zstr(err_str)) {
switch_safe_free(err_str);
err_str = strdup((char *)"SQL ERROR!");
}
*err = err_str;
}
}
static int db_is_up(switch_pgsql_handle_t *handle)
{
int ret = 0;
@ -553,8 +569,15 @@ switch_status_t pgsql_handle_exec_detailed(const char *file, const char *func, i
goto error;
}
return pgsql_finish_results(handle);
if (pgsql_finish_results(handle) != SWITCH_STATUS_SUCCESS) {
goto error;
}
return SWITCH_STATUS_SUCCESS;
error:
pgsql_handle_set_error_if_not_set(handle, err);
return SWITCH_STATUS_FALSE;
}
@ -630,6 +653,7 @@ done:
pgsql_free_result(&result);
if (pgsql_finish_results(handle) != SWITCH_STATUS_SUCCESS) {
pgsql_handle_set_error_if_not_set(handle, err);
sstatus = SWITCH_STATUS_FALSE;
}
@ -638,6 +662,7 @@ done:
error:
pgsql_free_result(&result);
pgsql_handle_set_error_if_not_set(handle, err);
return SWITCH_STATUS_FALSE;
}
@ -1050,6 +1075,8 @@ switch_status_t pgsql_handle_callback_exec_detailed(const char *file, const char
return SWITCH_STATUS_SUCCESS;
error:
pgsql_handle_set_error_if_not_set(handle, err);
return SWITCH_STATUS_FALSE;
}