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

Unified Diff: webrtc/modules/audio_coding/codecs/isac/locked_bandwidth_info.h

Issue 1821513003: Rent-A-Codec: Reference count the shared iSAC bandwidth estimation state (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@acm-13
Patch Set: Created 4 years, 9 months 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/codecs/isac/locked_bandwidth_info.h
diff --git a/webrtc/modules/audio_coding/codecs/isac/locked_bandwidth_info.h b/webrtc/modules/audio_coding/codecs/isac/locked_bandwidth_info.h
index 6bb32c99ed965145c0259f96fc04006bf2acb6e7..1ab5ae9d639a8f50a1b1a0fb4b2bddb09431bcb4 100644
--- a/webrtc/modules/audio_coding/codecs/isac/locked_bandwidth_info.h
+++ b/webrtc/modules/audio_coding/codecs/isac/locked_bandwidth_info.h
@@ -11,6 +11,7 @@
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_LOCKED_BANDWIDTH_INFO_H_
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_LOCKED_BANDWIDTH_INFO_H_
+#include "webrtc/base/atomicops.h"
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/thread_annotations.h"
#include "webrtc/modules/audio_coding/codecs/isac/bandwidth_info.h"
@@ -34,7 +35,18 @@ class LockedIsacBandwidthInfo final {
bwinfo_ = bwinfo;
}
+ int AddRef() const { return rtc::AtomicOps::Increment(&ref_count_); }
+
+ int Release() const {
+ const int count = rtc::AtomicOps::Decrement(&ref_count_);
+ if (count == 0) {
+ delete this;
+ }
+ return count;
+ }
+
private:
+ mutable volatile int ref_count_;
rtc::CriticalSection lock_;
IsacBandwidthInfo bwinfo_ GUARDED_BY(lock_);
};

Powered by Google App Engine
This is Rietveld 408576698