In RtcpTransceiver avoid extra PostTask during construction

it is not required because during construction members can be set on
wrong thread, and in some corner cases it may even cause a crash.

Bug: none
Change-Id: I37d7f2a7772b6ab5e574077d3f53bca2529f9ae1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/222651
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34315}
This commit is contained in:
Danil Chapovalov
2021-06-16 17:43:00 +02:00
committed by WebRTC LUCI CQ
parent f9d5e55a31
commit 35b21ba8d4
2 changed files with 20 additions and 3 deletions

View File

@ -169,6 +169,25 @@ TEST(RtcpTransceiverImplTest, NeedToStopPeriodicTaskToDestroyOnTaskQueue) {
ASSERT_TRUE(done.Wait(/*milliseconds=*/1000));
}
TEST(RtcpTransceiverImplTest, CanBeDestroyedRightAfterCreation) {
SimulatedClock clock(0);
FakeRtcpTransport transport;
TaskQueueForTest queue("rtcp");
RtcpTransceiverConfig config = DefaultTestConfig();
config.clock = &clock;
config.task_queue = queue.Get();
config.schedule_periodic_compound_packets = true;
config.outgoing_transport = &transport;
rtc::Event done;
queue.PostTask([&] {
RtcpTransceiverImpl rtcp_transceiver(config);
rtcp_transceiver.StopPeriodicTask();
done.Set();
});
ASSERT_TRUE(done.Wait(/*milliseconds=*/1000));
}
TEST(RtcpTransceiverImplTest, CanDestroyAfterTaskQueue) {
SimulatedClock clock(0);
FakeRtcpTransport transport;