opus encode valid data packets

This commit is contained in:
Terrence
2024-09-03 16:13:32 +08:00
parent a26541911e
commit 10574dd2bc

View File

@@ -427,6 +427,7 @@ void Application::AudioDecodeTask() {
AudioPacket* packet; AudioPacket* packet;
xQueueReceive(audio_decode_queue_, &packet, portMAX_DELAY); xQueueReceive(audio_decode_queue_, &packet, portMAX_DELAY);
if (packet->type == kAudioPacketTypeData) {
int frame_size = opus_decode_sample_rate_ / 1000 * opus_duration_ms_; int frame_size = opus_decode_sample_rate_ / 1000 * opus_duration_ms_;
packet->pcm.resize(frame_size); packet->pcm.resize(frame_size);
@@ -443,6 +444,7 @@ void Application::AudioDecodeTask() {
assert(0 == silk_resampler(&resampler_state_, resampled.data(), packet->pcm.data(), frame_size)); assert(0 == silk_resampler(&resampler_state_, resampled.data(), packet->pcm.data(), frame_size));
packet->pcm = std::move(resampled); packet->pcm = std::move(resampled);
} }
}
audio_device_.QueueAudioPacket(packet); audio_device_.QueueAudioPacket(packet);
} }