| 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 22 matching lines...) Expand all Loading... |
| 33 _timeEventPlay(*EventWrapper::Create()), | 33 _timeEventPlay(*EventWrapper::Create()), |
| 34 _recStartEvent(*EventWrapper::Create()), | 34 _recStartEvent(*EventWrapper::Create()), |
| 35 _playStartEvent(*EventWrapper::Create()), | 35 _playStartEvent(*EventWrapper::Create()), |
| 36 _inputDeviceIndex(0), | 36 _inputDeviceIndex(0), |
| 37 _outputDeviceIndex(0), | 37 _outputDeviceIndex(0), |
| 38 _inputDeviceIsSpecified(false), | 38 _inputDeviceIsSpecified(false), |
| 39 _outputDeviceIsSpecified(false), | 39 _outputDeviceIsSpecified(false), |
| 40 sample_rate_hz_(0), | 40 sample_rate_hz_(0), |
| 41 _recChannels(1), | 41 _recChannels(1), |
| 42 _playChannels(1), | 42 _playChannels(1), |
| 43 _playBufType(AudioDeviceModule::kFixedBufferSize), | |
| 44 _initialized(false), | 43 _initialized(false), |
| 45 _recording(false), | 44 _recording(false), |
| 46 _playing(false), | 45 _playing(false), |
| 47 _recIsInitialized(false), | 46 _recIsInitialized(false), |
| 48 _playIsInitialized(false), | 47 _playIsInitialized(false), |
| 49 _startRec(false), | 48 _startRec(false), |
| 50 _stopRec(false), | 49 _stopRec(false), |
| 51 _startPlay(false), | 50 _startPlay(false), |
| 52 _stopPlay(false), | 51 _stopPlay(false), |
| 53 _AGC(false), | 52 _AGC(false), |
| 54 update_speaker_volume_at_startup_(false), | 53 update_speaker_volume_at_startup_(false), |
| 55 _playBufDelayFixed(20), | |
| 56 _sndCardPlayDelay(0), | 54 _sndCardPlayDelay(0), |
| 57 _sndCardRecDelay(0), | 55 _sndCardRecDelay(0), |
| 58 _writeErrors(0), | 56 _writeErrors(0), |
| 59 _playWarning(0), | 57 _playWarning(0), |
| 60 _playError(0), | 58 _playError(0), |
| 61 _recWarning(0), | 59 _recWarning(0), |
| 62 _recError(0), | 60 _recError(0), |
| 63 _deviceIndex(-1), | 61 _deviceIndex(-1), |
| 64 _numPlayDevices(0), | 62 _numPlayDevices(0), |
| 65 _numRecDevices(0), | 63 _numRecDevices(0), |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 | 389 |
| 392 if (_mixerManager.MinSpeakerVolume(minVol) == -1) { | 390 if (_mixerManager.MinSpeakerVolume(minVol) == -1) { |
| 393 return -1; | 391 return -1; |
| 394 } | 392 } |
| 395 | 393 |
| 396 minVolume = minVol; | 394 minVolume = minVol; |
| 397 | 395 |
| 398 return 0; | 396 return 0; |
| 399 } | 397 } |
| 400 | 398 |
| 401 int32_t AudioDeviceLinuxPulse::SpeakerVolumeStepSize(uint16_t& stepSize) const { | |
| 402 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 403 uint16_t delta(0); | |
| 404 | |
| 405 if (_mixerManager.SpeakerVolumeStepSize(delta) == -1) { | |
| 406 return -1; | |
| 407 } | |
| 408 | |
| 409 stepSize = delta; | |
| 410 | |
| 411 return 0; | |
| 412 } | |
| 413 | |
| 414 int32_t AudioDeviceLinuxPulse::SpeakerMuteIsAvailable(bool& available) { | 399 int32_t AudioDeviceLinuxPulse::SpeakerMuteIsAvailable(bool& available) { |
| 415 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 400 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 416 bool isAvailable(false); | 401 bool isAvailable(false); |
| 417 bool wasInitialized = _mixerManager.SpeakerIsInitialized(); | 402 bool wasInitialized = _mixerManager.SpeakerIsInitialized(); |
| 418 | 403 |
| 419 // Make an attempt to open up the | 404 // Make an attempt to open up the |
| 420 // output mixer corresponding to the currently selected output device. | 405 // output mixer corresponding to the currently selected output device. |
| 421 // | 406 // |
| 422 if (!wasInitialized && InitSpeaker() == -1) { | 407 if (!wasInitialized && InitSpeaker() == -1) { |
| 423 // If we end up here it means that the selected speaker has no volume | 408 // If we end up here it means that the selected speaker has no volume |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 480 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 496 bool muted(0); | 481 bool muted(0); |
| 497 if (_mixerManager.MicrophoneMute(muted) == -1) { | 482 if (_mixerManager.MicrophoneMute(muted) == -1) { |
| 498 return -1; | 483 return -1; |
| 499 } | 484 } |
| 500 | 485 |
| 501 enabled = muted; | 486 enabled = muted; |
| 502 return 0; | 487 return 0; |
| 503 } | 488 } |
| 504 | 489 |
| 505 int32_t AudioDeviceLinuxPulse::MicrophoneBoostIsAvailable(bool& available) { | |
| 506 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 507 bool isAvailable(false); | |
| 508 bool wasInitialized = _mixerManager.MicrophoneIsInitialized(); | |
| 509 | |
| 510 // Enumerate all avaliable microphone and make an attempt to open up the | |
| 511 // input mixer corresponding to the currently selected input device. | |
| 512 // | |
| 513 if (!wasInitialized && InitMicrophone() == -1) { | |
| 514 // If we end up here it means that the selected microphone has no | |
| 515 // volume control, hence it is safe to state that there is no | |
| 516 // boost control already at this stage. | |
| 517 available = false; | |
| 518 return 0; | |
| 519 } | |
| 520 | |
| 521 // Check if the selected microphone has a boost control | |
| 522 _mixerManager.MicrophoneBoostIsAvailable(isAvailable); | |
| 523 available = isAvailable; | |
| 524 | |
| 525 // Close the initialized input mixer | |
| 526 if (!wasInitialized) { | |
| 527 _mixerManager.CloseMicrophone(); | |
| 528 } | |
| 529 | |
| 530 return 0; | |
| 531 } | |
| 532 | |
| 533 int32_t AudioDeviceLinuxPulse::SetMicrophoneBoost(bool enable) { | |
| 534 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 535 return (_mixerManager.SetMicrophoneBoost(enable)); | |
| 536 } | |
| 537 | |
| 538 int32_t AudioDeviceLinuxPulse::MicrophoneBoost(bool& enabled) const { | |
| 539 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 540 bool onOff(0); | |
| 541 | |
| 542 if (_mixerManager.MicrophoneBoost(onOff) == -1) { | |
| 543 return -1; | |
| 544 } | |
| 545 | |
| 546 enabled = onOff; | |
| 547 | |
| 548 return 0; | |
| 549 } | |
| 550 | |
| 551 int32_t AudioDeviceLinuxPulse::StereoRecordingIsAvailable(bool& available) { | 490 int32_t AudioDeviceLinuxPulse::StereoRecordingIsAvailable(bool& available) { |
| 552 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 491 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 553 if (_recChannels == 2 && _recording) { | 492 if (_recChannels == 2 && _recording) { |
| 554 available = true; | 493 available = true; |
| 555 return 0; | 494 return 0; |
| 556 } | 495 } |
| 557 | 496 |
| 558 available = false; | 497 available = false; |
| 559 bool wasInitialized = _mixerManager.MicrophoneIsInitialized(); | 498 bool wasInitialized = _mixerManager.MicrophoneIsInitialized(); |
| 560 int error = 0; | 499 int error = 0; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 | 659 |
| 721 if (_mixerManager.MinMicrophoneVolume(minVol) == -1) { | 660 if (_mixerManager.MinMicrophoneVolume(minVol) == -1) { |
| 722 return -1; | 661 return -1; |
| 723 } | 662 } |
| 724 | 663 |
| 725 minVolume = minVol; | 664 minVolume = minVol; |
| 726 | 665 |
| 727 return 0; | 666 return 0; |
| 728 } | 667 } |
| 729 | 668 |
| 730 int32_t AudioDeviceLinuxPulse::MicrophoneVolumeStepSize( | |
| 731 uint16_t& stepSize) const { | |
| 732 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 733 uint16_t delta(0); | |
| 734 | |
| 735 if (_mixerManager.MicrophoneVolumeStepSize(delta) == -1) { | |
| 736 return -1; | |
| 737 } | |
| 738 | |
| 739 stepSize = delta; | |
| 740 | |
| 741 return 0; | |
| 742 } | |
| 743 | |
| 744 int16_t AudioDeviceLinuxPulse::PlayoutDevices() { | 669 int16_t AudioDeviceLinuxPulse::PlayoutDevices() { |
| 745 PaLock(); | 670 PaLock(); |
| 746 | 671 |
| 747 pa_operation* paOperation = NULL; | 672 pa_operation* paOperation = NULL; |
| 748 _numPlayDevices = 1; // init to 1 to account for "default" | 673 _numPlayDevices = 1; // init to 1 to account for "default" |
| 749 | 674 |
| 750 // get the whole list of devices and update _numPlayDevices | 675 // get the whole list of devices and update _numPlayDevices |
| 751 paOperation = | 676 paOperation = |
| 752 LATE(pa_context_get_sink_info_list)(_paContext, PaSinkInfoCallback, this); | 677 LATE(pa_context_get_sink_info_list)(_paContext, PaSinkInfoCallback, this); |
| 753 | 678 |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1360 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 1285 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 1361 delayMS = (uint16_t)_sndCardRecDelay; | 1286 delayMS = (uint16_t)_sndCardRecDelay; |
| 1362 return 0; | 1287 return 0; |
| 1363 } | 1288 } |
| 1364 | 1289 |
| 1365 bool AudioDeviceLinuxPulse::Playing() const { | 1290 bool AudioDeviceLinuxPulse::Playing() const { |
| 1366 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 1291 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 1367 return (_playing); | 1292 return (_playing); |
| 1368 } | 1293 } |
| 1369 | 1294 |
| 1370 int32_t AudioDeviceLinuxPulse::SetPlayoutBuffer( | |
| 1371 const AudioDeviceModule::BufferType type, | |
| 1372 uint16_t sizeMS) { | |
| 1373 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 1374 if (type != AudioDeviceModule::kFixedBufferSize) { | |
| 1375 LOG(LS_ERROR) << "Adaptive buffer size not supported on this platform"; | |
| 1376 return -1; | |
| 1377 } | |
| 1378 | |
| 1379 _playBufType = type; | |
| 1380 _playBufDelayFixed = sizeMS; | |
| 1381 | |
| 1382 return 0; | |
| 1383 } | |
| 1384 | |
| 1385 int32_t AudioDeviceLinuxPulse::PlayoutBuffer( | |
| 1386 AudioDeviceModule::BufferType& type, | |
| 1387 uint16_t& sizeMS) const { | |
| 1388 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 1389 type = _playBufType; | |
| 1390 sizeMS = _playBufDelayFixed; | |
| 1391 | |
| 1392 return 0; | |
| 1393 } | |
| 1394 | |
| 1395 int32_t AudioDeviceLinuxPulse::CPULoad(uint16_t& /*load*/) const { | |
| 1396 LOG(LS_WARNING) << "API call not supported on this platform"; | |
| 1397 return -1; | |
| 1398 } | |
| 1399 | |
| 1400 bool AudioDeviceLinuxPulse::PlayoutWarning() const { | 1295 bool AudioDeviceLinuxPulse::PlayoutWarning() const { |
| 1401 rtc::CritScope lock(&_critSect); | 1296 rtc::CritScope lock(&_critSect); |
| 1402 return (_playWarning > 0); | 1297 return (_playWarning > 0); |
| 1403 } | 1298 } |
| 1404 | 1299 |
| 1405 bool AudioDeviceLinuxPulse::PlayoutError() const { | 1300 bool AudioDeviceLinuxPulse::PlayoutError() const { |
| 1406 rtc::CritScope lock(&_critSect); | 1301 rtc::CritScope lock(&_critSect); |
| 1407 return (_playError > 0); | 1302 return (_playError > 0); |
| 1408 } | 1303 } |
| 1409 | 1304 |
| (...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2503 | 2398 |
| 2504 // A bit change in keymap means a key is pressed | 2399 // A bit change in keymap means a key is pressed |
| 2505 for (i = 0; i < sizeof(szKey); i++) | 2400 for (i = 0; i < sizeof(szKey); i++) |
| 2506 state |= (szKey[i] ^ _oldKeyState[i]) & szKey[i]; | 2401 state |= (szKey[i] ^ _oldKeyState[i]) & szKey[i]; |
| 2507 | 2402 |
| 2508 // Save old state | 2403 // Save old state |
| 2509 memcpy((char*)_oldKeyState, (char*)szKey, sizeof(_oldKeyState)); | 2404 memcpy((char*)_oldKeyState, (char*)szKey, sizeof(_oldKeyState)); |
| 2510 return (state != 0); | 2405 return (state != 0); |
| 2511 } | 2406 } |
| 2512 } // namespace webrtc | 2407 } // namespace webrtc |
| OLD | NEW |