2015-08-24 02:03:23 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_AUDIO_CODING_CODECS_ISAC_LOCKED_BANDWIDTH_INFO_H_
|
|
|
|
|
#define MODULES_AUDIO_CODING_CODECS_ISAC_LOCKED_BANDWIDTH_INFO_H_
|
2015-08-24 02:03:23 -07:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_coding/codecs/isac/bandwidth_info.h"
|
|
|
|
|
#include "rtc_base/atomicops.h"
|
|
|
|
|
#include "rtc_base/criticalsection.h"
|
|
|
|
|
#include "rtc_base/thread_annotations.h"
|
2015-08-24 02:03:23 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
// An IsacBandwidthInfo that's safe to access from multiple threads because
|
|
|
|
|
// it's protected by a mutex.
|
|
|
|
|
class LockedIsacBandwidthInfo final {
|
|
|
|
|
public:
|
|
|
|
|
LockedIsacBandwidthInfo();
|
|
|
|
|
~LockedIsacBandwidthInfo();
|
|
|
|
|
|
|
|
|
|
IsacBandwidthInfo Get() const {
|
2016-01-20 13:39:36 +01:00
|
|
|
rtc::CritScope lock(&lock_);
|
2015-08-24 02:03:23 -07:00
|
|
|
return bwinfo_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Set(const IsacBandwidthInfo& bwinfo) {
|
2016-01-20 13:39:36 +01:00
|
|
|
rtc::CritScope lock(&lock_);
|
2015-08-24 02:03:23 -07:00
|
|
|
bwinfo_ = bwinfo;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-30 04:10:11 -07:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-24 02:03:23 -07:00
|
|
|
private:
|
2016-03-30 04:10:11 -07:00
|
|
|
mutable volatile int ref_count_;
|
2016-01-25 03:52:44 -08:00
|
|
|
rtc::CriticalSection lock_;
|
2017-09-07 07:53:45 -07:00
|
|
|
IsacBandwidthInfo bwinfo_ RTC_GUARDED_BY(lock_);
|
2015-08-24 02:03:23 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_AUDIO_CODING_CODECS_ISAC_LOCKED_BANDWIDTH_INFO_H_
|