| 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 LOG(LS_WARNING) << "output device index has not been set"; | 337 LOG(LS_WARNING) << "output device index has not been set"; |
| 338 return -1; | 338 return -1; |
| 339 } | 339 } |
| 340 | 340 |
| 341 minVolume = static_cast<uint32_t> (PA_VOLUME_MUTED); | 341 minVolume = static_cast<uint32_t> (PA_VOLUME_MUTED); |
| 342 | 342 |
| 343 return 0; | 343 return 0; |
| 344 } | 344 } |
| 345 | 345 |
| 346 int32_t | 346 int32_t |
| 347 AudioMixerManagerLinuxPulse::SpeakerVolumeStepSize(uint16_t& stepSize) const | |
| 348 { | |
| 349 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 350 if (_paOutputDeviceIndex == -1) | |
| 351 { | |
| 352 LOG(LS_WARNING) << "output device index has not been set"; | |
| 353 return -1; | |
| 354 } | |
| 355 | |
| 356 // The sink input (stream) will always have step size = 1 | |
| 357 // There are PA_VOLUME_NORM+1 steps | |
| 358 stepSize = 1; | |
| 359 | |
| 360 LOG(LS_VERBOSE) | |
| 361 << "AudioMixerManagerLinuxPulse::SpeakerVolumeStepSize() => size=" | |
| 362 << stepSize; | |
| 363 | |
| 364 return 0; | |
| 365 } | |
| 366 | |
| 367 int32_t | |
| 368 AudioMixerManagerLinuxPulse::SpeakerVolumeIsAvailable(bool& available) | 347 AudioMixerManagerLinuxPulse::SpeakerVolumeIsAvailable(bool& available) |
| 369 { | 348 { |
| 370 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 349 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 371 if (_paOutputDeviceIndex == -1) | 350 if (_paOutputDeviceIndex == -1) |
| 372 { | 351 { |
| 373 LOG(LS_WARNING) << "output device index has not been set"; | 352 LOG(LS_WARNING) << "output device index has not been set"; |
| 374 return -1; | 353 return -1; |
| 375 } | 354 } |
| 376 | 355 |
| 377 // Always available in Pulse Audio | 356 // Always available in Pulse Audio |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 | 625 |
| 647 enabled = static_cast<bool> (_paMute); | 626 enabled = static_cast<bool> (_paMute); |
| 648 | 627 |
| 649 LOG(LS_VERBOSE) | 628 LOG(LS_VERBOSE) |
| 650 << "AudioMixerManagerLinuxPulse::MicrophoneMute() => enabled=" | 629 << "AudioMixerManagerLinuxPulse::MicrophoneMute() => enabled=" |
| 651 << enabled; | 630 << enabled; |
| 652 | 631 |
| 653 return 0; | 632 return 0; |
| 654 } | 633 } |
| 655 | 634 |
| 656 int32_t | |
| 657 AudioMixerManagerLinuxPulse::MicrophoneBoostIsAvailable(bool& available) | |
| 658 { | |
| 659 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 660 if (_paInputDeviceIndex == -1) | |
| 661 { | |
| 662 LOG(LS_WARNING) << "input device index has not been set"; | |
| 663 return -1; | |
| 664 } | |
| 665 | |
| 666 // Always unavailable in Pulse Audio | |
| 667 // Could make it possible to use PA_VOLUME_MAX | |
| 668 // but that gives bad audio with some sound cards | |
| 669 available = false; | |
| 670 | |
| 671 return 0; | |
| 672 } | |
| 673 | |
| 674 int32_t AudioMixerManagerLinuxPulse::SetMicrophoneBoost(bool enable) | |
| 675 { | |
| 676 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 677 LOG(LS_VERBOSE) << "AudioMixerManagerLinuxPulse::SetMicrophoneBoost(enable=" | |
| 678 << enable << ")"; | |
| 679 | |
| 680 if (_paInputDeviceIndex == -1) | |
| 681 { | |
| 682 LOG(LS_WARNING) << "input device index has not been set"; | |
| 683 return -1; | |
| 684 } | |
| 685 | |
| 686 // Ensure the selected microphone destination has a valid boost control | |
| 687 bool available(false); | |
| 688 MicrophoneBoostIsAvailable(available); | |
| 689 if (!available) | |
| 690 { | |
| 691 LOG(LS_WARNING) << "it is not possible to enable microphone boost"; | |
| 692 return -1; | |
| 693 } | |
| 694 | |
| 695 // It is assumed that the call above fails! | |
| 696 | |
| 697 return 0; | |
| 698 } | |
| 699 | |
| 700 int32_t AudioMixerManagerLinuxPulse::MicrophoneBoost(bool& enabled) const | |
| 701 { | |
| 702 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 703 if (_paInputDeviceIndex == -1) | |
| 704 { | |
| 705 LOG(LS_WARNING) << "input device index has not been set"; | |
| 706 return -1; | |
| 707 } | |
| 708 | |
| 709 // Microphone boost cannot be enabled on this platform! | |
| 710 enabled = false; | |
| 711 | |
| 712 return 0; | |
| 713 } | |
| 714 | |
| 715 int32_t AudioMixerManagerLinuxPulse::MicrophoneVolumeIsAvailable( | 635 int32_t AudioMixerManagerLinuxPulse::MicrophoneVolumeIsAvailable( |
| 716 bool& available) | 636 bool& available) |
| 717 { | 637 { |
| 718 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 638 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 719 if (_paInputDeviceIndex == -1) | 639 if (_paInputDeviceIndex == -1) |
| 720 { | 640 { |
| 721 LOG(LS_WARNING) << "input device index has not been set"; | 641 LOG(LS_WARNING) << "input device index has not been set"; |
| 722 return -1; | 642 return -1; |
| 723 } | 643 } |
| 724 | 644 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 { | 788 { |
| 869 LOG(LS_WARNING) << "input device index has not been set"; | 789 LOG(LS_WARNING) << "input device index has not been set"; |
| 870 return -1; | 790 return -1; |
| 871 } | 791 } |
| 872 | 792 |
| 873 minVolume = static_cast<uint32_t> (PA_VOLUME_MUTED); | 793 minVolume = static_cast<uint32_t> (PA_VOLUME_MUTED); |
| 874 | 794 |
| 875 return 0; | 795 return 0; |
| 876 } | 796 } |
| 877 | 797 |
| 878 int32_t AudioMixerManagerLinuxPulse::MicrophoneVolumeStepSize( | |
| 879 uint16_t& stepSize) const | |
| 880 { | |
| 881 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 882 if (_paInputDeviceIndex == -1) | |
| 883 { | |
| 884 LOG(LS_WARNING) << "input device index has not been set"; | |
| 885 return -1; | |
| 886 } | |
| 887 | |
| 888 uint32_t deviceIndex = (uint32_t) _paInputDeviceIndex; | |
| 889 | |
| 890 AutoPulseLock auto_lock(_paMainloop); | |
| 891 | |
| 892 // Get the actual stream device index if we have a connected stream | |
| 893 // The device used by the stream can be changed | |
| 894 // during the call | |
| 895 if (_paRecStream && (LATE(pa_stream_get_state)(_paRecStream) | |
| 896 != PA_STREAM_UNCONNECTED)) | |
| 897 { | |
| 898 deviceIndex = LATE(pa_stream_get_device_index)(_paRecStream); | |
| 899 } | |
| 900 | |
| 901 pa_operation* paOperation = NULL; | |
| 902 | |
| 903 // Get info for this source | |
| 904 paOperation | |
| 905 = LATE(pa_context_get_source_info_by_index)(_paContext, deviceIndex, | |
| 906 PaSourceInfoCallback, | |
| 907 (void*) this); | |
| 908 | |
| 909 WaitForOperationCompletion(paOperation); | |
| 910 | |
| 911 stepSize = static_cast<uint16_t> ((PA_VOLUME_NORM + 1) / _paVolSteps); | |
| 912 | |
| 913 LOG(LS_VERBOSE) | |
| 914 << "AudioMixerManagerLinuxPulse::MicrophoneVolumeStepSize() => size=" | |
| 915 << stepSize; | |
| 916 | |
| 917 return 0; | |
| 918 } | |
| 919 | |
| 920 // =========================================================================== | 798 // =========================================================================== |
| 921 // Private Methods | 799 // Private Methods |
| 922 // =========================================================================== | 800 // =========================================================================== |
| 923 | 801 |
| 924 void | 802 void |
| 925 AudioMixerManagerLinuxPulse::PaSinkInfoCallback(pa_context */*c*/, | 803 AudioMixerManagerLinuxPulse::PaSinkInfoCallback(pa_context */*c*/, |
| 926 const pa_sink_info *i, | 804 const pa_sink_info *i, |
| 927 int eol, | 805 int eol, |
| 928 void *pThis) | 806 void *pThis) |
| 929 { | 807 { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 | 968 |
| 1091 AutoPulseLock auto_lock(_paMainloop); | 969 AutoPulseLock auto_lock(_paMainloop); |
| 1092 paOperation = LATE(pa_context_get_source_info_by_index)( | 970 paOperation = LATE(pa_context_get_source_info_by_index)( |
| 1093 _paContext, device_index, PaSourceInfoCallback, (void*) this); | 971 _paContext, device_index, PaSourceInfoCallback, (void*) this); |
| 1094 | 972 |
| 1095 WaitForOperationCompletion(paOperation); | 973 WaitForOperationCompletion(paOperation); |
| 1096 return true; | 974 return true; |
| 1097 } | 975 } |
| 1098 | 976 |
| 1099 } | 977 } |
| OLD | NEW |