From 7b4520c070025b1eec389ba0a3391ee19d2fa357 Mon Sep 17 00:00:00 2001 From: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com> Date: Sat, 5 Oct 2024 21:02:07 +0700 Subject: [PATCH] Playht delete circular buffer with mutex check (#123) Signed-off-by: root Co-authored-by: root --- mod_playht_tts/playht_glue.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mod_playht_tts/playht_glue.cpp b/mod_playht_tts/playht_glue.cpp index 283024a..01e468f 100644 --- a/mod_playht_tts/playht_glue.cpp +++ b/mod_playht_tts/playht_glue.cpp @@ -959,8 +959,11 @@ extern "C" { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "playht_speech_flush_tts, download complete? %s\n", download_complete ? "yes" : "no") ; ConnInfo_t *conn = (ConnInfo_t *) p->conn; CircularBuffer_t *cBuffer = (CircularBuffer_t *) p->circularBuffer; + // In multi threads, only delete the circular buffer when write and read buffer action finished using it. + switch_mutex_lock(p->mutex); delete cBuffer; p->circularBuffer = nullptr ; + switch_mutex_unlock(p->mutex); if (conn) { conn->flushed = true;