OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 #include "webrtc/base/platform_thread.h" | 10 #include "webrtc/base/platform_thread.h" |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 // PLAYOUT | 206 // PLAYOUT |
207 if (!_outputFilename.empty() && _outputFile.OpenFile( | 207 if (!_outputFilename.empty() && _outputFile.OpenFile( |
208 _outputFilename.c_str(), false, false, false) == -1) { | 208 _outputFilename.c_str(), false, false, false) == -1) { |
209 printf("Failed to open playout file %s!\n", _outputFilename.c_str()); | 209 printf("Failed to open playout file %s!\n", _outputFilename.c_str()); |
210 _playing = false; | 210 _playing = false; |
211 delete [] _playoutBuffer; | 211 delete [] _playoutBuffer; |
212 _playoutBuffer = NULL; | 212 _playoutBuffer = NULL; |
213 return -1; | 213 return -1; |
214 } | 214 } |
215 | 215 |
216 const char* threadName = "webrtc_audio_module_play_thread"; | 216 _ptrThreadPlay.reset(new rtc::PlatformThread( |
217 _ptrThreadPlay = | 217 PlayThreadFunc, this, "webrtc_audio_module_play_thread")); |
218 PlatformThread::CreateThread(PlayThreadFunc, this, threadName); | 218 _ptrThreadPlay->Start(); |
219 if (!_ptrThreadPlay->Start()) { | 219 _ptrThreadPlay->SetPriority(rtc::kRealtimePriority); |
220 _ptrThreadPlay.reset(); | |
221 _playing = false; | |
222 delete [] _playoutBuffer; | |
223 _playoutBuffer = NULL; | |
224 return -1; | |
225 } | |
226 _ptrThreadPlay->SetPriority(kRealtimePriority); | |
227 return 0; | 220 return 0; |
228 } | 221 } |
229 | 222 |
230 int32_t FileAudioDevice::StopPlayout() { | 223 int32_t FileAudioDevice::StopPlayout() { |
231 { | 224 { |
232 CriticalSectionScoped lock(&_critSect); | 225 CriticalSectionScoped lock(&_critSect); |
233 _playing = false; | 226 _playing = false; |
234 } | 227 } |
235 | 228 |
236 // stop playout thread first | 229 // stop playout thread first |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 if (!_inputFilename.empty() && _inputFile.OpenFile( | 262 if (!_inputFilename.empty() && _inputFile.OpenFile( |
270 _inputFilename.c_str(), true, true, false) == -1) { | 263 _inputFilename.c_str(), true, true, false) == -1) { |
271 printf("Failed to open audio input file %s!\n", | 264 printf("Failed to open audio input file %s!\n", |
272 _inputFilename.c_str()); | 265 _inputFilename.c_str()); |
273 _recording = false; | 266 _recording = false; |
274 delete[] _recordingBuffer; | 267 delete[] _recordingBuffer; |
275 _recordingBuffer = NULL; | 268 _recordingBuffer = NULL; |
276 return -1; | 269 return -1; |
277 } | 270 } |
278 | 271 |
279 const char* threadName = "webrtc_audio_module_capture_thread"; | 272 _ptrThreadRec.reset(new rtc::PlatformThread( |
280 _ptrThreadRec = PlatformThread::CreateThread(RecThreadFunc, this, threadName); | 273 RecThreadFunc, this, "webrtc_audio_module_capture_thread")); |
281 | 274 |
282 if (!_ptrThreadRec->Start()) { | 275 _ptrThreadRec->Start(); |
283 _ptrThreadRec.reset(); | 276 _ptrThreadRec->SetPriority(rtc::kRealtimePriority); |
284 _recording = false; | |
285 delete [] _recordingBuffer; | |
286 _recordingBuffer = NULL; | |
287 return -1; | |
288 } | |
289 _ptrThreadRec->SetPriority(kRealtimePriority); | |
290 | 277 |
291 return 0; | 278 return 0; |
292 } | 279 } |
293 | 280 |
294 | 281 |
295 int32_t FileAudioDevice::StopRecording() { | 282 int32_t FileAudioDevice::StopRecording() { |
296 { | 283 { |
297 CriticalSectionScoped lock(&_critSect); | 284 CriticalSectionScoped lock(&_critSect); |
298 _recording = false; | 285 _recording = false; |
299 } | 286 } |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 _critSect.Enter(); | 528 _critSect.Enter(); |
542 } | 529 } |
543 } | 530 } |
544 | 531 |
545 _critSect.Leave(); | 532 _critSect.Leave(); |
546 SleepMs(10 - (_clock->CurrentNtpInMilliseconds() - currentTime)); | 533 SleepMs(10 - (_clock->CurrentNtpInMilliseconds() - currentTime)); |
547 return true; | 534 return true; |
548 } | 535 } |
549 | 536 |
550 } // namespace webrtc | 537 } // namespace webrtc |
OLD | NEW |