新的opus封装以及优化const会导致的内存拷贝

This commit is contained in:
Terrence
2024-12-04 02:12:20 +08:00
parent 9c1f8a1d06
commit bcfd120b00
15 changed files with 102 additions and 102 deletions

View File

@@ -10,6 +10,7 @@
#include <condition_variable>
#include "opus_encoder.h"
#include "opus_decoder.h"
#include "opus_resampler.h"
#include "protocol.h"
@@ -52,7 +53,7 @@ public:
ChatState GetChatState() const { return chat_state_; }
void Schedule(std::function<void()> callback);
void SetChatState(ChatState state);
void Alert(const std::string&& title, const std::string&& message);
void Alert(const std::string& title, const std::string& message);
void AbortSpeaking(AbortReason reason);
void ToggleChatState();
void StartListening();
@@ -69,7 +70,7 @@ private:
Ota ota_;
std::mutex mutex_;
std::list<std::function<void()>> main_tasks_;
Protocol* protocol_ = nullptr;
std::unique_ptr<Protocol> protocol_;
EventGroupHandle_t event_group_;
volatile ChatState chat_state_ = kChatStateUnknown;
bool keep_listening_ = false;
@@ -78,10 +79,10 @@ private:
// Audio encode / decode
BackgroundTask background_task_;
std::chrono::steady_clock::time_point last_output_time_;
std::list<std::string> audio_decode_queue_;
std::list<std::vector<uint8_t>> audio_decode_queue_;
OpusEncoder opus_encoder_;
OpusDecoder* opus_decoder_ = nullptr;
std::unique_ptr<OpusEncoderWrapper> opus_encoder_;
std::unique_ptr<OpusDecoderWrapper> opus_decoder_;
int opus_decode_sample_rate_ = -1;
OpusResampler input_resampler_;