summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorminyue@webrtc.org <minyue@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2014-07-18 12:28:28 +0000
committerminyue@webrtc.org <minyue@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2014-07-18 12:28:28 +0000
commitd89fa97356bc1a276fd1319f3b57232f2e8cdc01 (patch)
tree175828d54d726861a29f80ec9c0fdfde3e93efe4 /modules
parentc6176548bfae24bcd7ff110d13a7e5139ef6bdb9 (diff)
downloadwebrtc-d89fa97356bc1a276fd1319f3b57232f2e8cdc01.tar.gz
This is related to an earlier CL of enabling Opus 48 kHz.
https://webrtc-codereview.appspot.com/16619005/ It was reverted due to a build bot error, which this CL is to fix. The problem was that when audio conference mixer receives audio frames all at 48 kHz and mixed them, it uses Audio Processing Module (APM) to do a post-processing. However the APM cannot handle 48 kHz input. The current solution is not to allow the mixer to output 48 kHz. TEST=locally solved https://webrtc-codereview.appspot.com/16619005/ BUG= R=andrew@webrtc.org Review URL: https://webrtc-codereview.appspot.com/20779004 git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@6730 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'modules')
-rw-r--r--modules/audio_conference_mixer/source/audio_conference_mixer_impl.cc38
-rw-r--r--modules/audio_conference_mixer/source/audio_conference_mixer_impl.h3
2 files changed, 19 insertions, 22 deletions
diff --git a/modules/audio_conference_mixer/source/audio_conference_mixer_impl.cc b/modules/audio_conference_mixer/source/audio_conference_mixer_impl.cc
index bc97ec20..6ef6166b 100644
--- a/modules/audio_conference_mixer/source/audio_conference_mixer_impl.cc
+++ b/modules/audio_conference_mixer/source/audio_conference_mixer_impl.cc
@@ -32,10 +32,13 @@ typedef std::list<ParticipantFramePair*> ParticipantFramePairList;
// stereo at most.
//
// TODO(andrew): consider not modifying |frame| here.
-void MixFrames(AudioFrame* mixed_frame, AudioFrame* frame) {
+void MixFrames(AudioFrame* mixed_frame, AudioFrame* frame, bool use_limiter) {
assert(mixed_frame->num_channels_ >= frame->num_channels_);
- // Divide by two to avoid saturation in the mixing.
- *frame >>= 1;
+ if (use_limiter) {
+ // Divide by two to avoid saturation in the mixing.
+ // This is only meaningful if the limiter will be used.
+ *frame >>= 1;
+ }
if (mixed_frame->num_channels_ > frame->num_channels_) {
// We only support mono-to-stereo.
assert(mixed_frame->num_channels_ == 2 &&
@@ -131,6 +134,7 @@ AudioConferenceMixerImpl::AudioConferenceMixerImpl(int id)
_participantList(),
_additionalParticipantList(),
_numMixedParticipants(0),
+ use_limiter_(true),
_timeStamp(0),
_timeScheduler(kProcessPeriodicityInMs),
_mixedAudioLevel(),
@@ -308,6 +312,11 @@ int32_t AudioConferenceMixerImpl::Process() {
_timeStamp += _sampleSize;
+ // We only use the limiter if it supports the output sample rate and
+ // we're actually mixing multiple streams.
+ use_limiter_ = _numMixedParticipants > 1 &&
+ _outputFrequency <= kAudioProcMaxNativeSampleRateHz;
+
MixFromList(*mixedAudio, &mixList);
MixAnonomouslyFromList(*mixedAudio, &additionalFramesList);
MixAnonomouslyFromList(*mixedAudio, &rampOutList);
@@ -946,14 +955,6 @@ int32_t AudioConferenceMixerImpl::MixFromList(
if(audioFrameList->empty()) return 0;
uint32_t position = 0;
- if(_numMixedParticipants == 1) {
- // No mixing required here; skip the saturation protection.
- AudioFrame* audioFrame = audioFrameList->front();
- mixedAudio.CopyFrom(*audioFrame);
- SetParticipantStatistics(&_scratchMixedParticipants[position],
- *audioFrame);
- return 0;
- }
if (_numMixedParticipants == 1) {
mixedAudio.timestamp_ = audioFrameList->front()->timestamp_;
@@ -979,7 +980,7 @@ int32_t AudioConferenceMixerImpl::MixFromList(
assert(false);
position = 0;
}
- MixFrames(&mixedAudio, (*iter));
+ MixFrames(&mixedAudio, (*iter), use_limiter_);
SetParticipantStatistics(&_scratchMixedParticipants[position],
**iter);
@@ -999,24 +1000,17 @@ int32_t AudioConferenceMixerImpl::MixAnonomouslyFromList(
if(audioFrameList->empty()) return 0;
- if(_numMixedParticipants == 1) {
- // No mixing required here; skip the saturation protection.
- AudioFrame* audioFrame = audioFrameList->front();
- mixedAudio.CopyFrom(*audioFrame);
- return 0;
- }
-
for (AudioFrameList::const_iterator iter = audioFrameList->begin();
iter != audioFrameList->end();
++iter) {
- MixFrames(&mixedAudio, *iter);
+ MixFrames(&mixedAudio, *iter, use_limiter_);
}
return 0;
}
bool AudioConferenceMixerImpl::LimitMixedAudio(AudioFrame& mixedAudio) {
- if(_numMixedParticipants == 1) {
- return true;
+ if (!use_limiter_) {
+ return true;
}
// Smoothly limit the mixed frame.
diff --git a/modules/audio_conference_mixer/source/audio_conference_mixer_impl.h b/modules/audio_conference_mixer/source/audio_conference_mixer_impl.h
index 31dc71e5..44f4ff04 100644
--- a/modules/audio_conference_mixer/source/audio_conference_mixer_impl.h
+++ b/modules/audio_conference_mixer/source/audio_conference_mixer_impl.h
@@ -192,6 +192,9 @@ private:
MixerParticipantList _additionalParticipantList;
size_t _numMixedParticipants;
+ // Determines if we will use a limiter for clipping protection during
+ // mixing.
+ bool use_limiter_;
uint32_t _timeStamp;