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 42 matching lines...) Loading... |
53 static const unsigned int ALSA_PLAYOUT_LATENCY = 40*1000; // in us | 53 static const unsigned int ALSA_PLAYOUT_LATENCY = 40*1000; // in us |
54 static const unsigned int ALSA_CAPTURE_FREQ = 48000; | 54 static const unsigned int ALSA_CAPTURE_FREQ = 48000; |
55 static const unsigned int ALSA_CAPTURE_CH = 2; | 55 static const unsigned int ALSA_CAPTURE_CH = 2; |
56 static const unsigned int ALSA_CAPTURE_LATENCY = 40*1000; // in us | 56 static const unsigned int ALSA_CAPTURE_LATENCY = 40*1000; // in us |
57 static const unsigned int ALSA_CAPTURE_WAIT_TIMEOUT = 5; // in ms | 57 static const unsigned int ALSA_CAPTURE_WAIT_TIMEOUT = 5; // in ms |
58 | 58 |
59 #define FUNC_GET_NUM_OF_DEVICE 0 | 59 #define FUNC_GET_NUM_OF_DEVICE 0 |
60 #define FUNC_GET_DEVICE_NAME 1 | 60 #define FUNC_GET_DEVICE_NAME 1 |
61 #define FUNC_GET_DEVICE_NAME_FOR_AN_ENUM 2 | 61 #define FUNC_GET_DEVICE_NAME_FOR_AN_ENUM 2 |
62 | 62 |
63 AudioDeviceLinuxALSA::AudioDeviceLinuxALSA(const int32_t id) : | 63 AudioDeviceLinuxALSA::AudioDeviceLinuxALSA(const int32_t id) |
64 _ptrAudioBuffer(NULL), | 64 : _ptrAudioBuffer(nullptr), |
65 _critSect(*CriticalSectionWrapper::CreateCriticalSection()), | 65 _critSect(*CriticalSectionWrapper::CreateCriticalSection()), |
66 _id(id), | 66 _id(id), |
67 _mixerManager(id), | 67 _mixerManager(id), |
68 _inputDeviceIndex(0), | 68 _inputDeviceIndex(0), |
69 _outputDeviceIndex(0), | 69 _outputDeviceIndex(0), |
70 _inputDeviceIsSpecified(false), | 70 _inputDeviceIsSpecified(false), |
71 _outputDeviceIsSpecified(false), | 71 _outputDeviceIsSpecified(false), |
72 _handleRecord(NULL), | 72 _handleRecord(nullptr), |
73 _handlePlayout(NULL), | 73 _handlePlayout(nullptr), |
74 _recordingBuffersizeInFrame(0), | 74 _recordingBuffersizeInFrame(0), |
75 _recordingPeriodSizeInFrame(0), | 75 _recordingPeriodSizeInFrame(0), |
76 _playoutBufferSizeInFrame(0), | 76 _playoutBufferSizeInFrame(0), |
77 _playoutPeriodSizeInFrame(0), | 77 _playoutPeriodSizeInFrame(0), |
78 _recordingBufferSizeIn10MS(0), | 78 _recordingBufferSizeIn10MS(0), |
79 _playoutBufferSizeIn10MS(0), | 79 _playoutBufferSizeIn10MS(0), |
80 _recordingFramesIn10MS(0), | 80 _recordingFramesIn10MS(0), |
81 _playoutFramesIn10MS(0), | 81 _playoutFramesIn10MS(0), |
82 _recordingFreq(ALSA_CAPTURE_FREQ), | 82 _recordingFreq(ALSA_CAPTURE_FREQ), |
83 _playoutFreq(ALSA_PLAYOUT_FREQ), | 83 _playoutFreq(ALSA_PLAYOUT_FREQ), |
84 _recChannels(ALSA_CAPTURE_CH), | 84 _recChannels(ALSA_CAPTURE_CH), |
85 _playChannels(ALSA_PLAYOUT_CH), | 85 _playChannels(ALSA_PLAYOUT_CH), |
86 _recordingBuffer(NULL), | 86 _recordingBuffer(nullptr), |
87 _playoutBuffer(NULL), | 87 _playoutBuffer(nullptr), |
88 _recordingFramesLeft(0), | 88 _recordingFramesLeft(0), |
89 _playoutFramesLeft(0), | 89 _playoutFramesLeft(0), |
90 _playBufType(AudioDeviceModule::kFixedBufferSize), | 90 _playBufType(AudioDeviceModule::kFixedBufferSize), |
91 _initialized(false), | 91 _initialized(false), |
92 _recording(false), | 92 _recording(false), |
93 _playing(false), | 93 _playing(false), |
94 _recIsInitialized(false), | 94 _recIsInitialized(false), |
95 _playIsInitialized(false), | 95 _playIsInitialized(false), |
96 _AGC(false), | 96 _AGC(false), |
97 _recordingDelay(0), | 97 _recordingDelay(0), |
98 _playoutDelay(0), | 98 _playoutDelay(0), |
99 _playWarning(0), | 99 _playWarning(0), |
100 _playError(0), | 100 _playError(0), |
101 _recWarning(0), | 101 _recWarning(0), |
102 _recError(0), | 102 _recError(0), |
103 _playBufDelay(80), | 103 _playBufDelay(80), |
104 _playBufDelayFixed(80) | 104 _playBufDelayFixed(80) { |
105 { | 105 memset(_oldKeyState, 0, sizeof(_oldKeyState)); |
106 memset(_oldKeyState, 0, sizeof(_oldKeyState)); | 106 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id, "%s created", __FUNCTION__); |
107 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id, | |
108 "%s created", __FUNCTION__); | |
109 } | 107 } |
110 | 108 |
111 // ---------------------------------------------------------------------------- | 109 // ---------------------------------------------------------------------------- |
112 // AudioDeviceLinuxALSA - dtor | 110 // AudioDeviceLinuxALSA - dtor |
113 // ---------------------------------------------------------------------------- | 111 // ---------------------------------------------------------------------------- |
114 | 112 |
115 AudioDeviceLinuxALSA::~AudioDeviceLinuxALSA() | 113 AudioDeviceLinuxALSA::~AudioDeviceLinuxALSA() |
116 { | 114 { |
117 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, | 115 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, |
118 "%s destroyed", __FUNCTION__); | 116 "%s destroyed", __FUNCTION__); |
119 | 117 |
120 Terminate(); | 118 Terminate(); |
121 | 119 |
122 // Clean up the recording buffer and playout buffer. | 120 // Clean up the recording buffer and playout buffer. |
123 if (_recordingBuffer) | 121 if (_recordingBuffer) |
124 { | 122 { |
125 delete [] _recordingBuffer; | 123 delete [] _recordingBuffer; |
126 _recordingBuffer = NULL; | 124 _recordingBuffer = nullptr; |
127 } | 125 } |
128 if (_playoutBuffer) | 126 if (_playoutBuffer) |
129 { | 127 { |
130 delete [] _playoutBuffer; | 128 delete [] _playoutBuffer; |
131 _playoutBuffer = NULL; | 129 _playoutBuffer = nullptr; |
132 } | 130 } |
133 delete &_critSect; | 131 delete &_critSect; |
134 } | 132 } |
135 | 133 |
136 void AudioDeviceLinuxALSA::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) | 134 void AudioDeviceLinuxALSA::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) |
137 { | 135 { |
138 | 136 |
139 CriticalSectionScoped lock(&_critSect); | 137 CriticalSectionScoped lock(&_critSect); |
140 | 138 |
141 _ptrAudioBuffer = audioBuffer; | 139 _ptrAudioBuffer = audioBuffer; |
(...skipping 22 matching lines...) Loading... |
164 // Alsa is not installed on this system | 162 // Alsa is not installed on this system |
165 LOG(LS_ERROR) << "failed to load symbol table"; | 163 LOG(LS_ERROR) << "failed to load symbol table"; |
166 return InitStatus::OTHER_ERROR; | 164 return InitStatus::OTHER_ERROR; |
167 } | 165 } |
168 | 166 |
169 if (_initialized) { | 167 if (_initialized) { |
170 return InitStatus::OK; | 168 return InitStatus::OK; |
171 } | 169 } |
172 #if defined(USE_X11) | 170 #if defined(USE_X11) |
173 //Get X display handle for typing detection | 171 //Get X display handle for typing detection |
174 _XDisplay = XOpenDisplay(NULL); | 172 _XDisplay = XOpenDisplay(nullptr); |
175 if (!_XDisplay) { | 173 if (!_XDisplay) { |
176 LOG(LS_WARNING) | 174 LOG(LS_WARNING) |
177 << "failed to open X display, typing detection will not work"; | 175 << "failed to open X display, typing detection will not work"; |
178 } | 176 } |
179 #endif | 177 #endif |
180 _playWarning = 0; | 178 _playWarning = 0; |
181 _playError = 0; | 179 _playError = 0; |
182 _recWarning = 0; | 180 _recWarning = 0; |
183 _recError = 0; | 181 _recError = 0; |
184 | 182 |
185 _initialized = true; | 183 _initialized = true; |
186 | 184 |
187 return InitStatus::OK; | 185 return InitStatus::OK; |
(...skipping 30 matching lines...) Loading... |
218 | 216 |
219 tmpThread->Stop(); | 217 tmpThread->Stop(); |
220 delete tmpThread; | 218 delete tmpThread; |
221 | 219 |
222 _critSect.Enter(); | 220 _critSect.Enter(); |
223 } | 221 } |
224 #if defined(USE_X11) | 222 #if defined(USE_X11) |
225 if (_XDisplay) | 223 if (_XDisplay) |
226 { | 224 { |
227 XCloseDisplay(_XDisplay); | 225 XCloseDisplay(_XDisplay); |
228 _XDisplay = NULL; | 226 _XDisplay = nullptr; |
229 } | 227 } |
230 #endif | 228 #endif |
231 _initialized = false; | 229 _initialized = false; |
232 _outputDeviceIsSpecified = false; | 230 _outputDeviceIsSpecified = false; |
233 _inputDeviceIsSpecified = false; | 231 _inputDeviceIsSpecified = false; |
234 | 232 |
235 return 0; | 233 return 0; |
236 } | 234 } |
237 | 235 |
238 bool AudioDeviceLinuxALSA::Initialized() const | 236 bool AudioDeviceLinuxALSA::Initialized() const |
(...skipping 615 matching lines...) Loading... |
854 } | 852 } |
855 | 853 |
856 int32_t AudioDeviceLinuxALSA::PlayoutDeviceName( | 854 int32_t AudioDeviceLinuxALSA::PlayoutDeviceName( |
857 uint16_t index, | 855 uint16_t index, |
858 char name[kAdmMaxDeviceNameSize], | 856 char name[kAdmMaxDeviceNameSize], |
859 char guid[kAdmMaxGuidSize]) | 857 char guid[kAdmMaxGuidSize]) |
860 { | 858 { |
861 | 859 |
862 const uint16_t nDevices(PlayoutDevices()); | 860 const uint16_t nDevices(PlayoutDevices()); |
863 | 861 |
864 if ((index > (nDevices-1)) || (name == NULL)) | 862 if ((index > (nDevices - 1)) || (name == nullptr)) { |
865 { | 863 return -1; |
866 return -1; | |
867 } | 864 } |
868 | 865 |
869 memset(name, 0, kAdmMaxDeviceNameSize); | 866 memset(name, 0, kAdmMaxDeviceNameSize); |
870 | 867 |
871 if (guid != NULL) | 868 if (guid != nullptr) { |
872 { | 869 memset(guid, 0, kAdmMaxGuidSize); |
873 memset(guid, 0, kAdmMaxGuidSize); | |
874 } | 870 } |
875 | 871 |
876 return GetDevicesInfo(1, true, index, name, kAdmMaxDeviceNameSize); | 872 return GetDevicesInfo(1, true, index, name, kAdmMaxDeviceNameSize); |
877 } | 873 } |
878 | 874 |
879 int32_t AudioDeviceLinuxALSA::RecordingDeviceName( | 875 int32_t AudioDeviceLinuxALSA::RecordingDeviceName( |
880 uint16_t index, | 876 uint16_t index, |
881 char name[kAdmMaxDeviceNameSize], | 877 char name[kAdmMaxDeviceNameSize], |
882 char guid[kAdmMaxGuidSize]) | 878 char guid[kAdmMaxGuidSize]) |
883 { | 879 { |
884 | 880 |
885 const uint16_t nDevices(RecordingDevices()); | 881 const uint16_t nDevices(RecordingDevices()); |
886 | 882 |
887 if ((index > (nDevices-1)) || (name == NULL)) | 883 if ((index > (nDevices - 1)) || (name == nullptr)) { |
888 { | 884 return -1; |
889 return -1; | |
890 } | 885 } |
891 | 886 |
892 memset(name, 0, kAdmMaxDeviceNameSize); | 887 memset(name, 0, kAdmMaxDeviceNameSize); |
893 | 888 |
894 if (guid != NULL) | 889 if (guid != nullptr) { |
895 { | 890 memset(guid, 0, kAdmMaxGuidSize); |
896 memset(guid, 0, kAdmMaxGuidSize); | |
897 } | 891 } |
898 | 892 |
899 return GetDevicesInfo(1, false, index, name, kAdmMaxDeviceNameSize); | 893 return GetDevicesInfo(1, false, index, name, kAdmMaxDeviceNameSize); |
900 } | 894 } |
901 | 895 |
902 int16_t AudioDeviceLinuxALSA::RecordingDevices() | 896 int16_t AudioDeviceLinuxALSA::RecordingDevices() |
903 { | 897 { |
904 | 898 |
905 return (int16_t)GetDevicesInfo(0, false); | 899 return (int16_t)GetDevicesInfo(0, false); |
906 } | 900 } |
(...skipping 119 matching lines...) Loading... |
1026 } | 1020 } |
1027 // Initialize the speaker (devices might have been added or removed) | 1021 // Initialize the speaker (devices might have been added or removed) |
1028 if (InitSpeaker() == -1) | 1022 if (InitSpeaker() == -1) |
1029 { | 1023 { |
1030 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, | 1024 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
1031 " InitSpeaker() failed"); | 1025 " InitSpeaker() failed"); |
1032 } | 1026 } |
1033 | 1027 |
1034 // Start by closing any existing wave-output devices | 1028 // Start by closing any existing wave-output devices |
1035 // | 1029 // |
1036 if (_handlePlayout != NULL) | 1030 if (_handlePlayout != nullptr) { |
1037 { | 1031 LATE(snd_pcm_close)(_handlePlayout); |
1038 LATE(snd_pcm_close)(_handlePlayout); | 1032 _handlePlayout = nullptr; |
1039 _handlePlayout = NULL; | 1033 _playIsInitialized = false; |
1040 _playIsInitialized = false; | 1034 if (errVal < 0) { |
1041 if (errVal < 0) | 1035 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
1042 { | 1036 " Error closing current playout sound device, error:" |
1043 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 1037 " %s", |
1044 " Error closing current playout sound device, error:" | 1038 LATE(snd_strerror)(errVal)); |
1045 " %s", LATE(snd_strerror)(errVal)); | 1039 } |
1046 } | |
1047 } | 1040 } |
1048 | 1041 |
1049 // Open PCM device for playout | 1042 // Open PCM device for playout |
1050 char deviceName[kAdmMaxDeviceNameSize] = {0}; | 1043 char deviceName[kAdmMaxDeviceNameSize] = {0}; |
1051 GetDevicesInfo(2, true, _outputDeviceIndex, deviceName, | 1044 GetDevicesInfo(2, true, _outputDeviceIndex, deviceName, |
1052 kAdmMaxDeviceNameSize); | 1045 kAdmMaxDeviceNameSize); |
1053 | 1046 |
1054 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, | 1047 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, |
1055 " InitPlayout open (%s)", deviceName); | 1048 " InitPlayout open (%s)", deviceName); |
1056 | 1049 |
(...skipping 18 matching lines...) Loading... |
1075 break; | 1068 break; |
1076 } | 1069 } |
1077 } | 1070 } |
1078 } | 1071 } |
1079 if (errVal < 0) | 1072 if (errVal < 0) |
1080 { | 1073 { |
1081 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 1074 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
1082 " unable to open playback device: %s (%d)", | 1075 " unable to open playback device: %s (%d)", |
1083 LATE(snd_strerror)(errVal), | 1076 LATE(snd_strerror)(errVal), |
1084 errVal); | 1077 errVal); |
1085 _handlePlayout = NULL; | 1078 _handlePlayout = nullptr; |
1086 return -1; | 1079 return -1; |
1087 } | 1080 } |
1088 | 1081 |
1089 _playoutFramesIn10MS = _playoutFreq/100; | 1082 _playoutFramesIn10MS = _playoutFreq/100; |
1090 if ((errVal = LATE(snd_pcm_set_params)( _handlePlayout, | 1083 if ((errVal = LATE(snd_pcm_set_params)( _handlePlayout, |
1091 #if defined(WEBRTC_ARCH_BIG_ENDIAN) | 1084 #if defined(WEBRTC_ARCH_BIG_ENDIAN) |
1092 SND_PCM_FORMAT_S16_BE, | 1085 SND_PCM_FORMAT_S16_BE, |
1093 #else | 1086 #else |
1094 SND_PCM_FORMAT_S16_LE, //format | 1087 SND_PCM_FORMAT_S16_LE, //format |
1095 #endif | 1088 #endif |
1096 SND_PCM_ACCESS_RW_INTERLEAVED, //access | 1089 SND_PCM_ACCESS_RW_INTERLEAVED, //access |
1097 _playChannels, //channels | 1090 _playChannels, //channels |
1098 _playoutFreq, //rate | 1091 _playoutFreq, //rate |
1099 1, //soft_resample | 1092 1, //soft_resample |
1100 ALSA_PLAYOUT_LATENCY //40*1000 //latency required overall latency in us | 1093 ALSA_PLAYOUT_LATENCY //40*1000 //latency required overall latency in us |
1101 )) < 0) | 1094 )) < 0) |
1102 { /* 0.5sec */ | 1095 { /* 0.5sec */ |
1103 _playoutFramesIn10MS = 0; | 1096 _playoutFramesIn10MS = 0; |
1104 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 1097 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
1105 " unable to set playback device: %s (%d)", | 1098 " unable to set playback device: %s (%d)", |
1106 LATE(snd_strerror)(errVal), | 1099 LATE(snd_strerror)(errVal), |
1107 errVal); | 1100 errVal); |
1108 ErrorRecovery(errVal, _handlePlayout); | 1101 ErrorRecovery(errVal, _handlePlayout); |
1109 errVal = LATE(snd_pcm_close)(_handlePlayout); | 1102 errVal = LATE(snd_pcm_close)(_handlePlayout); |
1110 _handlePlayout = NULL; | 1103 _handlePlayout = nullptr; |
1111 return -1; | 1104 return -1; |
1112 } | 1105 } |
1113 | 1106 |
1114 errVal = LATE(snd_pcm_get_params)(_handlePlayout, | 1107 errVal = LATE(snd_pcm_get_params)(_handlePlayout, |
1115 &_playoutBufferSizeInFrame, &_playoutPeriodSizeInFrame); | 1108 &_playoutBufferSizeInFrame, &_playoutPeriodSizeInFrame); |
1116 if (errVal < 0) | 1109 if (errVal < 0) |
1117 { | 1110 { |
1118 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 1111 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
1119 " snd_pcm_get_params %s", | 1112 " snd_pcm_get_params %s", |
1120 LATE(snd_strerror)(errVal), | 1113 LATE(snd_strerror)(errVal), |
(...skipping 16 matching lines...) Loading... |
1137 } | 1130 } |
1138 | 1131 |
1139 // Set play buffer size | 1132 // Set play buffer size |
1140 _playoutBufferSizeIn10MS = LATE(snd_pcm_frames_to_bytes)( | 1133 _playoutBufferSizeIn10MS = LATE(snd_pcm_frames_to_bytes)( |
1141 _handlePlayout, _playoutFramesIn10MS); | 1134 _handlePlayout, _playoutFramesIn10MS); |
1142 | 1135 |
1143 // Init varaibles used for play | 1136 // Init varaibles used for play |
1144 _playWarning = 0; | 1137 _playWarning = 0; |
1145 _playError = 0; | 1138 _playError = 0; |
1146 | 1139 |
1147 if (_handlePlayout != NULL) | 1140 if (_handlePlayout != nullptr) { |
1148 { | 1141 _playIsInitialized = true; |
1149 _playIsInitialized = true; | 1142 return 0; |
1150 return 0; | |
1151 } | 1143 } |
1152 else | 1144 else |
1153 { | 1145 { |
1154 return -1; | 1146 return -1; |
1155 } | 1147 } |
1156 | 1148 |
1157 return 0; | 1149 return 0; |
1158 } | 1150 } |
1159 | 1151 |
1160 int32_t AudioDeviceLinuxALSA::InitRecording() | 1152 int32_t AudioDeviceLinuxALSA::InitRecording() |
(...skipping 20 matching lines...) Loading... |
1181 | 1173 |
1182 // Initialize the microphone (devices might have been added or removed) | 1174 // Initialize the microphone (devices might have been added or removed) |
1183 if (InitMicrophone() == -1) | 1175 if (InitMicrophone() == -1) |
1184 { | 1176 { |
1185 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, | 1177 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
1186 " InitMicrophone() failed"); | 1178 " InitMicrophone() failed"); |
1187 } | 1179 } |
1188 | 1180 |
1189 // Start by closing any existing pcm-input devices | 1181 // Start by closing any existing pcm-input devices |
1190 // | 1182 // |
1191 if (_handleRecord != NULL) | 1183 if (_handleRecord != nullptr) { |
1192 { | 1184 int errVal = LATE(snd_pcm_close)(_handleRecord); |
1193 int errVal = LATE(snd_pcm_close)(_handleRecord); | 1185 _handleRecord = nullptr; |
1194 _handleRecord = NULL; | 1186 _recIsInitialized = false; |
1195 _recIsInitialized = false; | 1187 if (errVal < 0) { |
1196 if (errVal < 0) | 1188 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
1197 { | 1189 " Error closing current recording sound device," |
1198 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 1190 " error: %s", |
1199 " Error closing current recording sound device," | 1191 LATE(snd_strerror)(errVal)); |
1200 " error: %s", | 1192 } |
1201 LATE(snd_strerror)(errVal)); | |
1202 } | |
1203 } | 1193 } |
1204 | 1194 |
1205 // Open PCM device for recording | 1195 // Open PCM device for recording |
1206 // The corresponding settings for playout are made after the record settings | 1196 // The corresponding settings for playout are made after the record settings |
1207 char deviceName[kAdmMaxDeviceNameSize] = {0}; | 1197 char deviceName[kAdmMaxDeviceNameSize] = {0}; |
1208 GetDevicesInfo(2, false, _inputDeviceIndex, deviceName, | 1198 GetDevicesInfo(2, false, _inputDeviceIndex, deviceName, |
1209 kAdmMaxDeviceNameSize); | 1199 kAdmMaxDeviceNameSize); |
1210 | 1200 |
1211 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, | 1201 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, |
1212 "InitRecording open (%s)", deviceName); | 1202 "InitRecording open (%s)", deviceName); |
(...skipping 18 matching lines...) Loading... |
1231 { | 1221 { |
1232 break; | 1222 break; |
1233 } | 1223 } |
1234 } | 1224 } |
1235 } | 1225 } |
1236 if (errVal < 0) | 1226 if (errVal < 0) |
1237 { | 1227 { |
1238 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 1228 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
1239 " unable to open record device: %s", | 1229 " unable to open record device: %s", |
1240 LATE(snd_strerror)(errVal)); | 1230 LATE(snd_strerror)(errVal)); |
1241 _handleRecord = NULL; | 1231 _handleRecord = nullptr; |
1242 return -1; | 1232 return -1; |
1243 } | 1233 } |
1244 | 1234 |
1245 _recordingFramesIn10MS = _recordingFreq/100; | 1235 _recordingFramesIn10MS = _recordingFreq/100; |
1246 if ((errVal = LATE(snd_pcm_set_params)(_handleRecord, | 1236 if ((errVal = LATE(snd_pcm_set_params)(_handleRecord, |
1247 #if defined(WEBRTC_ARCH_BIG_ENDIAN) | 1237 #if defined(WEBRTC_ARCH_BIG_ENDIAN) |
1248 SND_PCM_FORMAT_S16_BE, //format | 1238 SND_PCM_FORMAT_S16_BE, //format |
1249 #else | 1239 #else |
1250 SND_PCM_FORMAT_S16_LE, //format | 1240 SND_PCM_FORMAT_S16_LE, //format |
1251 #endif | 1241 #endif |
(...skipping 22 matching lines...) Loading... |
1274 1, //soft_resample | 1264 1, //soft_resample |
1275 ALSA_CAPTURE_LATENCY //latency in us | 1265 ALSA_CAPTURE_LATENCY //latency in us |
1276 )) < 0) | 1266 )) < 0) |
1277 { | 1267 { |
1278 _recordingFramesIn10MS = 0; | 1268 _recordingFramesIn10MS = 0; |
1279 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 1269 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
1280 " unable to set record settings: %s (%d)", | 1270 " unable to set record settings: %s (%d)", |
1281 LATE(snd_strerror)(errVal), errVal); | 1271 LATE(snd_strerror)(errVal), errVal); |
1282 ErrorRecovery(errVal, _handleRecord); | 1272 ErrorRecovery(errVal, _handleRecord); |
1283 errVal = LATE(snd_pcm_close)(_handleRecord); | 1273 errVal = LATE(snd_pcm_close)(_handleRecord); |
1284 _handleRecord = NULL; | 1274 _handleRecord = nullptr; |
1285 return -1; | 1275 return -1; |
1286 } | 1276 } |
1287 } | 1277 } |
1288 | 1278 |
1289 errVal = LATE(snd_pcm_get_params)(_handleRecord, | 1279 errVal = LATE(snd_pcm_get_params)(_handleRecord, |
1290 &_recordingBuffersizeInFrame, &_recordingPeriodSizeInFrame); | 1280 &_recordingBuffersizeInFrame, &_recordingPeriodSizeInFrame); |
1291 if (errVal < 0) | 1281 if (errVal < 0) |
1292 { | 1282 { |
1293 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 1283 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
1294 " snd_pcm_get_params %s", | 1284 " snd_pcm_get_params %s", |
(...skipping 12 matching lines...) Loading... |
1307 { | 1297 { |
1308 // Update webrtc audio buffer with the selected parameters | 1298 // Update webrtc audio buffer with the selected parameters |
1309 _ptrAudioBuffer->SetRecordingSampleRate(_recordingFreq); | 1299 _ptrAudioBuffer->SetRecordingSampleRate(_recordingFreq); |
1310 _ptrAudioBuffer->SetRecordingChannels(_recChannels); | 1300 _ptrAudioBuffer->SetRecordingChannels(_recChannels); |
1311 } | 1301 } |
1312 | 1302 |
1313 // Set rec buffer size and create buffer | 1303 // Set rec buffer size and create buffer |
1314 _recordingBufferSizeIn10MS = LATE(snd_pcm_frames_to_bytes)( | 1304 _recordingBufferSizeIn10MS = LATE(snd_pcm_frames_to_bytes)( |
1315 _handleRecord, _recordingFramesIn10MS); | 1305 _handleRecord, _recordingFramesIn10MS); |
1316 | 1306 |
1317 if (_handleRecord != NULL) | 1307 if (_handleRecord != nullptr) { |
1318 { | 1308 // Mark recording side as initialized |
1319 // Mark recording side as initialized | 1309 _recIsInitialized = true; |
1320 _recIsInitialized = true; | 1310 return 0; |
1321 return 0; | |
1322 } | 1311 } |
1323 else | 1312 else |
1324 { | 1313 { |
1325 return -1; | 1314 return -1; |
1326 } | 1315 } |
1327 | 1316 |
1328 return 0; | 1317 return 0; |
1329 } | 1318 } |
1330 | 1319 |
1331 int32_t AudioDeviceLinuxALSA::StartRecording() | 1320 int32_t AudioDeviceLinuxALSA::StartRecording() |
(...skipping 65 matching lines...) Loading... |
1397 { | 1386 { |
1398 | 1387 |
1399 { | 1388 { |
1400 CriticalSectionScoped lock(&_critSect); | 1389 CriticalSectionScoped lock(&_critSect); |
1401 | 1390 |
1402 if (!_recIsInitialized) | 1391 if (!_recIsInitialized) |
1403 { | 1392 { |
1404 return 0; | 1393 return 0; |
1405 } | 1394 } |
1406 | 1395 |
1407 if (_handleRecord == NULL) | 1396 if (_handleRecord == nullptr) { |
1408 { | 1397 return -1; |
1409 return -1; | |
1410 } | 1398 } |
1411 | 1399 |
1412 // Make sure we don't start recording (it's asynchronous). | 1400 // Make sure we don't start recording (it's asynchronous). |
1413 _recIsInitialized = false; | 1401 _recIsInitialized = false; |
1414 _recording = false; | 1402 _recording = false; |
1415 } | 1403 } |
1416 | 1404 |
1417 if (_ptrThreadRec) | 1405 if (_ptrThreadRec) |
1418 { | 1406 { |
1419 _ptrThreadRec->Stop(); | 1407 _ptrThreadRec->Stop(); |
1420 _ptrThreadRec.reset(); | 1408 _ptrThreadRec.reset(); |
1421 } | 1409 } |
1422 | 1410 |
1423 CriticalSectionScoped lock(&_critSect); | 1411 CriticalSectionScoped lock(&_critSect); |
1424 _recordingFramesLeft = 0; | 1412 _recordingFramesLeft = 0; |
1425 if (_recordingBuffer) | 1413 if (_recordingBuffer) |
1426 { | 1414 { |
1427 delete [] _recordingBuffer; | 1415 delete [] _recordingBuffer; |
1428 _recordingBuffer = NULL; | 1416 _recordingBuffer = nullptr; |
1429 } | 1417 } |
1430 | 1418 |
1431 // Stop and close pcm recording device. | 1419 // Stop and close pcm recording device. |
1432 int errVal = LATE(snd_pcm_drop)(_handleRecord); | 1420 int errVal = LATE(snd_pcm_drop)(_handleRecord); |
1433 if (errVal < 0) | 1421 if (errVal < 0) |
1434 { | 1422 { |
1435 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 1423 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
1436 " Error stop recording: %s", | 1424 " Error stop recording: %s", |
1437 LATE(snd_strerror)(errVal)); | 1425 LATE(snd_strerror)(errVal)); |
1438 return -1; | 1426 return -1; |
1439 } | 1427 } |
1440 | 1428 |
1441 errVal = LATE(snd_pcm_close)(_handleRecord); | 1429 errVal = LATE(snd_pcm_close)(_handleRecord); |
1442 if (errVal < 0) | 1430 if (errVal < 0) |
1443 { | 1431 { |
1444 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 1432 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
1445 " Error closing record sound device, error: %s", | 1433 " Error closing record sound device, error: %s", |
1446 LATE(snd_strerror)(errVal)); | 1434 LATE(snd_strerror)(errVal)); |
1447 return -1; | 1435 return -1; |
1448 } | 1436 } |
1449 | 1437 |
1450 // Check if we have muted and unmute if so. | 1438 // Check if we have muted and unmute if so. |
1451 bool muteEnabled = false; | 1439 bool muteEnabled = false; |
1452 MicrophoneMute(muteEnabled); | 1440 MicrophoneMute(muteEnabled); |
1453 if (muteEnabled) | 1441 if (muteEnabled) |
1454 { | 1442 { |
1455 SetMicrophoneMute(false); | 1443 SetMicrophoneMute(false); |
1456 } | 1444 } |
1457 | 1445 |
1458 // set the pcm input handle to NULL | 1446 // set the pcm input handle to null |
1459 _handleRecord = NULL; | 1447 _handleRecord = nullptr; |
1460 return 0; | 1448 return 0; |
1461 } | 1449 } |
1462 | 1450 |
1463 bool AudioDeviceLinuxALSA::RecordingIsInitialized() const | 1451 bool AudioDeviceLinuxALSA::RecordingIsInitialized() const |
1464 { | 1452 { |
1465 return (_recIsInitialized); | 1453 return (_recIsInitialized); |
1466 } | 1454 } |
1467 | 1455 |
1468 bool AudioDeviceLinuxALSA::Recording() const | 1456 bool AudioDeviceLinuxALSA::Recording() const |
1469 { | 1457 { |
(...skipping 53 matching lines...) Loading... |
1523 { | 1511 { |
1524 | 1512 |
1525 { | 1513 { |
1526 CriticalSectionScoped lock(&_critSect); | 1514 CriticalSectionScoped lock(&_critSect); |
1527 | 1515 |
1528 if (!_playIsInitialized) | 1516 if (!_playIsInitialized) |
1529 { | 1517 { |
1530 return 0; | 1518 return 0; |
1531 } | 1519 } |
1532 | 1520 |
1533 if (_handlePlayout == NULL) | 1521 if (_handlePlayout == nullptr) { |
1534 { | 1522 return -1; |
1535 return -1; | |
1536 } | 1523 } |
1537 | 1524 |
1538 _playing = false; | 1525 _playing = false; |
1539 } | 1526 } |
1540 | 1527 |
1541 // stop playout thread first | 1528 // stop playout thread first |
1542 if (_ptrThreadPlay) | 1529 if (_ptrThreadPlay) |
1543 { | 1530 { |
1544 _ptrThreadPlay->Stop(); | 1531 _ptrThreadPlay->Stop(); |
1545 _ptrThreadPlay.reset(); | 1532 _ptrThreadPlay.reset(); |
1546 } | 1533 } |
1547 | 1534 |
1548 CriticalSectionScoped lock(&_critSect); | 1535 CriticalSectionScoped lock(&_critSect); |
1549 | 1536 |
1550 _playoutFramesLeft = 0; | 1537 _playoutFramesLeft = 0; |
1551 delete [] _playoutBuffer; | 1538 delete [] _playoutBuffer; |
1552 _playoutBuffer = NULL; | 1539 _playoutBuffer = nullptr; |
1553 | 1540 |
1554 // stop and close pcm playout device | 1541 // stop and close pcm playout device |
1555 int errVal = LATE(snd_pcm_drop)(_handlePlayout); | 1542 int errVal = LATE(snd_pcm_drop)(_handlePlayout); |
1556 if (errVal < 0) | 1543 if (errVal < 0) |
1557 { | 1544 { |
1558 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 1545 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
1559 " Error stop playing: %s", | 1546 " Error stop playing: %s", |
1560 LATE(snd_strerror)(errVal)); | 1547 LATE(snd_strerror)(errVal)); |
1561 } | 1548 } |
1562 | 1549 |
1563 errVal = LATE(snd_pcm_close)(_handlePlayout); | 1550 errVal = LATE(snd_pcm_close)(_handlePlayout); |
1564 if (errVal < 0) | 1551 if (errVal < 0) |
1565 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 1552 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
1566 " Error closing playout sound device, error: %s", | 1553 " Error closing playout sound device, error: %s", |
1567 LATE(snd_strerror)(errVal)); | 1554 LATE(snd_strerror)(errVal)); |
1568 | 1555 |
1569 // set the pcm input handle to NULL | 1556 // set the pcm input handle to null |
1570 _playIsInitialized = false; | 1557 _playIsInitialized = false; |
1571 _handlePlayout = NULL; | 1558 _handlePlayout = nullptr; |
1572 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, | 1559 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, |
1573 " handle_playout is now set to NULL"); | 1560 " handle_playout is now set to null"); |
1574 | 1561 |
1575 return 0; | 1562 return 0; |
1576 } | 1563 } |
1577 | 1564 |
1578 int32_t AudioDeviceLinuxALSA::PlayoutDelay(uint16_t& delayMS) const | 1565 int32_t AudioDeviceLinuxALSA::PlayoutDelay(uint16_t& delayMS) const |
1579 { | 1566 { |
1580 delayMS = (uint16_t)_playoutDelay * 1000 / _playoutFreq; | 1567 delayMS = (uint16_t)_playoutDelay * 1000 / _playoutFreq; |
1581 return 0; | 1568 return 0; |
1582 } | 1569 } |
1583 | 1570 |
(...skipping 150 matching lines...) Loading... |
1734 if (err != 0) | 1721 if (err != 0) |
1735 { | 1722 { |
1736 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 1723 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
1737 "GetDevicesInfo - device name free hint error: %s", | 1724 "GetDevicesInfo - device name free hint error: %s", |
1738 LATE(snd_strerror)(err)); | 1725 LATE(snd_strerror)(err)); |
1739 } | 1726 } |
1740 | 1727 |
1741 return 0; | 1728 return 0; |
1742 } | 1729 } |
1743 | 1730 |
1744 for (void **list = hints; *list != NULL; ++list) | 1731 for (void** list = hints; *list != nullptr; ++list) { |
1745 { | 1732 char* actualType = LATE(snd_device_name_get_hint)(*list, "IOID"); |
1746 char *actualType = LATE(snd_device_name_get_hint)(*list, "IOID"); | 1733 if (actualType) { // nullptr means it's both. |
1747 if (actualType) | 1734 bool wrongType = (strcmp(actualType, type) != 0); |
1748 { // NULL means it's both. | 1735 free(actualType); |
1749 bool wrongType = (strcmp(actualType, type) != 0); | 1736 if (wrongType) { |
1750 free(actualType); | 1737 // Wrong type of device (i.e., input vs. output). |
1751 if (wrongType) | 1738 continue; |
1752 { | 1739 } |
1753 // Wrong type of device (i.e., input vs. output). | 1740 } |
1754 continue; | 1741 |
1755 } | 1742 char* name = LATE(snd_device_name_get_hint)(*list, "NAME"); |
| 1743 if (!name) { |
| 1744 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
| 1745 "Device has no name"); |
| 1746 // Skip it. |
| 1747 continue; |
| 1748 } |
| 1749 |
| 1750 // Now check if we actually want to show this device. |
| 1751 if (strcmp(name, "default") != 0 && strcmp(name, "null") != 0 && |
| 1752 strcmp(name, "pulse") != 0 && |
| 1753 strncmp(name, ignorePrefix, strlen(ignorePrefix)) != 0) { |
| 1754 // Yes, we do. |
| 1755 char* desc = LATE(snd_device_name_get_hint)(*list, "DESC"); |
| 1756 if (!desc) { |
| 1757 // Virtual devices don't necessarily have descriptions. |
| 1758 // Use their names instead. |
| 1759 desc = name; |
1756 } | 1760 } |
1757 | 1761 |
1758 char *name = LATE(snd_device_name_get_hint)(*list, "NAME"); | 1762 if (FUNC_GET_NUM_OF_DEVICE == function) { |
1759 if (!name) | 1763 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, |
1760 { | 1764 " Enum device %d - %s", enumCount, name); |
1761 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 1765 } |
1762 "Device has no name"); | 1766 if ((FUNC_GET_DEVICE_NAME == function) && |
1763 // Skip it. | 1767 (enumDeviceNo == enumCount)) { |
1764 continue; | 1768 // We have found the enum device, copy the name to buffer. |
| 1769 strncpy(enumDeviceName, desc, ednLen); |
| 1770 enumDeviceName[ednLen - 1] = '\0'; |
| 1771 keepSearching = false; |
| 1772 // Replace '\n' with '-'. |
| 1773 char* pret = strchr(enumDeviceName, '\n' /*0xa*/); // LF |
| 1774 if (pret) |
| 1775 *pret = '-'; |
| 1776 } |
| 1777 if ((FUNC_GET_DEVICE_NAME_FOR_AN_ENUM == function) && |
| 1778 (enumDeviceNo == enumCount)) { |
| 1779 // We have found the enum device, copy the name to buffer. |
| 1780 strncpy(enumDeviceName, name, ednLen); |
| 1781 enumDeviceName[ednLen - 1] = '\0'; |
| 1782 keepSearching = false; |
1765 } | 1783 } |
1766 | 1784 |
1767 // Now check if we actually want to show this device. | 1785 if (keepSearching) |
1768 if (strcmp(name, "default") != 0 && | 1786 ++enumCount; |
1769 strcmp(name, "null") != 0 && | |
1770 strcmp(name, "pulse") != 0 && | |
1771 strncmp(name, ignorePrefix, strlen(ignorePrefix)) != 0) | |
1772 { | |
1773 // Yes, we do. | |
1774 char *desc = LATE(snd_device_name_get_hint)(*list, "DESC"); | |
1775 if (!desc) | |
1776 { | |
1777 // Virtual devices don't necessarily have descriptions. | |
1778 // Use their names instead. | |
1779 desc = name; | |
1780 } | |
1781 | 1787 |
1782 if (FUNC_GET_NUM_OF_DEVICE == function) | 1788 if (desc != name) |
1783 { | 1789 free(desc); |
1784 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, | 1790 } |
1785 " Enum device %d - %s", enumCount, name); | |
1786 | 1791 |
1787 } | 1792 free(name); |
1788 if ((FUNC_GET_DEVICE_NAME == function) && | |
1789 (enumDeviceNo == enumCount)) | |
1790 { | |
1791 // We have found the enum device, copy the name to buffer. | |
1792 strncpy(enumDeviceName, desc, ednLen); | |
1793 enumDeviceName[ednLen-1] = '\0'; | |
1794 keepSearching = false; | |
1795 // Replace '\n' with '-'. | |
1796 char * pret = strchr(enumDeviceName, '\n'/*0xa*/); //LF | |
1797 if (pret) | |
1798 *pret = '-'; | |
1799 } | |
1800 if ((FUNC_GET_DEVICE_NAME_FOR_AN_ENUM == function) && | |
1801 (enumDeviceNo == enumCount)) | |
1802 { | |
1803 // We have found the enum device, copy the name to buffer. | |
1804 strncpy(enumDeviceName, name, ednLen); | |
1805 enumDeviceName[ednLen-1] = '\0'; | |
1806 keepSearching = false; | |
1807 } | |
1808 | 1793 |
1809 if (keepSearching) | 1794 if (!keepSearching) |
1810 ++enumCount; | 1795 break; |
1811 | |
1812 if (desc != name) | |
1813 free(desc); | |
1814 } | |
1815 | |
1816 free(name); | |
1817 | |
1818 if (!keepSearching) | |
1819 break; | |
1820 } | 1796 } |
1821 | 1797 |
1822 err = LATE(snd_device_name_free_hint)(hints); | 1798 err = LATE(snd_device_name_free_hint)(hints); |
1823 if (err != 0) | 1799 if (err != 0) |
1824 { | 1800 { |
1825 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 1801 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
1826 "GetDevicesInfo - device name free hint error: %s", | 1802 "GetDevicesInfo - device name free hint error: %s", |
1827 LATE(snd_strerror)(err)); | 1803 LATE(snd_strerror)(err)); |
1828 // Continue and return true anyway, since we did get the whole list. | 1804 // Continue and return true anyway, since we did get the whole list. |
1829 } | 1805 } |
(...skipping 13 matching lines...) Loading... |
1843 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 1819 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
1844 "GetDevicesInfo - Could not find device name or numbers"); | 1820 "GetDevicesInfo - Could not find device name or numbers"); |
1845 return -1; | 1821 return -1; |
1846 } | 1822 } |
1847 | 1823 |
1848 return 0; | 1824 return 0; |
1849 } | 1825 } |
1850 | 1826 |
1851 int32_t AudioDeviceLinuxALSA::InputSanityCheckAfterUnlockedPeriod() const | 1827 int32_t AudioDeviceLinuxALSA::InputSanityCheckAfterUnlockedPeriod() const |
1852 { | 1828 { |
1853 if (_handleRecord == NULL) | 1829 if (_handleRecord == nullptr) { |
1854 { | 1830 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
1855 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 1831 " input state has been modified during unlocked period"); |
1856 " input state has been modified during unlocked period"); | 1832 return -1; |
1857 return -1; | |
1858 } | 1833 } |
1859 return 0; | 1834 return 0; |
1860 } | 1835 } |
1861 | 1836 |
1862 int32_t AudioDeviceLinuxALSA::OutputSanityCheckAfterUnlockedPeriod() const | 1837 int32_t AudioDeviceLinuxALSA::OutputSanityCheckAfterUnlockedPeriod() const |
1863 { | 1838 { |
1864 if (_handlePlayout == NULL) | 1839 if (_handlePlayout == nullptr) { |
1865 { | 1840 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
1866 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 1841 " output state has been modified during unlocked period"); |
1867 " output state has been modified during unlocked period"); | 1842 return -1; |
1868 return -1; | |
1869 } | 1843 } |
1870 return 0; | 1844 return 0; |
1871 } | 1845 } |
1872 | 1846 |
1873 int32_t AudioDeviceLinuxALSA::ErrorRecovery(int32_t error, | 1847 int32_t AudioDeviceLinuxALSA::ErrorRecovery(int32_t error, |
1874 snd_pcm_t* deviceHandle) | 1848 snd_pcm_t* deviceHandle) |
1875 { | 1849 { |
1876 int st = LATE(snd_pcm_state)(deviceHandle); | 1850 int st = LATE(snd_pcm_state)(deviceHandle); |
1877 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, | 1851 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, |
1878 "Trying to recover from error: %s (%d) (state %d)", | 1852 "Trying to recover from error: %s (%d) (state %d)", |
(...skipping 333 matching lines...) Loading... |
2212 state |= (szKey[i] ^ _oldKeyState[i]) & szKey[i]; | 2186 state |= (szKey[i] ^ _oldKeyState[i]) & szKey[i]; |
2213 | 2187 |
2214 // Save old state | 2188 // Save old state |
2215 memcpy((char*)_oldKeyState, (char*)szKey, sizeof(_oldKeyState)); | 2189 memcpy((char*)_oldKeyState, (char*)szKey, sizeof(_oldKeyState)); |
2216 return (state != 0); | 2190 return (state != 0); |
2217 #else | 2191 #else |
2218 return false; | 2192 return false; |
2219 #endif | 2193 #endif |
2220 } | 2194 } |
2221 } // namespace webrtc | 2195 } // namespace webrtc |
OLD | NEW |