Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: voice_engine/voe_base_impl.cc

Issue 3019513002: Remove the VoiceEngineObserver callback interface. (Closed)
Patch Set: rebase + build error Created 3 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « voice_engine/voe_base_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
28 VoEBase* VoEBase::GetInterface(VoiceEngine* voiceEngine) { 28 VoEBase* VoEBase::GetInterface(VoiceEngine* voiceEngine) {
29 if (nullptr == voiceEngine) { 29 if (nullptr == voiceEngine) {
30 return nullptr; 30 return nullptr;
31 } 31 }
32 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine); 32 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine);
33 s->AddRef(); 33 s->AddRef();
34 return s; 34 return s;
35 } 35 }
36 36
37 VoEBaseImpl::VoEBaseImpl(voe::SharedData* shared) 37 VoEBaseImpl::VoEBaseImpl(voe::SharedData* shared)
38 : voiceEngineObserverPtr_(nullptr), 38 : shared_(shared) {}
39 shared_(shared) {}
40 39
41 VoEBaseImpl::~VoEBaseImpl() { 40 VoEBaseImpl::~VoEBaseImpl() {
42 TerminateInternal(); 41 TerminateInternal();
43 } 42 }
44 43
45 void VoEBaseImpl::OnErrorIsReported(const ErrorCode error) { 44 void VoEBaseImpl::OnErrorIsReported(const ErrorCode error) {
46 rtc::CritScope cs(&callbackCritSect_); 45 rtc::CritScope cs(&callbackCritSect_);
47 int errCode = 0;
48 if (error == AudioDeviceObserver::kRecordingError) { 46 if (error == AudioDeviceObserver::kRecordingError) {
49 errCode = VE_RUNTIME_REC_ERROR;
50 LOG_F(LS_ERROR) << "VE_RUNTIME_REC_ERROR"; 47 LOG_F(LS_ERROR) << "VE_RUNTIME_REC_ERROR";
51 } else if (error == AudioDeviceObserver::kPlayoutError) { 48 } else if (error == AudioDeviceObserver::kPlayoutError) {
52 errCode = VE_RUNTIME_PLAY_ERROR;
53 LOG_F(LS_ERROR) << "VE_RUNTIME_PLAY_ERROR"; 49 LOG_F(LS_ERROR) << "VE_RUNTIME_PLAY_ERROR";
54 } 50 }
55 if (voiceEngineObserverPtr_) {
56 // Deliver callback (-1 <=> no channel dependency)
57 voiceEngineObserverPtr_->CallbackOnError(-1, errCode);
58 }
59 } 51 }
60 52
61 void VoEBaseImpl::OnWarningIsReported(const WarningCode warning) { 53 void VoEBaseImpl::OnWarningIsReported(const WarningCode warning) {
62 rtc::CritScope cs(&callbackCritSect_); 54 rtc::CritScope cs(&callbackCritSect_);
63 int warningCode = 0;
64 if (warning == AudioDeviceObserver::kRecordingWarning) { 55 if (warning == AudioDeviceObserver::kRecordingWarning) {
65 warningCode = VE_RUNTIME_REC_WARNING;
66 LOG_F(LS_WARNING) << "VE_RUNTIME_REC_WARNING"; 56 LOG_F(LS_WARNING) << "VE_RUNTIME_REC_WARNING";
67 } else if (warning == AudioDeviceObserver::kPlayoutWarning) { 57 } else if (warning == AudioDeviceObserver::kPlayoutWarning) {
68 warningCode = VE_RUNTIME_PLAY_WARNING;
69 LOG_F(LS_WARNING) << "VE_RUNTIME_PLAY_WARNING"; 58 LOG_F(LS_WARNING) << "VE_RUNTIME_PLAY_WARNING";
70 } 59 }
71 if (voiceEngineObserverPtr_) {
72 // Deliver callback (-1 <=> no channel dependency)
73 voiceEngineObserverPtr_->CallbackOnError(-1, warningCode);
74 }
75 } 60 }
76 61
77 int32_t VoEBaseImpl::RecordedDataIsAvailable( 62 int32_t VoEBaseImpl::RecordedDataIsAvailable(
78 const void* audio_data, 63 const void* audio_data,
79 const size_t number_of_frames, 64 const size_t number_of_frames,
80 const size_t bytes_per_sample, 65 const size_t bytes_per_sample,
81 const size_t number_of_channels, 66 const size_t number_of_channels,
82 const uint32_t sample_rate, 67 const uint32_t sample_rate,
83 const uint32_t audio_delay_milliseconds, 68 const uint32_t audio_delay_milliseconds,
84 const int32_t clock_drift, 69 const int32_t clock_drift,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 153
169 void VoEBaseImpl::PullRenderData(int bits_per_sample, 154 void VoEBaseImpl::PullRenderData(int bits_per_sample,
170 int sample_rate, 155 int sample_rate,
171 size_t number_of_channels, 156 size_t number_of_channels,
172 size_t number_of_frames, 157 size_t number_of_frames,
173 void* audio_data, int64_t* elapsed_time_ms, 158 void* audio_data, int64_t* elapsed_time_ms,
174 int64_t* ntp_time_ms) { 159 int64_t* ntp_time_ms) {
175 RTC_NOTREACHED(); 160 RTC_NOTREACHED();
176 } 161 }
177 162
178 int VoEBaseImpl::RegisterVoiceEngineObserver(VoiceEngineObserver& observer) {
179 rtc::CritScope cs(&callbackCritSect_);
180 if (voiceEngineObserverPtr_) {
181 shared_->SetLastError(
182 VE_INVALID_OPERATION, kTraceError,
183 "RegisterVoiceEngineObserver() observer already enabled");
184 return -1;
185 }
186
187 // Register the observer in all active channels
188 for (voe::ChannelManager::Iterator it(&shared_->channel_manager());
189 it.IsValid(); it.Increment()) {
190 it.GetChannel()->RegisterVoiceEngineObserver(observer);
191 }
192
193 shared_->transmit_mixer()->RegisterVoiceEngineObserver(observer);
194 voiceEngineObserverPtr_ = &observer;
195 return 0;
196 }
197
198 int VoEBaseImpl::DeRegisterVoiceEngineObserver() {
199 rtc::CritScope cs(&callbackCritSect_);
200 if (!voiceEngineObserverPtr_) {
201 shared_->SetLastError(
202 VE_INVALID_OPERATION, kTraceError,
203 "DeRegisterVoiceEngineObserver() observer already disabled");
204 return 0;
205 }
206 voiceEngineObserverPtr_ = nullptr;
207
208 // Deregister the observer in all active channels
209 for (voe::ChannelManager::Iterator it(&shared_->channel_manager());
210 it.IsValid(); it.Increment()) {
211 it.GetChannel()->DeRegisterVoiceEngineObserver();
212 }
213
214 return 0;
215 }
216
217 int VoEBaseImpl::Init( 163 int VoEBaseImpl::Init(
218 AudioDeviceModule* external_adm, 164 AudioDeviceModule* external_adm,
219 AudioProcessing* audio_processing, 165 AudioProcessing* audio_processing,
220 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) { 166 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) {
221 RTC_DCHECK(audio_processing); 167 RTC_DCHECK(audio_processing);
222 rtc::CritScope cs(shared_->crit_sec()); 168 rtc::CritScope cs(shared_->crit_sec());
223 WebRtcSpl_Init(); 169 WebRtcSpl_Init();
224 if (shared_->statistics().Initialized()) { 170 if (shared_->statistics().Initialized()) {
225 return 0; 171 return 0;
226 } 172 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 config_copy.acm_config.decoder_factory = decoder_factory_; 350 config_copy.acm_config.decoder_factory = decoder_factory_;
405 voe::ChannelOwner channel_owner = 351 voe::ChannelOwner channel_owner =
406 shared_->channel_manager().CreateChannel(config_copy); 352 shared_->channel_manager().CreateChannel(config_copy);
407 return InitializeChannel(&channel_owner); 353 return InitializeChannel(&channel_owner);
408 } 354 }
409 355
410 int VoEBaseImpl::InitializeChannel(voe::ChannelOwner* channel_owner) { 356 int VoEBaseImpl::InitializeChannel(voe::ChannelOwner* channel_owner) {
411 if (channel_owner->channel()->SetEngineInformation( 357 if (channel_owner->channel()->SetEngineInformation(
412 shared_->statistics(), 358 shared_->statistics(),
413 *shared_->process_thread(), *shared_->audio_device(), 359 *shared_->process_thread(), *shared_->audio_device(),
414 voiceEngineObserverPtr_, &callbackCritSect_, 360 &callbackCritSect_, shared_->encoder_queue()) != 0) {
415 shared_->encoder_queue()) != 0) {
416 shared_->SetLastError( 361 shared_->SetLastError(
417 VE_CHANNEL_NOT_CREATED, kTraceError, 362 VE_CHANNEL_NOT_CREATED, kTraceError,
418 "CreateChannel() failed to associate engine and channel." 363 "CreateChannel() failed to associate engine and channel."
419 " Destroying channel."); 364 " Destroying channel.");
420 shared_->channel_manager().DestroyChannel( 365 shared_->channel_manager().DestroyChannel(
421 channel_owner->channel()->ChannelId()); 366 channel_owner->channel()->ChannelId());
422 return -1; 367 return -1;
423 } else if (channel_owner->channel()->Init() != 0) { 368 } else if (channel_owner->channel()->Init() != 0) {
424 shared_->SetLastError( 369 shared_->SetLastError(
425 VE_CHANNEL_NOT_CREATED, kTraceError, 370 VE_CHANNEL_NOT_CREATED, kTraceError,
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 "TerminateInternal() failed to terminate the ADM"); 583 "TerminateInternal() failed to terminate the ADM");
639 } 584 }
640 shared_->set_audio_device(nullptr); 585 shared_->set_audio_device(nullptr);
641 } 586 }
642 587
643 shared_->set_audio_processing(nullptr); 588 shared_->set_audio_processing(nullptr);
644 589
645 return shared_->statistics().SetUnInitialized(); 590 return shared_->statistics().SetUnInitialized();
646 } 591 }
647 } // namespace webrtc 592 } // namespace webrtc
OLDNEW
« no previous file with comments | « voice_engine/voe_base_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698