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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // ============================================================================ | 109 // ============================================================================ |
110 // Construction & Destruction | 110 // Construction & Destruction |
111 // ============================================================================ | 111 // ============================================================================ |
112 | 112 |
113 // ---------------------------------------------------------------------------- | 113 // ---------------------------------------------------------------------------- |
114 // AudioDeviceModuleImpl - ctor | 114 // AudioDeviceModuleImpl - ctor |
115 // ---------------------------------------------------------------------------- | 115 // ---------------------------------------------------------------------------- |
116 | 116 |
117 AudioDeviceModuleImpl::AudioDeviceModuleImpl(const int32_t id, | 117 AudioDeviceModuleImpl::AudioDeviceModuleImpl(const int32_t id, |
118 const AudioLayer audioLayer) | 118 const AudioLayer audioLayer) |
119 : _ptrCbAudioDeviceObserver(NULL), | 119 : _ptrAudioDevice(NULL), |
120 _ptrAudioDevice(NULL), | |
121 _id(id), | 120 _id(id), |
122 _platformAudioLayer(audioLayer), | 121 _platformAudioLayer(audioLayer), |
123 _lastProcessTime(rtc::TimeMillis()), | |
124 _platformType(kPlatformNotSupported), | 122 _platformType(kPlatformNotSupported), |
125 _initialized(false), | 123 _initialized(false), |
126 _lastError(kAdmErrNone) { | 124 _lastError(kAdmErrNone) { |
127 LOG(INFO) << __FUNCTION__; | 125 LOG(INFO) << __FUNCTION__; |
128 } | 126 } |
129 | 127 |
130 // ---------------------------------------------------------------------------- | 128 // ---------------------------------------------------------------------------- |
131 // CheckPlatform | 129 // CheckPlatform |
132 // ---------------------------------------------------------------------------- | 130 // ---------------------------------------------------------------------------- |
133 | 131 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 | 351 |
354 AudioDeviceModuleImpl::~AudioDeviceModuleImpl() { | 352 AudioDeviceModuleImpl::~AudioDeviceModuleImpl() { |
355 LOG(INFO) << __FUNCTION__; | 353 LOG(INFO) << __FUNCTION__; |
356 if (_ptrAudioDevice) { | 354 if (_ptrAudioDevice) { |
357 delete _ptrAudioDevice; | 355 delete _ptrAudioDevice; |
358 _ptrAudioDevice = NULL; | 356 _ptrAudioDevice = NULL; |
359 } | 357 } |
360 } | 358 } |
361 | 359 |
362 // ============================================================================ | 360 // ============================================================================ |
363 // Module | |
364 // ============================================================================ | |
365 | |
366 // ---------------------------------------------------------------------------- | |
367 // Module::TimeUntilNextProcess | |
368 // | |
369 // Returns the number of milliseconds until the module want a worker thread | |
370 // to call Process(). | |
371 // ---------------------------------------------------------------------------- | |
372 | |
373 int64_t AudioDeviceModuleImpl::TimeUntilNextProcess() { | |
374 int64_t now = rtc::TimeMillis(); | |
375 int64_t deltaProcess = kAdmMaxIdleTimeProcess - (now - _lastProcessTime); | |
376 return deltaProcess; | |
377 } | |
378 | |
379 // ---------------------------------------------------------------------------- | |
380 // Module::Process | |
381 // | |
382 // Check for posted error and warning reports. Generate callbacks if | |
383 // new reports exists. | |
384 // ---------------------------------------------------------------------------- | |
385 | |
386 void AudioDeviceModuleImpl::Process() { | |
387 _lastProcessTime = rtc::TimeMillis(); | |
388 | |
389 // kPlayoutWarning | |
390 if (_ptrAudioDevice->PlayoutWarning()) { | |
391 rtc::CritScope lock(&_critSectEventCb); | |
392 if (_ptrCbAudioDeviceObserver) { | |
393 LOG(WARNING) << "=> OnWarningIsReported(kPlayoutWarning)"; | |
394 _ptrCbAudioDeviceObserver->OnWarningIsReported( | |
395 AudioDeviceObserver::kPlayoutWarning); | |
396 } | |
397 _ptrAudioDevice->ClearPlayoutWarning(); | |
398 } | |
399 | |
400 // kPlayoutError | |
401 if (_ptrAudioDevice->PlayoutError()) { | |
402 rtc::CritScope lock(&_critSectEventCb); | |
403 if (_ptrCbAudioDeviceObserver) { | |
404 LOG(LERROR) << "=> OnErrorIsReported(kPlayoutError)"; | |
405 _ptrCbAudioDeviceObserver->OnErrorIsReported( | |
406 AudioDeviceObserver::kPlayoutError); | |
407 } | |
408 _ptrAudioDevice->ClearPlayoutError(); | |
409 } | |
410 | |
411 // kRecordingWarning | |
412 if (_ptrAudioDevice->RecordingWarning()) { | |
413 rtc::CritScope lock(&_critSectEventCb); | |
414 if (_ptrCbAudioDeviceObserver) { | |
415 LOG(WARNING) << "=> OnWarningIsReported(kRecordingWarning)"; | |
416 _ptrCbAudioDeviceObserver->OnWarningIsReported( | |
417 AudioDeviceObserver::kRecordingWarning); | |
418 } | |
419 _ptrAudioDevice->ClearRecordingWarning(); | |
420 } | |
421 | |
422 // kRecordingError | |
423 if (_ptrAudioDevice->RecordingError()) { | |
424 rtc::CritScope lock(&_critSectEventCb); | |
425 if (_ptrCbAudioDeviceObserver) { | |
426 LOG(LERROR) << "=> OnErrorIsReported(kRecordingError)"; | |
427 _ptrCbAudioDeviceObserver->OnErrorIsReported( | |
428 AudioDeviceObserver::kRecordingError); | |
429 } | |
430 _ptrAudioDevice->ClearRecordingError(); | |
431 } | |
432 } | |
433 | |
434 // ============================================================================ | |
435 // Public API | 361 // Public API |
436 // ============================================================================ | 362 // ============================================================================ |
437 | 363 |
438 // ---------------------------------------------------------------------------- | 364 // ---------------------------------------------------------------------------- |
439 // ActiveAudioLayer | 365 // ActiveAudioLayer |
440 // ---------------------------------------------------------------------------- | 366 // ---------------------------------------------------------------------------- |
441 | 367 |
442 int32_t AudioDeviceModuleImpl::ActiveAudioLayer(AudioLayer* audioLayer) const { | 368 int32_t AudioDeviceModuleImpl::ActiveAudioLayer(AudioLayer* audioLayer) const { |
443 LOG(INFO) << __FUNCTION__; | 369 LOG(INFO) << __FUNCTION__; |
444 AudioLayer activeAudio; | 370 AudioLayer activeAudio; |
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 // Recording | 1240 // Recording |
1315 // ---------------------------------------------------------------------------- | 1241 // ---------------------------------------------------------------------------- |
1316 | 1242 |
1317 bool AudioDeviceModuleImpl::Recording() const { | 1243 bool AudioDeviceModuleImpl::Recording() const { |
1318 LOG(INFO) << __FUNCTION__; | 1244 LOG(INFO) << __FUNCTION__; |
1319 CHECK_INITIALIZED_BOOL(); | 1245 CHECK_INITIALIZED_BOOL(); |
1320 return (_ptrAudioDevice->Recording()); | 1246 return (_ptrAudioDevice->Recording()); |
1321 } | 1247 } |
1322 | 1248 |
1323 // ---------------------------------------------------------------------------- | 1249 // ---------------------------------------------------------------------------- |
1324 // RegisterEventObserver | |
1325 // ---------------------------------------------------------------------------- | |
1326 | |
1327 int32_t AudioDeviceModuleImpl::RegisterEventObserver( | |
1328 AudioDeviceObserver* eventCallback) { | |
1329 LOG(INFO) << __FUNCTION__; | |
1330 rtc::CritScope lock(&_critSectEventCb); | |
1331 _ptrCbAudioDeviceObserver = eventCallback; | |
1332 | |
1333 return 0; | |
1334 } | |
1335 | |
1336 // ---------------------------------------------------------------------------- | |
1337 // RegisterAudioCallback | 1250 // RegisterAudioCallback |
1338 // ---------------------------------------------------------------------------- | 1251 // ---------------------------------------------------------------------------- |
1339 | 1252 |
1340 int32_t AudioDeviceModuleImpl::RegisterAudioCallback( | 1253 int32_t AudioDeviceModuleImpl::RegisterAudioCallback( |
1341 AudioTransport* audioCallback) { | 1254 AudioTransport* audioCallback) { |
1342 LOG(INFO) << __FUNCTION__; | 1255 LOG(INFO) << __FUNCTION__; |
1343 rtc::CritScope lock(&_critSectAudioCb); | 1256 rtc::CritScope lock(&_critSectAudioCb); |
1344 return _audioDeviceBuffer.RegisterAudioCallback(audioCallback); | 1257 return _audioDeviceBuffer.RegisterAudioCallback(audioCallback); |
1345 } | 1258 } |
1346 | 1259 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1569 // PlatformAudioLayer | 1482 // PlatformAudioLayer |
1570 // ---------------------------------------------------------------------------- | 1483 // ---------------------------------------------------------------------------- |
1571 | 1484 |
1572 AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer() | 1485 AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer() |
1573 const { | 1486 const { |
1574 LOG(INFO) << __FUNCTION__; | 1487 LOG(INFO) << __FUNCTION__; |
1575 return _platformAudioLayer; | 1488 return _platformAudioLayer; |
1576 } | 1489 } |
1577 | 1490 |
1578 } // namespace webrtc | 1491 } // namespace webrtc |
OLD | NEW |