Skip to content

Commit 99d00a6

Browse files
committed
AudioResampler: initialize frame_.samples_per_channel_
This change is needed for the same reason as b776e64 (livekit#722): A change in the resampler API introduced in libwebrtc m137 caused the output frame's samples_per_channel_ property to remain uninitialized. As a result, the length of the output slice was always calculated as zero, resulting in NativeAudioStream yielding audio frames without any sample data.
1 parent 28f4eb6 commit 99d00a6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

webrtc-sys/src/audio_resampler.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "audio/remix_resample.h"
2222
#include "api/audio/audio_view.h"
23+
#include "api/audio/audio_frame.h"
2324

2425
namespace livekit {
2526

@@ -31,6 +32,7 @@ size_t AudioResampler::remix_and_resample(const int16_t* src,
3132
int dest_sample_rate) {
3233
frame_.num_channels_ = dest_num_channels;
3334
frame_.sample_rate_hz_ = dest_sample_rate;
35+
frame_.samples_per_channel_ = webrtc::SampleRateToDefaultChannelSize(dest_sample_rate);
3436
webrtc::InterleavedView<const int16_t> source(static_cast<const int16_t*>(src),
3537
samples_per_channel,
3638
num_channels);
@@ -47,4 +49,4 @@ std::unique_ptr<AudioResampler> create_audio_resampler() {
4749
return std::make_unique<AudioResampler>();
4850
}
4951

50-
} // namespace livekit
52+
} // namespace livekit

0 commit comments

Comments
 (0)