@@ -147,11 +147,6 @@ AudioTrackSource::InternalSource::InternalSource(
147147 return ; // no audio queue
148148 }
149149
150- // start sending silence when there is nothing on the queue for 10 frames
151- // (100ms)
152- const int silence_frames_threshold = 10 ;
153- missed_frames_ = silence_frames_threshold;
154-
155150 int samples10ms = sample_rate / 100 * num_channels;
156151
157152 silence_buffer_.assign (samples10ms, 0 );
@@ -171,20 +166,16 @@ AudioTrackSource::InternalSource::InternalSource(
171166 constexpr int kBitsPerSample = sizeof (int16_t ) * 8 ;
172167
173168 if (buffer_.size () >= samples10ms) {
174- // Reset |missed_frames_| to 0 so that it won't keep sending silence to webrtc due to audio callback timing drifts.
175- missed_frames_ = 0 ;
176169 for (auto sink : sinks_)
177170 sink->OnData (buffer_.data (), kBitsPerSample , sample_rate_,
178171 num_channels_, samples10ms / num_channels_);
179172
180173 buffer_.erase (buffer_.begin (), buffer_.begin () + samples10ms);
181174 } else {
182- missed_frames_++;
183- if (missed_frames_ >= silence_frames_threshold) {
184- for (auto sink : sinks_)
185- sink->OnData (silence_buffer_.data (), kBitsPerSample , sample_rate_,
186- num_channels_, samples10ms / num_channels_);
187- }
175+ // Always provide a 10ms frame to avoid playout underruns.
176+ for (auto sink : sinks_)
177+ sink->OnData (silence_buffer_.data (), kBitsPerSample , sample_rate_,
178+ num_channels_, samples10ms / num_channels_);
188179 }
189180
190181 if (on_complete_ && buffer_.size () <= notify_threshold_samples_) {
0 commit comments