The Cl is to support mixing output file in a stereo stream.

Previously, an assert will be triggered in case it is not a mono stream.
With the CL, the mono file stream will be copied into a strereo stream and mixed with the channel stream.

More detail about the fix please refer to 
http://code.google.com/p/webrtc/issues/detail?id=36
Review URL: http://webrtc-codereview.appspot.com/93020

git-svn-id: http://webrtc.googlecode.com/svn/trunk@322 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
xians@google.com
2011-08-08 12:02:36 +00:00
parent 0922815173
commit 4257b175f3

View File

@ -879,7 +879,6 @@ WebRtc_Word32 Channel::GetAudioFrame(const WebRtc_Word32 id,
// Mix decoded PCM output with file if file mixing is enabled // Mix decoded PCM output with file if file mixing is enabled
if (_outputFilePlaying) if (_outputFilePlaying)
{ {
assert(audioFrame._audioChannel == 1);
MixAudioWithFile(audioFrame, audioFrame._frequencyInHz); MixAudioWithFile(audioFrame, audioFrame._frequencyInHz);
} }
@ -6282,7 +6281,7 @@ Channel::MixAudioWithFile(AudioFrame& audioFrame,
{ {
assert(mixingFrequency <= 32000); assert(mixingFrequency <= 32000);
WebRtc_Word16 fileBuffer[320]; WebRtc_Word16 fileBuffer[640];
WebRtc_UWord32 fileSamples(0); WebRtc_UWord32 fileSamples(0);
{ {
@ -6310,6 +6309,25 @@ Channel::MixAudioWithFile(AudioFrame& audioFrame,
if (audioFrame._payloadDataLengthInSamples == fileSamples) if (audioFrame._payloadDataLengthInSamples == fileSamples)
{ {
// In case the incoming stream is stereo and file stream is mono,
// turn the file stream into stereo.
// TODO(xians): remove the code when FilePlayer supports real stereo.
if (audioFrame._audioChannel == 2)
{
// The mono file stream is copied to be stereo.
WebRtc_Word16* FileBufferCopy = new WebRtc_Word16[fileSamples];
memcpy(FileBufferCopy, fileBuffer,
sizeof(WebRtc_Word16) * fileSamples);
for (unsigned int i = 0; i < fileSamples; i++)
{
fileBuffer[2*i] = FileBufferCopy[i];
fileBuffer[2*i+1] = FileBufferCopy[i];
}
fileSamples = 2*fileSamples;
delete [] FileBufferCopy;
}
// Mix the incoming stream and file stream.
Utility::MixWithSat(audioFrame._payloadData, Utility::MixWithSat(audioFrame._payloadData,
fileBuffer, fileBuffer,
(WebRtc_UWord16)fileSamples); (WebRtc_UWord16)fileSamples);