Removing neteq decode lock and friends
NetEq is thread-safe by virtue of it's own lock, and in r6404 the ACMISAC class was made thread-safe. Therefore, the neteq decode lock is no longer needed. R=kwiberg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/18599004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6531 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
05f1464df3
commit
eecf5e6ba7
@ -60,7 +60,6 @@ ACMGenericCodec::ACMGenericCodec()
|
||||
sent_cn_previous_(false),
|
||||
prev_frame_cng_(0),
|
||||
has_internal_fec_(false),
|
||||
neteq_decode_lock_(NULL),
|
||||
codec_wrapper_lock_(*RWLockWrapper::CreateRWLock()),
|
||||
last_timestamp_(0xD87F3F9F),
|
||||
unique_id_(0) {
|
||||
@ -210,7 +209,6 @@ int16_t ACMGenericCodec::Encode(uint8_t* bitstream,
|
||||
return 0;
|
||||
}
|
||||
WriteLockScoped lockCodec(codec_wrapper_lock_);
|
||||
ReadLockScoped lockNetEq(*neteq_decode_lock_);
|
||||
|
||||
// Not all codecs accept the whole frame to be pushed into encoder at once.
|
||||
// Some codecs needs to be feed with a specific number of samples different
|
||||
@ -394,7 +392,6 @@ int16_t ACMGenericCodec::EncoderParamsSafe(WebRtcACMCodecParams* enc_params) {
|
||||
|
||||
int16_t ACMGenericCodec::ResetEncoder() {
|
||||
WriteLockScoped lockCodec(codec_wrapper_lock_);
|
||||
ReadLockScoped lockNetEq(*neteq_decode_lock_);
|
||||
return ResetEncoderSafe();
|
||||
}
|
||||
|
||||
@ -443,7 +440,6 @@ int16_t ACMGenericCodec::InternalResetEncoder() {
|
||||
int16_t ACMGenericCodec::InitEncoder(WebRtcACMCodecParams* codec_params,
|
||||
bool force_initialization) {
|
||||
WriteLockScoped lockCodec(codec_wrapper_lock_);
|
||||
ReadLockScoped lockNetEq(*neteq_decode_lock_);
|
||||
return InitEncoderSafe(codec_params, force_initialization);
|
||||
}
|
||||
|
||||
@ -629,7 +625,6 @@ int16_t ACMGenericCodec::CreateEncoder() {
|
||||
void ACMGenericCodec::DestructEncoderInst(void* ptr_inst) {
|
||||
if (ptr_inst != NULL) {
|
||||
WriteLockScoped lockCodec(codec_wrapper_lock_);
|
||||
ReadLockScoped lockNetEq(*neteq_decode_lock_);
|
||||
InternalDestructEncoderInst(ptr_inst);
|
||||
}
|
||||
}
|
||||
|
@ -293,17 +293,6 @@ class ACMGenericCodec {
|
||||
//
|
||||
int32_t IsInternalDTXReplaced(bool* internal_dtx_replaced);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// void SetNetEqDecodeLock()
|
||||
// Passes the NetEq lock to the codec.
|
||||
//
|
||||
// Input:
|
||||
// -neteq_decode_lock : pointer to the lock associated with NetEQ of ACM.
|
||||
//
|
||||
void SetNetEqDecodeLock(RWLockWrapper* neteq_decode_lock) {
|
||||
neteq_decode_lock_ = neteq_decode_lock;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// bool HasInternalDTX()
|
||||
// Used to check if the codec has internal DTX.
|
||||
@ -965,10 +954,6 @@ class ACMGenericCodec {
|
||||
|
||||
WebRtcACMCodecParams encoder_params_ GUARDED_BY(codec_wrapper_lock_);
|
||||
|
||||
// Used as a global lock for all available decoders
|
||||
// so that no decoder is used when NetEQ decodes.
|
||||
RWLockWrapper* neteq_decode_lock_;
|
||||
|
||||
// Used to lock wrapper internal data
|
||||
// such as buffers and state variables.
|
||||
RWLockWrapper& codec_wrapper_lock_;
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/logging.h"
|
||||
#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/tick_util.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
@ -126,7 +125,6 @@ AcmReceiver::AcmReceiver(const AudioCodingModule::Config& config)
|
||||
nack_(),
|
||||
nack_enabled_(false),
|
||||
neteq_(NetEq::Create(config.neteq_config)),
|
||||
decode_lock_(RWLockWrapper::CreateRWLock()),
|
||||
vad_enabled_(true),
|
||||
clock_(config.clock),
|
||||
av_sync_(false),
|
||||
@ -149,7 +147,6 @@ AcmReceiver::AcmReceiver(const AudioCodingModule::Config& config)
|
||||
|
||||
AcmReceiver::~AcmReceiver() {
|
||||
delete neteq_;
|
||||
delete decode_lock_;
|
||||
}
|
||||
|
||||
int AcmReceiver::SetMinimumDelay(int delay_ms) {
|
||||
@ -331,22 +328,18 @@ int AcmReceiver::InsertPacket(const WebRtcRTPHeader& rtp_header,
|
||||
}
|
||||
} // |crit_sect_| is released.
|
||||
|
||||
{
|
||||
WriteLockScoped lock_codecs(*decode_lock_); // Lock to prevent an encoding.
|
||||
// If |missing_packets_sync_stream_| is allocated then we are in AV-sync and
|
||||
// we may need to insert sync-packets. We don't check |av_sync_| as we are
|
||||
// outside AcmReceiver's critical section.
|
||||
if (missing_packets_sync_stream_.get()) {
|
||||
InsertStreamOfSyncPackets(missing_packets_sync_stream_.get());
|
||||
}
|
||||
|
||||
// If |missing_packets_sync_stream_| is allocated then we are in AV-sync and
|
||||
// we may need to insert sync-packets. We don't check |av_sync_| as we are
|
||||
// outside AcmReceiver's critical section.
|
||||
if (missing_packets_sync_stream_.get()) {
|
||||
InsertStreamOfSyncPackets(missing_packets_sync_stream_.get());
|
||||
}
|
||||
|
||||
if (neteq_->InsertPacket(rtp_header, incoming_payload, length_payload,
|
||||
receive_timestamp) < 0) {
|
||||
LOG_FERR1(LS_ERROR, "AcmReceiver::InsertPacket", header->payloadType) <<
|
||||
" Failed to insert packet";
|
||||
return -1;
|
||||
}
|
||||
if (neteq_->InsertPacket(rtp_header, incoming_payload, length_payload,
|
||||
receive_timestamp) < 0) {
|
||||
LOG_FERR1(LS_ERROR, "AcmReceiver::InsertPacket", header->payloadType) <<
|
||||
" Failed to insert packet";
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -384,24 +377,20 @@ int AcmReceiver::GetAudio(int desired_freq_hz, AudioFrame* audio_frame) {
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
WriteLockScoped lock_codecs(*decode_lock_); // Lock to prevent an encoding.
|
||||
// If |late_packets_sync_stream_| is allocated then we have been in AV-sync
|
||||
// mode and we might have to insert sync-packets.
|
||||
if (late_packets_sync_stream_.get()) {
|
||||
InsertStreamOfSyncPackets(late_packets_sync_stream_.get());
|
||||
if (return_silence) // Silence generated, don't pull from NetEq.
|
||||
return 0;
|
||||
}
|
||||
|
||||
// If |late_packets_sync_stream_| is allocated then we have been in AV-sync
|
||||
// mode and we might have to insert sync-packets.
|
||||
if (late_packets_sync_stream_.get()) {
|
||||
InsertStreamOfSyncPackets(late_packets_sync_stream_.get());
|
||||
if (return_silence) // Silence generated, don't pull from NetEq.
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (neteq_->GetAudio(AudioFrame::kMaxDataSizeSamples,
|
||||
ptr_audio_buffer,
|
||||
&samples_per_channel,
|
||||
&num_channels, &type) != NetEq::kOK) {
|
||||
LOG_FERR0(LS_ERROR, "AcmReceiver::GetAudio") << "NetEq Failed.";
|
||||
return -1;
|
||||
}
|
||||
if (neteq_->GetAudio(AudioFrame::kMaxDataSizeSamples,
|
||||
ptr_audio_buffer,
|
||||
&samples_per_channel,
|
||||
&num_channels, &type) != NetEq::kOK) {
|
||||
LOG_FERR0(LS_ERROR, "AcmReceiver::GetAudio") << "NetEq Failed.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Accessing members, take the lock.
|
||||
|
@ -30,7 +30,6 @@ namespace webrtc {
|
||||
|
||||
struct CodecInst;
|
||||
class CriticalSectionWrapper;
|
||||
class RWLockWrapper;
|
||||
class NetEq;
|
||||
|
||||
namespace acm2 {
|
||||
@ -209,13 +208,6 @@ class AcmReceiver {
|
||||
//
|
||||
bool vad_enabled() const { return vad_enabled_; }
|
||||
|
||||
//
|
||||
// Get the decode lock used to protect decoder instances while decoding.
|
||||
//
|
||||
// Return value : Pointer to the decode lock.
|
||||
//
|
||||
RWLockWrapper* DecodeLock() const { return decode_lock_; }
|
||||
|
||||
//
|
||||
// Flushes the NetEq packet and speech buffers.
|
||||
//
|
||||
@ -354,7 +346,6 @@ class AcmReceiver {
|
||||
CallStatistics call_stats_ GUARDED_BY(crit_sect_);
|
||||
NetEq* neteq_;
|
||||
Decoder decoders_[ACMCodecDB::kMaxNumCodecs];
|
||||
RWLockWrapper* decode_lock_;
|
||||
bool vad_enabled_;
|
||||
Clock* clock_; // TODO(henrik.lundin) Make const if possible.
|
||||
|
||||
|
@ -749,7 +749,6 @@ ACMGenericCodec* AudioCodingModuleImpl::CreateCodec(const CodecInst& codec) {
|
||||
return my_codec;
|
||||
}
|
||||
my_codec->SetUniqueID(id_);
|
||||
my_codec->SetNetEqDecodeLock(receiver_.DecodeLock());
|
||||
|
||||
return my_codec;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user