| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 _playoutBuffer(NULL), | 82 _playoutBuffer(NULL), |
| 83 _recordingFramesLeft(0), | 83 _recordingFramesLeft(0), |
| 84 _playoutFramesLeft(0), | 84 _playoutFramesLeft(0), |
| 85 _initialized(false), | 85 _initialized(false), |
| 86 _recording(false), | 86 _recording(false), |
| 87 _playing(false), | 87 _playing(false), |
| 88 _recIsInitialized(false), | 88 _recIsInitialized(false), |
| 89 _playIsInitialized(false), | 89 _playIsInitialized(false), |
| 90 _AGC(false), | 90 _AGC(false), |
| 91 _recordingDelay(0), | 91 _recordingDelay(0), |
| 92 _playoutDelay(0), | 92 _playoutDelay(0) |
| 93 _playWarning(0), | |
| 94 _playError(0), | |
| 95 _recWarning(0), | |
| 96 _recError(0) | |
| 97 { | 93 { |
| 98 memset(_oldKeyState, 0, sizeof(_oldKeyState)); | 94 memset(_oldKeyState, 0, sizeof(_oldKeyState)); |
| 99 LOG(LS_INFO) << __FUNCTION__ << " created"; | 95 LOG(LS_INFO) << __FUNCTION__ << " created"; |
| 100 } | 96 } |
| 101 | 97 |
| 102 // ---------------------------------------------------------------------------- | 98 // ---------------------------------------------------------------------------- |
| 103 // AudioDeviceLinuxALSA - dtor | 99 // AudioDeviceLinuxALSA - dtor |
| 104 // ---------------------------------------------------------------------------- | 100 // ---------------------------------------------------------------------------- |
| 105 | 101 |
| 106 AudioDeviceLinuxALSA::~AudioDeviceLinuxALSA() | 102 AudioDeviceLinuxALSA::~AudioDeviceLinuxALSA() |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 return InitStatus::OK; | 155 return InitStatus::OK; |
| 160 } | 156 } |
| 161 #if defined(USE_X11) | 157 #if defined(USE_X11) |
| 162 //Get X display handle for typing detection | 158 //Get X display handle for typing detection |
| 163 _XDisplay = XOpenDisplay(NULL); | 159 _XDisplay = XOpenDisplay(NULL); |
| 164 if (!_XDisplay) { | 160 if (!_XDisplay) { |
| 165 LOG(LS_WARNING) | 161 LOG(LS_WARNING) |
| 166 << "failed to open X display, typing detection will not work"; | 162 << "failed to open X display, typing detection will not work"; |
| 167 } | 163 } |
| 168 #endif | 164 #endif |
| 169 _playWarning = 0; | |
| 170 _playError = 0; | |
| 171 _recWarning = 0; | |
| 172 _recError = 0; | |
| 173 | 165 |
| 174 _initialized = true; | 166 _initialized = true; |
| 175 | 167 |
| 176 return InitStatus::OK; | 168 return InitStatus::OK; |
| 177 } | 169 } |
| 178 | 170 |
| 179 int32_t AudioDeviceLinuxALSA::Terminate() | 171 int32_t AudioDeviceLinuxALSA::Terminate() |
| 180 { | 172 { |
| 181 if (!_initialized) | 173 if (!_initialized) |
| 182 { | 174 { |
| (...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 // Update webrtc audio buffer with the selected parameters | 999 // Update webrtc audio buffer with the selected parameters |
| 1008 _ptrAudioBuffer->SetPlayoutSampleRate(_playoutFreq); | 1000 _ptrAudioBuffer->SetPlayoutSampleRate(_playoutFreq); |
| 1009 _ptrAudioBuffer->SetPlayoutChannels(_playChannels); | 1001 _ptrAudioBuffer->SetPlayoutChannels(_playChannels); |
| 1010 } | 1002 } |
| 1011 | 1003 |
| 1012 // Set play buffer size | 1004 // Set play buffer size |
| 1013 _playoutBufferSizeIn10MS = LATE(snd_pcm_frames_to_bytes)( | 1005 _playoutBufferSizeIn10MS = LATE(snd_pcm_frames_to_bytes)( |
| 1014 _handlePlayout, _playoutFramesIn10MS); | 1006 _handlePlayout, _playoutFramesIn10MS); |
| 1015 | 1007 |
| 1016 // Init varaibles used for play | 1008 // Init varaibles used for play |
| 1017 _playWarning = 0; | |
| 1018 _playError = 0; | |
| 1019 | 1009 |
| 1020 if (_handlePlayout != NULL) | 1010 if (_handlePlayout != NULL) |
| 1021 { | 1011 { |
| 1022 _playIsInitialized = true; | 1012 _playIsInitialized = true; |
| 1023 return 0; | 1013 return 0; |
| 1024 } | 1014 } |
| 1025 else | 1015 else |
| 1026 { | 1016 { |
| 1027 return -1; | 1017 return -1; |
| 1028 } | 1018 } |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1440 // Adding 10ms adjusted value to the record delay due to 10ms buffering. | 1430 // Adding 10ms adjusted value to the record delay due to 10ms buffering. |
| 1441 delayMS = (uint16_t)(10 + _recordingDelay * 1000 / _recordingFreq); | 1431 delayMS = (uint16_t)(10 + _recordingDelay * 1000 / _recordingFreq); |
| 1442 return 0; | 1432 return 0; |
| 1443 } | 1433 } |
| 1444 | 1434 |
| 1445 bool AudioDeviceLinuxALSA::Playing() const | 1435 bool AudioDeviceLinuxALSA::Playing() const |
| 1446 { | 1436 { |
| 1447 return (_playing); | 1437 return (_playing); |
| 1448 } | 1438 } |
| 1449 | 1439 |
| 1450 bool AudioDeviceLinuxALSA::PlayoutWarning() const | |
| 1451 { | |
| 1452 rtc::CritScope lock(&_critSect); | |
| 1453 return (_playWarning > 0); | |
| 1454 } | |
| 1455 | |
| 1456 bool AudioDeviceLinuxALSA::PlayoutError() const | |
| 1457 { | |
| 1458 rtc::CritScope lock(&_critSect); | |
| 1459 return (_playError > 0); | |
| 1460 } | |
| 1461 | |
| 1462 bool AudioDeviceLinuxALSA::RecordingWarning() const | |
| 1463 { | |
| 1464 rtc::CritScope lock(&_critSect); | |
| 1465 return (_recWarning > 0); | |
| 1466 } | |
| 1467 | |
| 1468 bool AudioDeviceLinuxALSA::RecordingError() const | |
| 1469 { | |
| 1470 rtc::CritScope lock(&_critSect); | |
| 1471 return (_recError > 0); | |
| 1472 } | |
| 1473 | |
| 1474 void AudioDeviceLinuxALSA::ClearPlayoutWarning() | |
| 1475 { | |
| 1476 rtc::CritScope lock(&_critSect); | |
| 1477 _playWarning = 0; | |
| 1478 } | |
| 1479 | |
| 1480 void AudioDeviceLinuxALSA::ClearPlayoutError() | |
| 1481 { | |
| 1482 rtc::CritScope lock(&_critSect); | |
| 1483 _playError = 0; | |
| 1484 } | |
| 1485 | |
| 1486 void AudioDeviceLinuxALSA::ClearRecordingWarning() | |
| 1487 { | |
| 1488 rtc::CritScope lock(&_critSect); | |
| 1489 _recWarning = 0; | |
| 1490 } | |
| 1491 | |
| 1492 void AudioDeviceLinuxALSA::ClearRecordingError() | |
| 1493 { | |
| 1494 rtc::CritScope lock(&_critSect); | |
| 1495 _recError = 0; | |
| 1496 } | |
| 1497 | |
| 1498 // ============================================================================ | 1440 // ============================================================================ |
| 1499 // Private Methods | 1441 // Private Methods |
| 1500 // ============================================================================ | 1442 // ============================================================================ |
| 1501 | 1443 |
| 1502 int32_t AudioDeviceLinuxALSA::GetDevicesInfo( | 1444 int32_t AudioDeviceLinuxALSA::GetDevicesInfo( |
| 1503 const int32_t function, | 1445 const int32_t function, |
| 1504 const bool playback, | 1446 const bool playback, |
| 1505 const int32_t enumDeviceNo, | 1447 const int32_t enumDeviceNo, |
| 1506 char* enumDeviceName, | 1448 char* enumDeviceName, |
| 1507 const int32_t ednLen) const | 1449 const int32_t ednLen) const |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2009 state |= (szKey[i] ^ _oldKeyState[i]) & szKey[i]; | 1951 state |= (szKey[i] ^ _oldKeyState[i]) & szKey[i]; |
| 2010 | 1952 |
| 2011 // Save old state | 1953 // Save old state |
| 2012 memcpy((char*)_oldKeyState, (char*)szKey, sizeof(_oldKeyState)); | 1954 memcpy((char*)_oldKeyState, (char*)szKey, sizeof(_oldKeyState)); |
| 2013 return (state != 0); | 1955 return (state != 0); |
| 2014 #else | 1956 #else |
| 2015 return false; | 1957 return false; |
| 2016 #endif | 1958 #endif |
| 2017 } | 1959 } |
| 2018 } // namespace webrtc | 1960 } // namespace webrtc |
| OLD | NEW |