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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #elif defined(WEBRTC_MAC) | 46 #elif defined(WEBRTC_MAC) |
47 #include "audio_device_mac.h" | 47 #include "audio_device_mac.h" |
48 #endif | 48 #endif |
49 | 49 |
50 #if defined(WEBRTC_DUMMY_FILE_DEVICES) | 50 #if defined(WEBRTC_DUMMY_FILE_DEVICES) |
51 #include "webrtc/modules/audio_device/dummy/file_audio_device_factory.h" | 51 #include "webrtc/modules/audio_device/dummy/file_audio_device_factory.h" |
52 #endif | 52 #endif |
53 | 53 |
54 #include "webrtc/modules/audio_device/dummy/audio_device_dummy.h" | 54 #include "webrtc/modules/audio_device/dummy/audio_device_dummy.h" |
55 #include "webrtc/modules/audio_device/dummy/file_audio_device.h" | 55 #include "webrtc/modules/audio_device/dummy/file_audio_device.h" |
56 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | |
57 | 56 |
58 #define CHECK_INITIALIZED() \ | 57 #define CHECK_INITIALIZED() \ |
59 { \ | 58 { \ |
60 if (!_initialized) { \ | 59 if (!_initialized) { \ |
61 return -1; \ | 60 return -1; \ |
62 }; \ | 61 }; \ |
63 } | 62 } |
64 | 63 |
65 #define CHECK_INITIALIZED_BOOL() \ | 64 #define CHECK_INITIALIZED_BOOL() \ |
66 { \ | 65 { \ |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // ============================================================================ | 110 // ============================================================================ |
112 // Construction & Destruction | 111 // Construction & Destruction |
113 // ============================================================================ | 112 // ============================================================================ |
114 | 113 |
115 // ---------------------------------------------------------------------------- | 114 // ---------------------------------------------------------------------------- |
116 // AudioDeviceModuleImpl - ctor | 115 // AudioDeviceModuleImpl - ctor |
117 // ---------------------------------------------------------------------------- | 116 // ---------------------------------------------------------------------------- |
118 | 117 |
119 AudioDeviceModuleImpl::AudioDeviceModuleImpl(const int32_t id, | 118 AudioDeviceModuleImpl::AudioDeviceModuleImpl(const int32_t id, |
120 const AudioLayer audioLayer) | 119 const AudioLayer audioLayer) |
121 : _critSect(*CriticalSectionWrapper::CreateCriticalSection()), | 120 : _ptrCbAudioDeviceObserver(NULL), |
122 _critSectEventCb(*CriticalSectionWrapper::CreateCriticalSection()), | |
123 _critSectAudioCb(*CriticalSectionWrapper::CreateCriticalSection()), | |
124 _ptrCbAudioDeviceObserver(NULL), | |
125 _ptrAudioDevice(NULL), | 121 _ptrAudioDevice(NULL), |
126 _id(id), | 122 _id(id), |
127 _platformAudioLayer(audioLayer), | 123 _platformAudioLayer(audioLayer), |
128 _lastProcessTime(rtc::TimeMillis()), | 124 _lastProcessTime(rtc::TimeMillis()), |
129 _platformType(kPlatformNotSupported), | 125 _platformType(kPlatformNotSupported), |
130 _initialized(false), | 126 _initialized(false), |
131 _lastError(kAdmErrNone) { | 127 _lastError(kAdmErrNone) { |
132 LOG(INFO) << __FUNCTION__; | 128 LOG(INFO) << __FUNCTION__; |
133 } | 129 } |
134 | 130 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 _ptrAudioDevice->AttachAudioBuffer(&_audioDeviceBuffer); | 347 _ptrAudioDevice->AttachAudioBuffer(&_audioDeviceBuffer); |
352 return 0; | 348 return 0; |
353 } | 349 } |
354 | 350 |
355 // ---------------------------------------------------------------------------- | 351 // ---------------------------------------------------------------------------- |
356 // ~AudioDeviceModuleImpl - dtor | 352 // ~AudioDeviceModuleImpl - dtor |
357 // ---------------------------------------------------------------------------- | 353 // ---------------------------------------------------------------------------- |
358 | 354 |
359 AudioDeviceModuleImpl::~AudioDeviceModuleImpl() { | 355 AudioDeviceModuleImpl::~AudioDeviceModuleImpl() { |
360 LOG(INFO) << __FUNCTION__; | 356 LOG(INFO) << __FUNCTION__; |
361 | |
362 if (_ptrAudioDevice) { | 357 if (_ptrAudioDevice) { |
363 delete _ptrAudioDevice; | 358 delete _ptrAudioDevice; |
364 _ptrAudioDevice = NULL; | 359 _ptrAudioDevice = NULL; |
365 } | 360 } |
366 | |
367 delete &_critSect; | |
368 delete &_critSectEventCb; | |
369 delete &_critSectAudioCb; | |
370 } | 361 } |
371 | 362 |
372 // ============================================================================ | 363 // ============================================================================ |
373 // Module | 364 // Module |
374 // ============================================================================ | 365 // ============================================================================ |
375 | 366 |
376 // ---------------------------------------------------------------------------- | 367 // ---------------------------------------------------------------------------- |
377 // Module::TimeUntilNextProcess | 368 // Module::TimeUntilNextProcess |
378 // | 369 // |
379 // Returns the number of milliseconds until the module want a worker thread | 370 // Returns the number of milliseconds until the module want a worker thread |
(...skipping 11 matching lines...) Expand all Loading... |
391 // | 382 // |
392 // Check for posted error and warning reports. Generate callbacks if | 383 // Check for posted error and warning reports. Generate callbacks if |
393 // new reports exists. | 384 // new reports exists. |
394 // ---------------------------------------------------------------------------- | 385 // ---------------------------------------------------------------------------- |
395 | 386 |
396 void AudioDeviceModuleImpl::Process() { | 387 void AudioDeviceModuleImpl::Process() { |
397 _lastProcessTime = rtc::TimeMillis(); | 388 _lastProcessTime = rtc::TimeMillis(); |
398 | 389 |
399 // kPlayoutWarning | 390 // kPlayoutWarning |
400 if (_ptrAudioDevice->PlayoutWarning()) { | 391 if (_ptrAudioDevice->PlayoutWarning()) { |
401 CriticalSectionScoped lock(&_critSectEventCb); | 392 rtc::CritScope lock(&_critSectEventCb); |
402 if (_ptrCbAudioDeviceObserver) { | 393 if (_ptrCbAudioDeviceObserver) { |
403 LOG(WARNING) << "=> OnWarningIsReported(kPlayoutWarning)"; | 394 LOG(WARNING) << "=> OnWarningIsReported(kPlayoutWarning)"; |
404 _ptrCbAudioDeviceObserver->OnWarningIsReported( | 395 _ptrCbAudioDeviceObserver->OnWarningIsReported( |
405 AudioDeviceObserver::kPlayoutWarning); | 396 AudioDeviceObserver::kPlayoutWarning); |
406 } | 397 } |
407 _ptrAudioDevice->ClearPlayoutWarning(); | 398 _ptrAudioDevice->ClearPlayoutWarning(); |
408 } | 399 } |
409 | 400 |
410 // kPlayoutError | 401 // kPlayoutError |
411 if (_ptrAudioDevice->PlayoutError()) { | 402 if (_ptrAudioDevice->PlayoutError()) { |
412 CriticalSectionScoped lock(&_critSectEventCb); | 403 rtc::CritScope lock(&_critSectEventCb); |
413 if (_ptrCbAudioDeviceObserver) { | 404 if (_ptrCbAudioDeviceObserver) { |
414 LOG(LERROR) << "=> OnErrorIsReported(kPlayoutError)"; | 405 LOG(LERROR) << "=> OnErrorIsReported(kPlayoutError)"; |
415 _ptrCbAudioDeviceObserver->OnErrorIsReported( | 406 _ptrCbAudioDeviceObserver->OnErrorIsReported( |
416 AudioDeviceObserver::kPlayoutError); | 407 AudioDeviceObserver::kPlayoutError); |
417 } | 408 } |
418 _ptrAudioDevice->ClearPlayoutError(); | 409 _ptrAudioDevice->ClearPlayoutError(); |
419 } | 410 } |
420 | 411 |
421 // kRecordingWarning | 412 // kRecordingWarning |
422 if (_ptrAudioDevice->RecordingWarning()) { | 413 if (_ptrAudioDevice->RecordingWarning()) { |
423 CriticalSectionScoped lock(&_critSectEventCb); | 414 rtc::CritScope lock(&_critSectEventCb); |
424 if (_ptrCbAudioDeviceObserver) { | 415 if (_ptrCbAudioDeviceObserver) { |
425 LOG(WARNING) << "=> OnWarningIsReported(kRecordingWarning)"; | 416 LOG(WARNING) << "=> OnWarningIsReported(kRecordingWarning)"; |
426 _ptrCbAudioDeviceObserver->OnWarningIsReported( | 417 _ptrCbAudioDeviceObserver->OnWarningIsReported( |
427 AudioDeviceObserver::kRecordingWarning); | 418 AudioDeviceObserver::kRecordingWarning); |
428 } | 419 } |
429 _ptrAudioDevice->ClearRecordingWarning(); | 420 _ptrAudioDevice->ClearRecordingWarning(); |
430 } | 421 } |
431 | 422 |
432 // kRecordingError | 423 // kRecordingError |
433 if (_ptrAudioDevice->RecordingError()) { | 424 if (_ptrAudioDevice->RecordingError()) { |
434 CriticalSectionScoped lock(&_critSectEventCb); | 425 rtc::CritScope lock(&_critSectEventCb); |
435 if (_ptrCbAudioDeviceObserver) { | 426 if (_ptrCbAudioDeviceObserver) { |
436 LOG(LERROR) << "=> OnErrorIsReported(kRecordingError)"; | 427 LOG(LERROR) << "=> OnErrorIsReported(kRecordingError)"; |
437 _ptrCbAudioDeviceObserver->OnErrorIsReported( | 428 _ptrCbAudioDeviceObserver->OnErrorIsReported( |
438 AudioDeviceObserver::kRecordingError); | 429 AudioDeviceObserver::kRecordingError); |
439 } | 430 } |
440 _ptrAudioDevice->ClearRecordingError(); | 431 _ptrAudioDevice->ClearRecordingError(); |
441 } | 432 } |
442 } | 433 } |
443 | 434 |
444 // ============================================================================ | 435 // ============================================================================ |
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1452 return (_ptrAudioDevice->Recording()); | 1443 return (_ptrAudioDevice->Recording()); |
1453 } | 1444 } |
1454 | 1445 |
1455 // ---------------------------------------------------------------------------- | 1446 // ---------------------------------------------------------------------------- |
1456 // RegisterEventObserver | 1447 // RegisterEventObserver |
1457 // ---------------------------------------------------------------------------- | 1448 // ---------------------------------------------------------------------------- |
1458 | 1449 |
1459 int32_t AudioDeviceModuleImpl::RegisterEventObserver( | 1450 int32_t AudioDeviceModuleImpl::RegisterEventObserver( |
1460 AudioDeviceObserver* eventCallback) { | 1451 AudioDeviceObserver* eventCallback) { |
1461 LOG(INFO) << __FUNCTION__; | 1452 LOG(INFO) << __FUNCTION__; |
1462 CriticalSectionScoped lock(&_critSectEventCb); | 1453 rtc::CritScope lock(&_critSectEventCb); |
1463 _ptrCbAudioDeviceObserver = eventCallback; | 1454 _ptrCbAudioDeviceObserver = eventCallback; |
1464 | 1455 |
1465 return 0; | 1456 return 0; |
1466 } | 1457 } |
1467 | 1458 |
1468 // ---------------------------------------------------------------------------- | 1459 // ---------------------------------------------------------------------------- |
1469 // RegisterAudioCallback | 1460 // RegisterAudioCallback |
1470 // ---------------------------------------------------------------------------- | 1461 // ---------------------------------------------------------------------------- |
1471 | 1462 |
1472 int32_t AudioDeviceModuleImpl::RegisterAudioCallback( | 1463 int32_t AudioDeviceModuleImpl::RegisterAudioCallback( |
1473 AudioTransport* audioCallback) { | 1464 AudioTransport* audioCallback) { |
1474 LOG(INFO) << __FUNCTION__; | 1465 LOG(INFO) << __FUNCTION__; |
1475 CriticalSectionScoped lock(&_critSectAudioCb); | 1466 rtc::CritScope lock(&_critSectAudioCb); |
1476 return _audioDeviceBuffer.RegisterAudioCallback(audioCallback); | 1467 return _audioDeviceBuffer.RegisterAudioCallback(audioCallback); |
1477 } | 1468 } |
1478 | 1469 |
1479 // ---------------------------------------------------------------------------- | 1470 // ---------------------------------------------------------------------------- |
1480 // StartRawInputFileRecording | 1471 // StartRawInputFileRecording |
1481 // ---------------------------------------------------------------------------- | 1472 // ---------------------------------------------------------------------------- |
1482 | 1473 |
1483 int32_t AudioDeviceModuleImpl::StartRawInputFileRecording( | 1474 int32_t AudioDeviceModuleImpl::StartRawInputFileRecording( |
1484 const char pcmFileNameUTF8[kAdmMaxFileNameSize]) { | 1475 const char pcmFileNameUTF8[kAdmMaxFileNameSize]) { |
1485 LOG(INFO) << __FUNCTION__; | 1476 LOG(INFO) << __FUNCTION__; |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1848 // PlatformAudioLayer | 1839 // PlatformAudioLayer |
1849 // ---------------------------------------------------------------------------- | 1840 // ---------------------------------------------------------------------------- |
1850 | 1841 |
1851 AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer() | 1842 AudioDeviceModule::AudioLayer AudioDeviceModuleImpl::PlatformAudioLayer() |
1852 const { | 1843 const { |
1853 LOG(INFO) << __FUNCTION__; | 1844 LOG(INFO) << __FUNCTION__; |
1854 return _platformAudioLayer; | 1845 return _platformAudioLayer; |
1855 } | 1846 } |
1856 | 1847 |
1857 } // namespace webrtc | 1848 } // namespace webrtc |
OLD | NEW |