Skip to content

ESP-IDF 使用-O2编译参数编译报错 #1

@qingehao

Description

@qingehao

问题报错如下:

Image

对应出错代码为 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_);
}

}
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions