-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
问题报错如下:
对应出错代码为 in_buffer_.insert(in_buffer_.end(), pcm.begin(), pcm.end());
`
void OpusEncoderWrapper::Encode(std::vector<int16_t>&& pcm, std::function<void(std::vector<uint8_t>&& opus)> handler) {
if (audio_enc_ == nullptr) {
ESP_LOGE(TAG, "Audio encoder is not configured");
return;
}
if (in_buffer_.empty()) {
in_buffer_ = std::move(pcm);
} else {
in_buffer_.insert(in_buffer_.end(), pcm.begin(), pcm.end());
}
while (in_buffer_.size() >= frame_size_) {
std::vector<uint8_t> opus(MAX_OPUS_PACKET_SIZE);
auto ret = opus_encode(audio_enc_, in_buffer_.data(), frame_size_, opus.data(), opus.size());
if (ret < 0) {
ESP_LOGE(TAG, "Failed to encode audio, error code: %ld", ret);
return;
}
opus.resize(ret);
if (handler != nullptr) {
handler(std::move(opus));
}
in_buffer_.erase(in_buffer_.begin(), in_buffer_.begin() + frame_size_);
}
}
`
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
