Skip to content

Commit b776e64

Browse files
authored
Fix empty audio frames after resample (#722)
* Initialize samples per channel `RemixAndResample` will not initialize this field, causing the slice's length to be computed to zero. * Remove redundant cast
1 parent 0215091 commit b776e64

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

webrtc-sys/src/audio_track.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <memory>
2323

2424
#include "api/audio_options.h"
25+
#include "api/audio/audio_frame.h"
2526
#include "api/media_stream_interface.h"
2627
#include "api/task_queue/task_queue_base.h"
2728
#include "audio/remix_resample.h"
@@ -87,6 +88,7 @@ NativeAudioSink::NativeAudioSink(rust::Box<AudioSinkWrapper> observer,
8788
num_channels_(num_channels) {
8889
frame_.sample_rate_hz_ = sample_rate;
8990
frame_.num_channels_ = num_channels;
91+
frame_.samples_per_channel_ = webrtc::SampleRateToDefaultChannelSize(sample_rate);
9092
}
9193

9294
void NativeAudioSink::OnData(const void* audio_data,
@@ -99,7 +101,7 @@ void NativeAudioSink::OnData(const void* audio_data,
99101
const int16_t* data = static_cast<const int16_t*>(audio_data);
100102

101103
if (sample_rate_ != sample_rate || num_channels_ != number_of_channels) {
102-
webrtc::InterleavedView<const int16_t> source(static_cast<const int16_t*>(data),
104+
webrtc::InterleavedView<const int16_t> source(data,
103105
number_of_frames,
104106
number_of_channels);
105107
// resample/remix before capturing

0 commit comments

Comments
 (0)