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

Unified Diff: webrtc/modules/audio_coding/codecs/audio_decoder_factory.h

Issue 1990803004: Turned AudioDecoderFactory into a RefCounted thing to use with scoped_refptr. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/codecs/audio_decoder_factory_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_coding/codecs/audio_decoder_factory.h
diff --git a/webrtc/modules/audio_coding/codecs/audio_decoder_factory.h b/webrtc/modules/audio_coding/codecs/audio_decoder_factory.h
index 12b977809187e8bf868a32bd415531f9d49d8e3f..64044b60209827f50738dbbdf8abc242ce1ba059 100644
--- a/webrtc/modules/audio_coding/codecs/audio_decoder_factory.h
+++ b/webrtc/modules/audio_coding/codecs/audio_decoder_factory.h
@@ -14,6 +14,8 @@
#include <memory>
#include <vector>
+#include "webrtc/base/atomicops.h"
+#include "webrtc/base/refcount.h"
#include "webrtc/modules/audio_coding/codecs/audio_decoder.h"
#include "webrtc/modules/audio_coding/codecs/audio_format.h"
@@ -21,7 +23,7 @@ namespace webrtc {
// A factory that creates AudioDecoders.
// NOTE: This class is still under development and may change without notice.
-class AudioDecoderFactory {
+class AudioDecoderFactory : public rtc::RefCountInterface {
public:
virtual ~AudioDecoderFactory() = default;
@@ -29,6 +31,21 @@ class AudioDecoderFactory {
virtual std::unique_ptr<AudioDecoder> MakeAudioDecoder(
const SdpAudioFormat& format) = 0;
+
+ int AddRef() const override {
ossu 2016/05/18 11:59:56 Put these in .cc-file? Pro: cleaner Con: slower (a
kwiberg-webrtc 2016/05/18 14:03:15 Slower how? It's a virtual call either way.
ossu 2016/05/18 14:42:20 Yeah, I guess as long as we inherit from rtc::RefC
kwiberg-webrtc 2016/05/18 15:48:27 Making them final would essentially make them not
+ return rtc::AtomicOps::Increment(&ref_count_);
+ }
+
+ int Release() const override {
+ int count = rtc::AtomicOps::Decrement(&ref_count_);
+ if (!count) {
+ delete this;
+ }
+ return count;
+ }
+
+ private:
+ mutable volatile int ref_count_;
kwiberg-webrtc 2016/05/18 14:03:15 Danger, Will Robinson! State in an interface! Thi
ossu 2016/05/18 14:42:21 Oh, right... We'd get two reference counts and eve
};
} // namespace webrtc
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/codecs/audio_decoder_factory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698