v1.6.5: Improve performance and memory usage

This commit is contained in:
Terrence
2025-05-26 14:30:44 +08:00
parent 277f87ae5f
commit 0c57df1cd8
13 changed files with 50 additions and 45 deletions

View File

@@ -144,9 +144,7 @@ void MqttProtocol::SendAudio(const AudioStreamPacket& packet) {
return;
}
busy_sending_audio_ = true;
udp_->Send(encrypted);
busy_sending_audio_ = false;
}
void MqttProtocol::CloseAudioChannel() {
@@ -177,7 +175,6 @@ bool MqttProtocol::OpenAudioChannel() {
}
}
busy_sending_audio_ = false;
error_occurred_ = false;
session_id_ = "";
xEventGroupClearBits(event_group_handle_, MQTT_PROTOCOL_SERVER_HELLO_EVENT);
@@ -207,7 +204,7 @@ bool MqttProtocol::OpenAudioChannel() {
* |payload payload_len|
*/
if (data.size() < sizeof(aes_nonce_)) {
ESP_LOGE(TAG, "Invalid audio packet size: %zu", data.size());
ESP_LOGE(TAG, "Invalid audio packet size: %u", data.size());
return;
}
if (data[0] != 0x01) {

View File

@@ -130,8 +130,3 @@ bool Protocol::IsTimeout() const {
}
return timeout;
}
bool Protocol::IsAudioChannelBusy() const {
return busy_sending_audio_;
}

View File

@@ -63,7 +63,6 @@ public:
virtual bool OpenAudioChannel() = 0;
virtual void CloseAudioChannel() = 0;
virtual bool IsAudioChannelOpened() const = 0;
virtual bool IsAudioChannelBusy() const;
virtual void SendAudio(const AudioStreamPacket& packet) = 0;
virtual void SendWakeWordDetected(const std::string& wake_word);
virtual void SendStartListening(ListeningMode mode);
@@ -83,7 +82,6 @@ protected:
int server_sample_rate_ = 24000;
int server_frame_duration_ = 60;
bool error_occurred_ = false;
bool busy_sending_audio_ = false;
std::string session_id_;
std::chrono::time_point<std::chrono::steady_clock> last_incoming_time_;

View File

@@ -44,9 +44,7 @@ void WebsocketProtocol::SendAudio(const AudioStreamPacket& packet) {
bp2->payload_size = htonl(packet.payload.size());
memcpy(bp2->payload, packet.payload.data(), packet.payload.size());
busy_sending_audio_ = true;
websocket_->Send(serialized.data(), serialized.size(), true);
busy_sending_audio_ = false;
} else if (version_ == 3) {
std::string serialized;
serialized.resize(sizeof(BinaryProtocol3) + packet.payload.size());
@@ -56,13 +54,9 @@ void WebsocketProtocol::SendAudio(const AudioStreamPacket& packet) {
bp3->payload_size = htons(packet.payload.size());
memcpy(bp3->payload, packet.payload.data(), packet.payload.size());
busy_sending_audio_ = true;
websocket_->Send(serialized.data(), serialized.size(), true);
busy_sending_audio_ = false;
} else {
busy_sending_audio_ = true;
websocket_->Send(packet.payload.data(), packet.payload.size(), true);
busy_sending_audio_ = false;
}
}
@@ -104,7 +98,6 @@ bool WebsocketProtocol::OpenAudioChannel() {
version_ = version;
}
busy_sending_audio_ = false;
error_occurred_ = false;
websocket_ = Board::GetInstance().CreateWebSocket();