Bug 901633 - Part 11 - Add an API in webrtc.org's output mixer to get the output channel count. r=jesup

This commit is contained in:
Paul Adenot 2015-09-01 14:25:48 +02:00
parent 77cec3e297
commit c392cc5108
3 changed files with 17 additions and 3 deletions

View File

@ -297,6 +297,11 @@ OutputMixer::GetOutputVolumePan(float& left, float& right)
return 0;
}
int OutputMixer::GetOutputChannelCount()
{
return _audioFrame.num_channels_;
}
int OutputMixer::StartRecordingPlayout(const char* fileName,
const CodecInst* codecInst)
{

View File

@ -117,6 +117,8 @@ public:
// so ExternalPlayoutData() can insert far-end audio from the audio drivers
void APMAnalyzeReverseStream(AudioFrame &audioFrame);
int GetOutputChannelCount();
private:
OutputMixer(uint32_t instanceId);
int InsertInbandDtmfTone();

View File

@ -383,16 +383,23 @@ int VoEExternalMediaImpl::ExternalPlayoutGetData(
AudioFrame audioFrame;
uint32_t channels = shared_->output_mixer()->GetOutputChannelCount();
// If we have not received any data yet, consider it's mono since it's the
// most common case.
if (channels == 0) {
channels = 1;
}
// Retrieve mixed output at the specified rate
shared_->output_mixer()->MixActiveChannels();
shared_->output_mixer()->DoOperationsOnCombinedSignal(true);
shared_->output_mixer()->GetMixedAudio(samplingFreqHz, 1, &audioFrame);
shared_->output_mixer()->GetMixedAudio(samplingFreqHz, channels, &audioFrame);
// Deliver audio (PCM) samples to the external sink
memcpy(speechData10ms,
audioFrame.data_,
sizeof(int16_t)*(audioFrame.samples_per_channel_));
lengthSamples = audioFrame.samples_per_channel_;
sizeof(int16_t)*audioFrame.samples_per_channel_*channels);
lengthSamples = audioFrame.samples_per_channel_ * channels;
// Store current playout delay (to be used by ExternalRecordingInsertData).
playout_delay_ms_ = current_delay_ms;