From 7925f77739369086278aae49ac6feda04760de09 Mon Sep 17 00:00:00 2001 From: Terrence Date: Mon, 19 May 2025 01:29:39 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20=E5=88=87=E6=8D=A2=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=90=8E=E4=B8=80=E6=AE=B5=E6=97=B6=E9=97=B4=E5=86=85=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=BD=95=E9=9F=B3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/application.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/main/application.cc b/main/application.cc index e78370f0..54841a45 100644 --- a/main/application.cc +++ b/main/application.cc @@ -531,7 +531,7 @@ void Application::Start() { opus_encoder_->Encode(std::move(data), [this](std::vector&& opus) { AudioStreamPacket packet; packet.payload = std::move(opus); - uint32_t last_output_timestamp_value = last_output_timestamp_.load(); +#ifdef CONFIG_USE_SERVER_AEC { std::lock_guard lock(timestamp_mutex_); if (!timestamp_queue_.empty()) { @@ -546,10 +546,9 @@ void Application::Start() { return; } } - Schedule([this, last_output_timestamp_value, packet = std::move(packet)]() { +#endif + Schedule([this, packet = std::move(packet)]() { protocol_->SendAudio(packet); - // ESP_LOGI(TAG, "Send %zu bytes, timestamp %lu, last_ts %lu, qsize %zu", - // packet.payload.size(), packet.timestamp, last_output_timestamp_value, timestamp_queue_.size()); }); }); }); @@ -732,11 +731,11 @@ void Application::OnAudioOutput() { pcm = std::move(resampled); } codec->OutputData(pcm); - { +#ifdef CONFIG_USE_SERVER_AEC std::lock_guard lock(timestamp_mutex_); timestamp_queue_.push_back(packet.timestamp); last_output_timestamp_ = packet.timestamp; - } +#endif last_output_time_ = std::chrono::steady_clock::now(); }); }