Skip to content

Commit bfb78d1

Browse files
kwibergCommit bot
authored andcommitted
Revert of AcmReceiver: Ask NetEq to delete all decoders at once instead of one by one (patchset #2 id:20001 of https://codereview.webrtc.org/2342313002/ )
Reason for revert: Seems to have broken Chromium tests. Original issue's description: > AcmReceiver: Ask NetEq to delete all decoders at once instead of one by one > > It requires a new NetEq method, but it can no longer fail. And we no > longer need to use AcmReceiver::decoders_, which we're trying to > eliminate. > > BUG=webrtc:5801 > > Committed: https://crrev.com/f6232b43a176e1717354b671a0a52b887d70de59 > Cr-Commit-Position: refs/heads/master@{#14275} TBR=ossu@webrtc.org,henrik.lundin@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:5801 Review-Url: https://codereview.webrtc.org/2349973002 Cr-Commit-Position: refs/heads/master@{#14278}
1 parent f62b82e commit bfb78d1

8 files changed

Lines changed: 23 additions & 25 deletions

File tree

webrtc/modules/audio_coding/acm2/acm_receiver.cc

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,27 @@ void AcmReceiver::FlushBuffers() {
245245
neteq_->FlushBuffers();
246246
}
247247

248-
void AcmReceiver::RemoveAllCodecs() {
248+
// If failed in removing one of the codecs, this method continues to remove as
249+
// many as it can.
250+
int AcmReceiver::RemoveAllCodecs() {
251+
int ret_val = 0;
249252
rtc::CritScope lock(&crit_sect_);
250-
neteq_->RemoveAllPayloadTypes();
251-
decoders_.clear();
253+
for (auto it = decoders_.begin(); it != decoders_.end(); ) {
254+
auto cur = it;
255+
++it; // it will be valid even if we erase cur
256+
if (neteq_->RemovePayloadType(cur->second.payload_type) == 0) {
257+
decoders_.erase(cur);
258+
} else {
259+
LOG_F(LS_ERROR) << "Cannot remove payload "
260+
<< static_cast<int>(cur->second.payload_type);
261+
ret_val = -1;
262+
}
263+
}
264+
265+
// No codec is registered, invalidate last audio decoder.
252266
last_audio_decoder_ = rtc::Optional<CodecInst>();
253267
last_packet_sample_rate_hz_ = rtc::Optional<int>();
268+
return ret_val;
254269
}
255270

256271
int AcmReceiver::RemoveCodec(uint8_t payload_type) {

webrtc/modules/audio_coding/acm2/acm_receiver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class AcmReceiver {
186186
//
187187
// Remove all registered codecs.
188188
//
189-
void RemoveAllCodecs();
189+
int RemoveAllCodecs();
190190

191191
// Returns the RTP timestamp for the last sample delivered by GetAudio().
192192
// The return value will be empty if no valid timestamp is available.

webrtc/modules/audio_coding/acm2/audio_coding_module.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,10 @@ int AudioCodingModuleImpl::InitializeReceiverSafe() {
948948
// If the receiver is already initialized then we want to destroy any
949949
// existing decoders. After a call to this function, we should have a clean
950950
// start-up.
951-
if (receiver_initialized_)
952-
receiver_.RemoveAllCodecs();
951+
if (receiver_initialized_) {
952+
if (receiver_.RemoveAllCodecs() < 0)
953+
return -1;
954+
}
953955
receiver_.ResetInitialDelay();
954956
receiver_.SetMinimumDelay(0);
955957
receiver_.SetMaximumDelay(0);

webrtc/modules/audio_coding/neteq/decoder_database.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,6 @@ int DecoderDatabase::Remove(uint8_t rtp_payload_type) {
169169
return kOK;
170170
}
171171

172-
void DecoderDatabase::RemoveAll() {
173-
decoders_.clear();
174-
active_decoder_type_ = -1; // No active decoder.
175-
active_cng_decoder_type_ = -1; // No active CNG decoder.
176-
}
177-
178172
const DecoderDatabase::DecoderInfo* DecoderDatabase::GetDecoderInfo(
179173
uint8_t rtp_payload_type) const {
180174
DecoderMap::const_iterator it = decoders_.find(rtp_payload_type);

webrtc/modules/audio_coding/neteq/decoder_database.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,6 @@ class DecoderDatabase {
136136
// Returns kDecoderNotFound or kOK depending on the outcome of the operation.
137137
virtual int Remove(uint8_t rtp_payload_type);
138138

139-
// Remove all entries.
140-
void RemoveAll();
141-
142139
// Returns a pointer to the DecoderInfo struct for |rtp_payload_type|. If
143140
// no decoder is registered with that |rtp_payload_type|, NULL is returned.
144141
virtual const DecoderInfo* GetDecoderInfo(uint8_t rtp_payload_type) const;

webrtc/modules/audio_coding/neteq/include/neteq.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,6 @@ class NetEq {
183183
// -1 on failure.
184184
virtual int RemovePayloadType(uint8_t rtp_payload_type) = 0;
185185

186-
// Removes all payload types from the codec database.
187-
virtual void RemoveAllPayloadTypes() = 0;
188-
189186
// Sets a minimum delay in millisecond for packet buffer. The minimum is
190187
// maintained unless a higher latency is dictated by channel condition.
191188
// Returns true if the minimum is successfully applied, otherwise false is

webrtc/modules/audio_coding/neteq/neteq_impl.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,6 @@ int NetEqImpl::RemovePayloadType(uint8_t rtp_payload_type) {
291291
return kFail;
292292
}
293293

294-
void NetEqImpl::RemoveAllPayloadTypes() {
295-
rtc::CritScope lock(&crit_sect_);
296-
decoder_database_->RemoveAll();
297-
}
298-
299294
bool NetEqImpl::SetMinimumDelay(int delay_ms) {
300295
rtc::CritScope lock(&crit_sect_);
301296
if (delay_ms >= 0 && delay_ms < 10000) {

webrtc/modules/audio_coding/neteq/neteq_impl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ class NetEqImpl : public webrtc::NetEq {
123123
// -1 on failure.
124124
int RemovePayloadType(uint8_t rtp_payload_type) override;
125125

126-
void RemoveAllPayloadTypes() override;
127-
128126
bool SetMinimumDelay(int delay_ms) override;
129127

130128
bool SetMaximumDelay(int delay_ms) override;

0 commit comments

Comments
 (0)