2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-06-28 07:29:46 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2012-06-28 07:29:46 +00:00
|
|
|
#include <assert.h>
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-05-17 13:44:48 +00:00
|
|
|
#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
|
|
|
|
|
#include "webrtc/video_engine/vie_manager_base.h"
|
2011-12-14 08:18:42 +00:00
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
namespace webrtc {
|
|
|
|
|
|
2011-12-14 08:18:42 +00:00
|
|
|
ViEManagerBase::ViEManagerBase()
|
|
|
|
|
: instance_rwlock_(*RWLockWrapper::CreateRWLock()) {
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2011-12-14 08:18:42 +00:00
|
|
|
|
|
|
|
|
ViEManagerBase::~ViEManagerBase() {
|
|
|
|
|
delete &instance_rwlock_;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2011-12-14 08:18:42 +00:00
|
|
|
void ViEManagerBase::ReadLockManager() const {
|
|
|
|
|
instance_rwlock_.AcquireLockShared();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2011-12-14 08:18:42 +00:00
|
|
|
void ViEManagerBase::ReleaseLockManager() const {
|
|
|
|
|
instance_rwlock_.ReleaseLockShared();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2011-12-14 08:18:42 +00:00
|
|
|
void ViEManagerBase::WriteLockManager() {
|
|
|
|
|
instance_rwlock_.AcquireLockExclusive();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2011-12-14 08:18:42 +00:00
|
|
|
void ViEManagerBase::ReleaseWriteLockManager() {
|
|
|
|
|
instance_rwlock_.ReleaseLockExclusive();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2011-12-14 08:18:42 +00:00
|
|
|
ViEManagerScopedBase::ViEManagerScopedBase(const ViEManagerBase& ViEManagerBase)
|
|
|
|
|
: vie_manager_(&ViEManagerBase),
|
|
|
|
|
ref_count_(0) {
|
|
|
|
|
vie_manager_->ReadLockManager();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2011-12-14 08:18:42 +00:00
|
|
|
ViEManagerScopedBase::~ViEManagerScopedBase() {
|
|
|
|
|
assert(ref_count_ == 0);
|
|
|
|
|
vie_manager_->ReleaseLockManager();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2012-06-28 07:29:46 +00:00
|
|
|
ViEManagerWriteScoped::ViEManagerWriteScoped(ViEManagerBase* vie_manager)
|
|
|
|
|
: vie_manager_(vie_manager) {
|
2011-12-14 08:18:42 +00:00
|
|
|
vie_manager_->WriteLockManager();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2011-12-14 08:18:42 +00:00
|
|
|
ViEManagerWriteScoped::~ViEManagerWriteScoped() {
|
|
|
|
|
vie_manager_->ReleaseWriteLockManager();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ViEManagedItemScopedBase::ViEManagedItemScopedBase(
|
2012-06-28 07:29:46 +00:00
|
|
|
ViEManagerScopedBase* vie_scoped_manager)
|
2011-12-14 08:18:42 +00:00
|
|
|
: vie_scoped_manager_(vie_scoped_manager) {
|
2012-06-28 07:29:46 +00:00
|
|
|
vie_scoped_manager_->ref_count_++;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2011-12-14 08:18:42 +00:00
|
|
|
ViEManagedItemScopedBase::~ViEManagedItemScopedBase() {
|
2012-06-28 07:29:46 +00:00
|
|
|
vie_scoped_manager_->ref_count_--;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2011-12-14 08:18:42 +00:00
|
|
|
|
|
|
|
|
} // namespace webrtc
|