diff --git a/pc/dtmfsender.cc b/pc/dtmfsender.cc index 8378eb9a07..1fde7bf236 100644 --- a/pc/dtmfsender.cc +++ b/pc/dtmfsender.cc @@ -141,7 +141,7 @@ bool DtmfSender::InsertDtmf(const std::string& tones, int duration, // Clear the previous queue. signaling_thread_->Clear(this, MSG_DO_INSERT_DTMF); // Kick off a new DTMF task queue. - signaling_thread_->Post(RTC_FROM_HERE, this, MSG_DO_INSERT_DTMF); + signaling_thread_->PostDelayed(RTC_FROM_HERE, 1, this, MSG_DO_INSERT_DTMF); return true; } diff --git a/pc/dtmfsender_unittest.cc b/pc/dtmfsender_unittest.cc index ddccc448f6..48f2bee259 100644 --- a/pc/dtmfsender_unittest.cc +++ b/pc/dtmfsender_unittest.cc @@ -335,3 +335,15 @@ TEST_F(DtmfSenderTest, InsertDtmfWithInvalidDurationOrGap) { EXPECT_TRUE(dtmf_->InsertDtmf(tones, duration, inter_tone_gap)); } + +TEST_F(DtmfSenderTest, InsertDtmfSendsAfterWait) { + std::string tones = "ABC"; + int duration = 100; + int inter_tone_gap = 50; + EXPECT_TRUE(dtmf_->InsertDtmf(tones, duration, inter_tone_gap)); + VerifyExpectedState(track_, "ABC", duration, inter_tone_gap); + // Wait until the first tone got sent. + EXPECT_TRUE_SIMULATED_WAIT(observer_->tones().size() == 1, kMaxWaitMs, + fake_clock_); + VerifyExpectedState(track_, "BC", duration, inter_tone_gap); +}