From c2e4e3c2e9be855277d9f4fa9cd0544892ff829a Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期三, 30 八月 2023 09:57:30 +0800
Subject: [PATCH] Merge branch 'main' of github.com:alibaba-damo-academy/FunASR add
---
funasr/runtime/websocket/websocket-server-2pass.cpp | 23 +++++++++++++++--------
1 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/funasr/runtime/websocket/websocket-server-2pass.cpp b/funasr/runtime/websocket/websocket-server-2pass.cpp
index e6e6c51..201b439 100644
--- a/funasr/runtime/websocket/websocket-server-2pass.cpp
+++ b/funasr/runtime/websocket/websocket-server-2pass.cpp
@@ -203,6 +203,12 @@
data_msg->msg["is_eof"]=false; // if this connection is closed
data_msg->punc_cache =
std::make_shared<std::vector<std::vector<std::string>>>(2);
+ data_msg->strand_ = std::make_shared<asio::io_context::strand>(io_decoder_);
+ // std::vector<int> chunk_size = {5, 10, 5}; //TODO, need get from client
+ // FUNASR_HANDLE tpass_online_handle =
+ // FunTpassOnlineInit(tpass_handle, chunk_size);
+ // data_msg->tpass_online_handle = tpass_online_handle;
+
data_map.emplace(hdl, data_msg);
// LOG(INFO) << "on_open, active connections: " << data_map.size();
}catch (std::exception const& e) {
@@ -294,7 +300,8 @@
}
for (auto hdl : to_remove) {
remove_hdl(hdl, data_map);
- // LOG(INFO) << "remove one connection ";
+ //LOG(INFO) << "remove one connection ";
+
}
}
}
@@ -360,8 +367,8 @@
// if it is in final message, post the sample_data to decode
try{
- asio::post(
- io_decoder_,
+
+ msg_data->strand_->post(
std::bind(&WebSocketServer::do_decoder, this,
std::move(*(sample_data_p.get())), std::move(hdl),
std::ref(msg_data->msg), std::ref(*(punc_cache_p.get())),
@@ -400,7 +407,7 @@
try{
// post to decode
- asio::post(io_decoder_,
+ msg_data->strand_->post(
std::bind(&WebSocketServer::do_decoder, this,
std::move(subvector), std::move(hdl),
std::ref(msg_data->msg),
@@ -436,10 +443,10 @@
LOG(ERROR) << "FunTpassInit init failed";
exit(-1);
}
- LOG(INFO) << "initAsr run check_and_clean_connection";
- std::thread clean_thread(&WebSocketServer::check_and_clean_connection,this);
- clean_thread.detach();
- LOG(INFO) << "initAsr run check_and_clean_connection finished";
+ LOG(INFO) << "initAsr run check_and_clean_connection";
+ std::thread clean_thread(&WebSocketServer::check_and_clean_connection,this);
+ clean_thread.detach();
+ LOG(INFO) << "initAsr run check_and_clean_connection finished";
} catch (const std::exception& e) {
LOG(INFO) << e.what();
--
Gitblit v1.9.1