Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Side by Side Diff: webrtc/modules/pacing/packet_router.cc

Issue 1505053002: Revert of "Create rtc::AtomicInt POD struct." (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/pacing/packet_router.h" 11 #include "webrtc/modules/pacing/packet_router.h"
12 12
13 #include "webrtc/base/atomicops.h" 13 #include "webrtc/base/atomicops.h"
14 #include "webrtc/base/checks.h" 14 #include "webrtc/base/checks.h"
15 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 15 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
16 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 16 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" 17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
18 18
19 namespace webrtc { 19 namespace webrtc {
20 20
21 PacketRouter::PacketRouter() : transport_seq_({0}) {} 21 PacketRouter::PacketRouter() : transport_seq_(0) {
22 }
22 23
23 PacketRouter::~PacketRouter() { 24 PacketRouter::~PacketRouter() {
24 RTC_DCHECK(rtp_modules_.empty()); 25 RTC_DCHECK(rtp_modules_.empty());
25 } 26 }
26 27
27 void PacketRouter::AddRtpModule(RtpRtcp* rtp_module) { 28 void PacketRouter::AddRtpModule(RtpRtcp* rtp_module) {
28 rtc::CritScope cs(&modules_lock_); 29 rtc::CritScope cs(&modules_lock_);
29 RTC_DCHECK(std::find(rtp_modules_.begin(), rtp_modules_.end(), rtp_module) == 30 RTC_DCHECK(std::find(rtp_modules_.begin(), rtp_modules_.end(), rtp_module) ==
30 rtp_modules_.end()); 31 rtp_modules_.end());
31 rtp_modules_.push_back(rtp_module); 32 rtp_modules_.push_back(rtp_module);
(...skipping 29 matching lines...) Expand all
61 module->TimeToSendPadding(bytes_to_send - total_bytes_sent); 62 module->TimeToSendPadding(bytes_to_send - total_bytes_sent);
62 total_bytes_sent += bytes_sent; 63 total_bytes_sent += bytes_sent;
63 if (total_bytes_sent >= bytes_to_send) 64 if (total_bytes_sent >= bytes_to_send)
64 break; 65 break;
65 } 66 }
66 } 67 }
67 return total_bytes_sent; 68 return total_bytes_sent;
68 } 69 }
69 70
70 void PacketRouter::SetTransportWideSequenceNumber(uint16_t sequence_number) { 71 void PacketRouter::SetTransportWideSequenceNumber(uint16_t sequence_number) {
71 rtc::AtomicInt::ReleaseStore(&transport_seq_, sequence_number); 72 rtc::AtomicOps::ReleaseStore(&transport_seq_, sequence_number);
72 } 73 }
73 74
74 uint16_t PacketRouter::AllocateSequenceNumber() { 75 uint16_t PacketRouter::AllocateSequenceNumber() {
75 int prev_seq = rtc::AtomicInt::AcquireLoad(&transport_seq_); 76 int prev_seq = rtc::AtomicOps::AcquireLoad(&transport_seq_);
76 int desired_prev_seq; 77 int desired_prev_seq;
77 int new_seq; 78 int new_seq;
78 do { 79 do {
79 desired_prev_seq = prev_seq; 80 desired_prev_seq = prev_seq;
80 new_seq = (desired_prev_seq + 1) & 0xFFFF; 81 new_seq = (desired_prev_seq + 1) & 0xFFFF;
81 // Note: CompareAndSwap returns the actual value of transport_seq at the 82 // Note: CompareAndSwap returns the actual value of transport_seq at the
82 // time the CAS operation was executed. Thus, if prev_seq is returned, the 83 // time the CAS operation was executed. Thus, if prev_seq is returned, the
83 // operation was successful - otherwise we need to retry. Saving the 84 // operation was successful - otherwise we need to retry. Saving the
84 // return value saves us a load on retry. 85 // return value saves us a load on retry.
85 prev_seq = rtc::AtomicInt::CompareAndSwap(&transport_seq_, desired_prev_seq, 86 prev_seq = rtc::AtomicOps::CompareAndSwap(&transport_seq_, desired_prev_seq,
86 new_seq); 87 new_seq);
87 } while (prev_seq != desired_prev_seq); 88 } while (prev_seq != desired_prev_seq);
88 89
89 return new_seq; 90 return new_seq;
90 } 91 }
91 92
92 bool PacketRouter::SendFeedback(rtcp::TransportFeedback* packet) { 93 bool PacketRouter::SendFeedback(rtcp::TransportFeedback* packet) {
93 rtc::CritScope cs(&modules_lock_); 94 rtc::CritScope cs(&modules_lock_);
94 for (auto* rtp_module : rtp_modules_) { 95 for (auto* rtp_module : rtp_modules_) {
95 packet->WithPacketSenderSsrc(rtp_module->SSRC()); 96 packet->WithPacketSenderSsrc(rtp_module->SSRC());
96 if (rtp_module->SendFeedbackPacket(*packet)) 97 if (rtp_module->SendFeedbackPacket(*packet))
97 return true; 98 return true;
98 } 99 }
99 return false; 100 return false;
100 } 101 }
101 102
102 } // namespace webrtc 103 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698