mirror of
https://github.com/jambonz/freeswitch-modules.git
synced 2026-01-25 02:08:27 +00:00
Delete tts tmp file if playback_start event has not been sent (#68)
* Delete tts tmp file if playback_start event has not been sent Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com> * Delete tts tmp file if playback_start event has not been sent Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com> * wip Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com> --------- Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com>
This commit is contained in:
@@ -84,6 +84,7 @@ static switch_status_t d_speech_feed_tts(switch_speech_handle_t *sh, char *text,
|
||||
d->reads = 0;
|
||||
d->response_code = 0;
|
||||
d->err_msg = NULL;
|
||||
d->playback_start_sent = 0;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "d_speech_feed_tts\n");
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ typedef struct rimelabs_data {
|
||||
int draining;
|
||||
int reads;
|
||||
int cache_audio;
|
||||
int playback_start_sent;
|
||||
|
||||
void *conn;
|
||||
void *circularBuffer;
|
||||
|
||||
@@ -493,6 +493,7 @@ static size_t write_cb(void *ptr, size_t size, size_t nmemb, ConnInfo_t *conn) {
|
||||
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "variable_tts_time_to_first_byte_ms", time_to_first_byte_ms.c_str());
|
||||
switch_event_fire(&event);
|
||||
d->playback_start_sent = 1;
|
||||
}
|
||||
else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "write_cb: failed to create event\n");
|
||||
@@ -903,18 +904,18 @@ extern "C" {
|
||||
}
|
||||
conn->file = nullptr ;
|
||||
}
|
||||
|
||||
if (d->cache_filename) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "removing audio cache file %s because download was interrupted\n", d->cache_filename);
|
||||
if (unlink(d->cache_filename) != 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cleanupConn: error removing audio cache file %s: %d:%s\n",
|
||||
d->cache_filename, errno, strerror(errno));
|
||||
}
|
||||
free(d->cache_filename);
|
||||
d->cache_filename = nullptr ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if playback_start event has not been sent, delete the file
|
||||
if (d->cache_filename && !d->playback_start_sent) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "removing audio cache file %s because download was interrupted\n", d->cache_filename);
|
||||
if (unlink(d->cache_filename) != 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cleanupConn: error removing audio cache file %s: %d:%s\n",
|
||||
d->cache_filename, errno, strerror(errno));
|
||||
}
|
||||
free(d->cache_filename);
|
||||
d->cache_filename = nullptr ;
|
||||
}
|
||||
if (d->session_id) {
|
||||
switch_core_session_t* session = switch_core_session_locate(d->session_id);
|
||||
if (session) {
|
||||
|
||||
Reference in New Issue
Block a user