зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1456115 - Remove locking in AcmReceiver::GetAudio. r=dminor
This also causes a lot of dropouts. We don't need to lock here. NetEQ is thread safe, and its created in the ctor. The rest of the members are made atomic or is simply never accessed in multiple threads. MozReview-Commit-ID: 2fRw5ZgxdpQ --HG-- extra : rebase_source : f2aa082a3e856e873cfcd96ff721ccdc77df3633
This commit is contained in:
Родитель
581308e902
Коммит
2d783a2f32
|
@ -203,7 +203,7 @@ webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const {
|
|||
stats.accelerate_rate = Q14ToFloat(ns.currentAccelerateRate);
|
||||
stats.preemptive_expand_rate = Q14ToFloat(ns.currentPreemptiveRate);
|
||||
|
||||
auto ds = channel_proxy_->GetDecodingCallStatistics();
|
||||
auto ds(channel_proxy_->GetDecodingCallStatistics());
|
||||
stats.decoding_calls_to_silence_generator = ds.calls_to_silence_generator;
|
||||
stats.decoding_calls_to_neteq = ds.calls_to_neteq;
|
||||
stats.decoding_normal = ds.decoded_normal;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -408,14 +409,37 @@ struct AudioDecodingCallStats {
|
|||
decoded_plc_cng(0),
|
||||
decoded_muted_output(0) {}
|
||||
|
||||
int calls_to_silence_generator; // Number of calls where silence generated,
|
||||
AudioDecodingCallStats(const AudioDecodingCallStats& other)
|
||||
{
|
||||
calls_to_silence_generator = other.calls_to_silence_generator.load();
|
||||
calls_to_neteq = other.calls_to_neteq.load();
|
||||
decoded_normal = other.decoded_normal.load();
|
||||
decoded_plc = other.decoded_plc.load();
|
||||
decoded_cng = other.decoded_cng.load();
|
||||
decoded_plc_cng = other.decoded_plc_cng.load();
|
||||
decoded_muted_output = other.decoded_muted_output.load();
|
||||
}
|
||||
|
||||
AudioDecodingCallStats& operator=(const AudioDecodingCallStats& other)
|
||||
{
|
||||
calls_to_silence_generator = other.calls_to_silence_generator.load();
|
||||
calls_to_neteq = other.calls_to_neteq.load();
|
||||
decoded_normal = other.decoded_normal.load();
|
||||
decoded_plc = other.decoded_plc.load();
|
||||
decoded_cng = other.decoded_cng.load();
|
||||
decoded_plc_cng = other.decoded_plc_cng.load();
|
||||
decoded_muted_output = other.decoded_muted_output.load();
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::atomic<int> calls_to_silence_generator; // Number of calls where silence generated,
|
||||
// and NetEq was disengaged from decoding.
|
||||
int calls_to_neteq; // Number of calls to NetEq.
|
||||
int decoded_normal; // Number of calls where audio RTP packet decoded.
|
||||
int decoded_plc; // Number of calls resulted in PLC.
|
||||
int decoded_cng; // Number of calls where comfort noise generated due to DTX.
|
||||
int decoded_plc_cng; // Number of calls resulted where PLC faded to CNG.
|
||||
int decoded_muted_output; // Number of calls returning a muted state output.
|
||||
std::atomic<int> calls_to_neteq; // Number of calls to NetEq.
|
||||
std::atomic<int> decoded_normal; // Number of calls where audio RTP packet decoded.
|
||||
std::atomic<int> decoded_plc; // Number of calls resulted in PLC.
|
||||
std::atomic<int> decoded_cng; // Number of calls where comfort noise generated due to DTX.
|
||||
std::atomic<int> decoded_plc_cng; // Number of calls resulted where PLC faded to CNG.
|
||||
std::atomic<int> decoded_muted_output; // Number of calls returning a muted state output.
|
||||
};
|
||||
|
||||
// Type of Noise Suppression.
|
||||
|
|
|
@ -119,9 +119,6 @@ int AcmReceiver::GetAudio(int desired_freq_hz,
|
|||
AudioFrame* audio_frame,
|
||||
bool* muted) {
|
||||
RTC_DCHECK(muted);
|
||||
// Accessing members, take the lock.
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
|
||||
if (neteq_->GetAudio(audio_frame, muted) != NetEq::kOK) {
|
||||
LOG(LERROR) << "AcmReceiver::GetAudio - NetEq Failed.";
|
||||
return -1;
|
||||
|
|
|
@ -278,11 +278,13 @@ class AcmReceiver {
|
|||
rtc::Optional<CodecInst> last_audio_decoder_ GUARDED_BY(crit_sect_);
|
||||
rtc::Optional<SdpAudioFormat> last_audio_format_ GUARDED_BY(crit_sect_);
|
||||
ACMResampler resampler_ GUARDED_BY(crit_sect_);
|
||||
std::unique_ptr<int16_t[]> last_audio_buffer_ GUARDED_BY(crit_sect_);
|
||||
// After construction, this is only ever touched on the thread that calls
|
||||
// AcmReceiver::GetAudio, and only modified in this method.
|
||||
std::unique_ptr<int16_t[]> last_audio_buffer_;
|
||||
CallStatistics call_stats_ GUARDED_BY(crit_sect_);
|
||||
NetEq* neteq_;
|
||||
NetEq* const neteq_;
|
||||
Clock* clock_; // TODO(henrik.lundin) Make const if possible.
|
||||
bool resampled_last_output_frame_ GUARDED_BY(crit_sect_);
|
||||
std::atomic<bool> resampled_last_output_frame_;
|
||||
rtc::Optional<int> last_packet_sample_rate_hz_ GUARDED_BY(crit_sect_);
|
||||
std::atomic<int> last_audio_format_clockrate_hz_;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче