diff --git a/src/modules/audio_coding/main/source/audio_coding_module_impl.cc b/src/modules/audio_coding/main/source/audio_coding_module_impl.cc index 75adb8998..79fff303e 100644 --- a/src/modules/audio_coding/main/source/audio_coding_module_impl.cc +++ b/src/modules/audio_coding/main/source/audio_coding_module_impl.cc @@ -322,35 +322,34 @@ AudioCodingModuleImpl::TimeUntilNextProcess() } // Process any pending tasks such as timeouts -WebRtc_Word32 +WebRtc_Word32 AudioCodingModuleImpl::Process() { WebRtc_UWord8 bitStream[2 * MAX_PAYLOAD_SIZE_BYTE]; // Make room for 1 RED payload WebRtc_Word16 lengthBytes = 2 * MAX_PAYLOAD_SIZE_BYTE; + WebRtc_Word16 redLengthBytes = lengthBytes; WebRtc_UWord32 rtpTimestamp; WebRtc_Word16 status; WebRtcACMEncodingType encodingType; FrameType frameType = kAudioFrameSpeech; - WebRtc_Word16 redLengthBytes; WebRtc_UWord8 currentPayloadType; bool hasDataToSend = false; bool fecActive = false; - WebRtc_UWord32 dummyFragLength; - + // keep the scope of the ACM critical section limited { CriticalSectionScoped lock(*_acmCritSect); if(!HaveValidEncoder("Process")) - { + { return -1; } - - status = _codecs[_currentSendCodecIdx]->Encode(bitStream, &lengthBytes, - &rtpTimestamp, &encodingType); + + status = _codecs[_currentSendCodecIdx]->Encode(bitStream, &lengthBytes, + &rtpTimestamp, &encodingType); if (status < 0) // Encode failed { // logging error - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, + WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, "Process(): Encoding Failed"); lengthBytes = 0; return -1; @@ -415,7 +414,6 @@ AudioCodingModuleImpl::Process() // one RTP packet and the fragmentation points // are set. // Only apply RED on speech data. - if((_fecEnabled) && ((encodingType == kActiveNormalEncoded) || (encodingType == kPassiveNormalEncoded))) @@ -481,12 +479,12 @@ AudioCodingModuleImpl::Process() // Insert new packet length. _fragmentation->fragmentationLength[0] = lengthBytes; - + // Insert new packet payload type. _fragmentation->fragmentationPlType[0] = currentPayloadType; _lastFECTimestamp = rtpTimestamp; - // can be modified by the getRedPayload() call if iSAC is utilized + // can be modified by the GetRedPayload() call if iSAC is utilized redLengthBytes = lengthBytes; // A fragmentation header is provided => packetization according to RFC 2198 // (RTP Payload for Redundant Audio Data) will be used. @@ -505,11 +503,8 @@ AudioCodingModuleImpl::Process() { // The codec was not iSAC => use current encoder output as redundant data // instead (trivial FEC scheme) - memcpy(_redBuffer, bitStream, redLengthBytes); + memcpy(_redBuffer, bitStream, redLengthBytes); } - - // Temporary storing RED length - dummyFragLength = redLengthBytes; _isFirstRED = false; // Update payload type with RED payload type @@ -533,10 +528,10 @@ AudioCodingModuleImpl::Process() if(_packetizationCallback != NULL) { if (fecActive) { - _packetizationCallback->SendData(frameType, currentPayloadType, + _packetizationCallback->SendData(frameType, currentPayloadType, rtpTimestamp, bitStream, lengthBytes, _fragmentation); } else { - _packetizationCallback->SendData(frameType, currentPayloadType, + _packetizationCallback->SendData(frameType, currentPayloadType, rtpTimestamp, bitStream, lengthBytes, NULL); } } @@ -548,7 +543,7 @@ AudioCodingModuleImpl::Process() } } if (fecActive) { - _fragmentation->fragmentationLength[1] = dummyFragLength; + _fragmentation->fragmentationLength[1] = redLengthBytes; } return lengthBytes; } diff --git a/src/video_engine/main/source/vie_file_recorder.cc b/src/video_engine/main/source/vie_file_recorder.cc index 547cc1449..b24cb6ed2 100644 --- a/src/video_engine/main/source/vie_file_recorder.cc +++ b/src/video_engine/main/source/vie_file_recorder.cc @@ -133,7 +133,7 @@ int ViEFileRecorder::StartRecording(const char* fileNameUTF8, int ViEFileRecorder::StopRecording() { - int error; + int error = 0; // Stop recording audio // Note - we can not hold the _ptrCritSect while accessing VE functions. It might cause deadlock in Write if (_veFileInterface) diff --git a/src/video_engine/main/source/vie_sender.cc b/src/video_engine/main/source/vie_sender.cc index 3315f4db6..46dc03165 100644 --- a/src/video_engine/main/source/vie_sender.cc +++ b/src/video_engine/main/source/vie_sender.cc @@ -304,8 +304,7 @@ int ViESender::SendPacket(int vieId, const void *data, int len) return -1; } - int channelId = ChannelId(vieId); - assert(channelId == _channelId); + assert(ChannelId(vieId) == _channelId); // Prepare for possible encryption and sending WebRtc_UWord8* sendPacket = (WebRtc_UWord8*) data; @@ -356,8 +355,8 @@ int ViESender::SendRTCPPacket(int vieId, const void *data, int len) // No transport return -1; } - int channelId = ChannelId(vieId); - assert(channelId == _channelId); + + assert(ChannelId(vieId) == _channelId); // Prepare for possible encryption and sending WebRtc_UWord8* sendPacket = (WebRtc_UWord8*) data; diff --git a/src/video_engine/main/test/AutoTest/source/vie_autotest_main.cc b/src/video_engine/main/test/AutoTest/source/vie_autotest_main.cc index 130dc44e9..0480fda2d 100644 --- a/src/video_engine/main/test/AutoTest/source/vie_autotest_main.cc +++ b/src/video_engine/main/test/AutoTest/source/vie_autotest_main.cc @@ -90,7 +90,13 @@ bool ViEAutoTestMain::BeginOSIndependentTesting() } else { - scanf("%d", &testType); + if (scanf("%d", &testType) <= 0) + { + ViETest::Log("ERROR: unable to read selection. Try again\n"); + testType = -1; + getchar(); + continue; + } getchar(); } ViETest::Log(""); diff --git a/src/voice_engine/main/source/channel.cc b/src/voice_engine/main/source/channel.cc index 21334a58e..a031b9d8a 100644 --- a/src/voice_engine/main/source/channel.cc +++ b/src/voice_engine/main/source/channel.cc @@ -639,8 +639,7 @@ Channel::OnInitializeDecoder( "payloadName=%s, frequency=%u, channels=%u, rate=%u)", id, payloadType, payloadName, frequency, channels, rate); - WebRtc_Word32 channel = VoEChannelId(id); - assert(channel == _channelId); + assert(VoEChannelId(id) == _channelId); CodecInst receiveCodec; CodecInst dummyCodec; @@ -658,7 +657,7 @@ Channel::OnInitializeDecoder( if (_audioCodingModule.RegisterReceiveCodec(receiveCodec) == -1) { WEBRTC_TRACE(kTraceWarning, kTraceVoice, - VoEId(_instanceId,_channelId), + VoEId(_instanceId, _channelId), "Channel::OnInitializeDecoder() invalid codec (" "pt=%d, name=%s) received - 1", payloadType, payloadName); _engineStatisticsPtr->SetLastError(VE_AUDIO_CODING_MODULE_ERROR); @@ -703,8 +702,7 @@ Channel::OnReceivedPacket(const WebRtc_Word32 id, "Channel::OnReceivedPacket(id=%d, packetType=%d)", id, packetType); - WebRtc_Word32 channel = VoEChannelId(id); - assert(channel == _channelId); + assert(VoEChannelId(id) == _channelId); // Notify only for the case when we have restarted an RTP session. if (_rtpPacketTimedOut && (kPacketRtp == packetType))