[Core] Delete recording files if media bug creation fails
Signed-off-by: hateeyan <hateeyan@gmail.com>
This commit is contained in:
parent
98f164d2bf
commit
0739809c76
|
@ -1664,12 +1664,10 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
|
||||||
if (!rh->writes && !rh->vwrites && !switch_test_flag(rh->fh, SWITCH_FILE_WRITE_APPEND)) {
|
if (!rh->writes && !rh->vwrites && !switch_test_flag(rh->fh, SWITCH_FILE_WRITE_APPEND)) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Discarding empty file %s\n", rh->file);
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Discarding empty file %s\n", rh->file);
|
||||||
switch_channel_set_variable(channel, "RECORD_DISCARDED", "true");
|
switch_channel_set_variable(channel, "RECORD_DISCARDED", "true");
|
||||||
switch_file_remove(rh->file, switch_core_session_get_pool(session));
|
|
||||||
set_completion_cause(rh, "empty-file");
|
set_completion_cause(rh, "empty-file");
|
||||||
} else if ((rh->fh->samples_out < rh->fh->samplerate * rh->min_sec) && !switch_test_flag(rh->fh, SWITCH_FILE_WRITE_APPEND)) {
|
} else if ((rh->fh->samples_out < rh->fh->samplerate * rh->min_sec) && !switch_test_flag(rh->fh, SWITCH_FILE_WRITE_APPEND)) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Discarding short file %s\n", rh->file);
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Discarding short file %s\n", rh->file);
|
||||||
switch_channel_set_variable(channel, "RECORD_DISCARDED", "true");
|
switch_channel_set_variable(channel, "RECORD_DISCARDED", "true");
|
||||||
switch_file_remove(rh->file, switch_core_session_get_pool(session));
|
|
||||||
set_completion_cause(rh, "input-too-short");
|
set_completion_cause(rh, "input-too-short");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -2899,6 +2897,9 @@ static switch_status_t record_helper_destroy(struct record_helper **rh, switch_c
|
||||||
switch_core_file_close(&(*rh)->out_fh);
|
switch_core_file_close(&(*rh)->out_fh);
|
||||||
} else if((*rh)->fh) {
|
} else if((*rh)->fh) {
|
||||||
switch_core_file_close((*rh)->fh);
|
switch_core_file_close((*rh)->fh);
|
||||||
|
if (((!(*rh)->writes && !(*rh)->vwrites) || ((*rh)->fh->samples_out < (*rh)->fh->samplerate * (*rh)->min_sec)) && !switch_test_flag((*rh)->fh, SWITCH_FILE_WRITE_APPEND)) {
|
||||||
|
switch_file_remove((*rh)->file, switch_core_session_get_pool(session));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_event_safe_destroy((*rh)->variables);
|
switch_event_safe_destroy((*rh)->variables);
|
||||||
|
|
Loading…
Reference in New Issue