OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 152 |
153 if (error != 0) { | 153 if (error != 0) { |
154 LOG_FERR1(LS_WARNING, InsertPacketInternal, error); | 154 LOG_FERR1(LS_WARNING, InsertPacketInternal, error); |
155 error_code_ = error; | 155 error_code_ = error; |
156 return kFail; | 156 return kFail; |
157 } | 157 } |
158 return kOK; | 158 return kOK; |
159 } | 159 } |
160 | 160 |
161 int NetEqImpl::GetAudio(size_t max_length, int16_t* output_audio, | 161 int NetEqImpl::GetAudio(size_t max_length, int16_t* output_audio, |
162 size_t* samples_per_channel, int* num_channels, | 162 size_t* samples_per_channel, size_t* num_channels, |
163 NetEqOutputType* type) { | 163 NetEqOutputType* type) { |
164 CriticalSectionScoped lock(crit_sect_.get()); | 164 CriticalSectionScoped lock(crit_sect_.get()); |
165 LOG(LS_VERBOSE) << "GetAudio"; | 165 LOG(LS_VERBOSE) << "GetAudio"; |
166 int error = GetAudioInternal(max_length, output_audio, samples_per_channel, | 166 int error = GetAudioInternal(max_length, output_audio, samples_per_channel, |
167 num_channels); | 167 num_channels); |
168 LOG(LS_VERBOSE) << "Produced " << *samples_per_channel << | 168 LOG(LS_VERBOSE) << "Produced " << *samples_per_channel << |
169 " samples/channel for " << *num_channels << " channel(s)"; | 169 " samples/channel for " << *num_channels << " channel(s)"; |
170 if (error != 0) { | 170 if (error != 0) { |
171 LOG_FERR1(LS_WARNING, GetAudioInternal, error); | 171 LOG_FERR1(LS_WARNING, GetAudioInternal, error); |
172 error_code_ = error; | 172 error_code_ = error; |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 // but don't update statistics. | 702 // but don't update statistics. |
703 delay_manager_->set_last_pack_cng_or_dtmf(0); | 703 delay_manager_->set_last_pack_cng_or_dtmf(0); |
704 delay_manager_->ResetPacketIatCount(); | 704 delay_manager_->ResetPacketIatCount(); |
705 } | 705 } |
706 return 0; | 706 return 0; |
707 } | 707 } |
708 | 708 |
709 int NetEqImpl::GetAudioInternal(size_t max_length, | 709 int NetEqImpl::GetAudioInternal(size_t max_length, |
710 int16_t* output, | 710 int16_t* output, |
711 size_t* samples_per_channel, | 711 size_t* samples_per_channel, |
712 int* num_channels) { | 712 size_t* num_channels) { |
713 PacketList packet_list; | 713 PacketList packet_list; |
714 DtmfEvent dtmf_event; | 714 DtmfEvent dtmf_event; |
715 Operations operation; | 715 Operations operation; |
716 bool play_dtmf; | 716 bool play_dtmf; |
717 int return_value = GetDecision(&operation, &packet_list, &dtmf_event, | 717 int return_value = GetDecision(&operation, &packet_list, &dtmf_event, |
718 &play_dtmf); | 718 &play_dtmf); |
719 if (return_value != 0) { | 719 if (return_value != 0) { |
720 LOG_FERR1(LS_WARNING, GetDecision, return_value); | 720 LOG_FERR1(LS_WARNING, GetDecision, return_value); |
721 assert(false); | 721 assert(false); |
722 last_mode_ = kModeError; | 722 last_mode_ = kModeError; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 size_t num_output_samples = output_size_samples_ * sync_buffer_->Channels(); | 830 size_t num_output_samples = output_size_samples_ * sync_buffer_->Channels(); |
831 if (num_output_samples > max_length) { | 831 if (num_output_samples > max_length) { |
832 LOG(LS_WARNING) << "Output array is too short. " << max_length << " < " << | 832 LOG(LS_WARNING) << "Output array is too short. " << max_length << " < " << |
833 output_size_samples_ << " * " << sync_buffer_->Channels(); | 833 output_size_samples_ << " * " << sync_buffer_->Channels(); |
834 num_output_samples = max_length; | 834 num_output_samples = max_length; |
835 num_output_samples_per_channel = max_length / sync_buffer_->Channels(); | 835 num_output_samples_per_channel = max_length / sync_buffer_->Channels(); |
836 } | 836 } |
837 size_t samples_from_sync = | 837 size_t samples_from_sync = |
838 sync_buffer_->GetNextAudioInterleaved(num_output_samples_per_channel, | 838 sync_buffer_->GetNextAudioInterleaved(num_output_samples_per_channel, |
839 output); | 839 output); |
840 *num_channels = static_cast<int>(sync_buffer_->Channels()); | 840 *num_channels = sync_buffer_->Channels(); |
841 LOG(LS_VERBOSE) << "Sync buffer (" << *num_channels << " channel(s)):" << | 841 LOG(LS_VERBOSE) << "Sync buffer (" << *num_channels << " channel(s)):" << |
842 " insert " << algorithm_buffer_->Size() << " samples, extract " << | 842 " insert " << algorithm_buffer_->Size() << " samples, extract " << |
843 samples_from_sync << " samples"; | 843 samples_from_sync << " samples"; |
844 if (samples_from_sync != output_size_samples_) { | 844 if (samples_from_sync != output_size_samples_) { |
845 LOG_F(LS_ERROR) << "samples_from_sync != output_size_samples_"; | 845 LOG_F(LS_ERROR) << "samples_from_sync != output_size_samples_"; |
846 // TODO(minyue): treatment of under-run, filling zeros | 846 // TODO(minyue): treatment of under-run, filling zeros |
847 memset(output, 0, num_output_samples * sizeof(int16_t)); | 847 memset(output, 0, num_output_samples * sizeof(int16_t)); |
848 *samples_per_channel = output_size_samples_; | 848 *samples_per_channel = output_size_samples_; |
849 return kSampleUnderrun; | 849 return kSampleUnderrun; |
850 } | 850 } |
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1992 | 1992 |
1993 void NetEqImpl::CreateDecisionLogic() { | 1993 void NetEqImpl::CreateDecisionLogic() { |
1994 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, | 1994 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, |
1995 playout_mode_, | 1995 playout_mode_, |
1996 decoder_database_.get(), | 1996 decoder_database_.get(), |
1997 *packet_buffer_.get(), | 1997 *packet_buffer_.get(), |
1998 delay_manager_.get(), | 1998 delay_manager_.get(), |
1999 buffer_level_filter_.get())); | 1999 buffer_level_filter_.get())); |
2000 } | 2000 } |
2001 } // namespace webrtc | 2001 } // namespace webrtc |
OLD | NEW |