| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 // CoreAudio errors are best interpreted as four character strings. | 88 // CoreAudio errors are best interpreted as four character strings. |
| 89 void AudioDeviceMac::logCAMsg(const TraceLevel level, | 89 void AudioDeviceMac::logCAMsg(const TraceLevel level, |
| 90 const TraceModule module, | 90 const TraceModule module, |
| 91 const int32_t id, const char *msg, | 91 const int32_t id, const char *msg, |
| 92 const char *err) | 92 const char *err) |
| 93 { | 93 { |
| 94 DCHECK(msg != NULL); | 94 RTC_DCHECK(msg != NULL); |
| 95 DCHECK(err != NULL); | 95 RTC_DCHECK(err != NULL); |
| 96 | 96 |
| 97 #ifdef WEBRTC_ARCH_BIG_ENDIAN | 97 #ifdef WEBRTC_ARCH_BIG_ENDIAN |
| 98 WEBRTC_TRACE(level, module, id, "%s: %.4s", msg, err); | 98 WEBRTC_TRACE(level, module, id, "%s: %.4s", msg, err); |
| 99 #else | 99 #else |
| 100 // We need to flip the characters in this case. | 100 // We need to flip the characters in this case. |
| 101 WEBRTC_TRACE(level, module, id, "%s: %.1s%.1s%.1s%.1s", msg, err + 3, err | 101 WEBRTC_TRACE(level, module, id, "%s: %.1s%.1s%.1s%.1s", msg, err + 3, err |
| 102 + 2, err + 1, err); | 102 + 2, err + 1, err); |
| 103 #endif | 103 #endif |
| 104 } | 104 } |
| 105 | 105 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 _recError(0), | 147 _recError(0), |
| 148 _paCaptureBuffer(NULL), | 148 _paCaptureBuffer(NULL), |
| 149 _paRenderBuffer(NULL), | 149 _paRenderBuffer(NULL), |
| 150 _captureBufSizeSamples(0), | 150 _captureBufSizeSamples(0), |
| 151 _renderBufSizeSamples(0), | 151 _renderBufSizeSamples(0), |
| 152 prev_key_state_() | 152 prev_key_state_() |
| 153 { | 153 { |
| 154 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id, | 154 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id, |
| 155 "%s created", __FUNCTION__); | 155 "%s created", __FUNCTION__); |
| 156 | 156 |
| 157 DCHECK(&_stopEvent != NULL); | 157 RTC_DCHECK(&_stopEvent != NULL); |
| 158 DCHECK(&_stopEventRec != NULL); | 158 RTC_DCHECK(&_stopEventRec != NULL); |
| 159 | 159 |
| 160 memset(_renderConvertData, 0, sizeof(_renderConvertData)); | 160 memset(_renderConvertData, 0, sizeof(_renderConvertData)); |
| 161 memset(&_outStreamFormat, 0, sizeof(AudioStreamBasicDescription)); | 161 memset(&_outStreamFormat, 0, sizeof(AudioStreamBasicDescription)); |
| 162 memset(&_outDesiredFormat, 0, sizeof(AudioStreamBasicDescription)); | 162 memset(&_outDesiredFormat, 0, sizeof(AudioStreamBasicDescription)); |
| 163 memset(&_inStreamFormat, 0, sizeof(AudioStreamBasicDescription)); | 163 memset(&_inStreamFormat, 0, sizeof(AudioStreamBasicDescription)); |
| 164 memset(&_inDesiredFormat, 0, sizeof(AudioStreamBasicDescription)); | 164 memset(&_inDesiredFormat, 0, sizeof(AudioStreamBasicDescription)); |
| 165 } | 165 } |
| 166 | 166 |
| 167 | 167 |
| 168 AudioDeviceMac::~AudioDeviceMac() | 168 AudioDeviceMac::~AudioDeviceMac() |
| 169 { | 169 { |
| 170 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, | 170 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, |
| 171 "%s destroyed", __FUNCTION__); | 171 "%s destroyed", __FUNCTION__); |
| 172 | 172 |
| 173 if (!_isShutDown) | 173 if (!_isShutDown) |
| 174 { | 174 { |
| 175 Terminate(); | 175 Terminate(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 DCHECK(!capture_worker_thread_.get()); | 178 RTC_DCHECK(!capture_worker_thread_.get()); |
| 179 DCHECK(!render_worker_thread_.get()); | 179 RTC_DCHECK(!render_worker_thread_.get()); |
| 180 | 180 |
| 181 if (_paRenderBuffer) | 181 if (_paRenderBuffer) |
| 182 { | 182 { |
| 183 delete _paRenderBuffer; | 183 delete _paRenderBuffer; |
| 184 _paRenderBuffer = NULL; | 184 _paRenderBuffer = NULL; |
| 185 } | 185 } |
| 186 | 186 |
| 187 if (_paCaptureBuffer) | 187 if (_paCaptureBuffer) |
| 188 { | 188 { |
| 189 delete _paCaptureBuffer; | 189 delete _paCaptureBuffer; |
| (...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1657 return 0; | 1657 return 0; |
| 1658 } | 1658 } |
| 1659 | 1659 |
| 1660 if (!_initialized) | 1660 if (!_initialized) |
| 1661 { | 1661 { |
| 1662 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 1662 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
| 1663 " Recording worker thread has not been started"); | 1663 " Recording worker thread has not been started"); |
| 1664 return -1; | 1664 return -1; |
| 1665 } | 1665 } |
| 1666 | 1666 |
| 1667 DCHECK(!capture_worker_thread_.get()); | 1667 RTC_DCHECK(!capture_worker_thread_.get()); |
| 1668 capture_worker_thread_ = | 1668 capture_worker_thread_ = |
| 1669 ThreadWrapper::CreateThread(RunCapture, this, "CaptureWorkerThread"); | 1669 ThreadWrapper::CreateThread(RunCapture, this, "CaptureWorkerThread"); |
| 1670 DCHECK(capture_worker_thread_.get()); | 1670 RTC_DCHECK(capture_worker_thread_.get()); |
| 1671 capture_worker_thread_->Start(); | 1671 capture_worker_thread_->Start(); |
| 1672 capture_worker_thread_->SetPriority(kRealtimePriority); | 1672 capture_worker_thread_->SetPriority(kRealtimePriority); |
| 1673 | 1673 |
| 1674 OSStatus err = noErr; | 1674 OSStatus err = noErr; |
| 1675 if (_twoDevices) | 1675 if (_twoDevices) |
| 1676 { | 1676 { |
| 1677 WEBRTC_CA_RETURN_ON_ERR(AudioDeviceStart(_inputDeviceID, _inDeviceIOProc
ID)); | 1677 WEBRTC_CA_RETURN_ON_ERR(AudioDeviceStart(_inputDeviceID, _inDeviceIOProc
ID)); |
| 1678 } else if (!_playing) | 1678 } else if (!_playing) |
| 1679 { | 1679 { |
| 1680 WEBRTC_CA_RETURN_ON_ERR(AudioDeviceStart(_inputDeviceID, _deviceIOProcID
)); | 1680 WEBRTC_CA_RETURN_ON_ERR(AudioDeviceStart(_inputDeviceID, _deviceIOProcID
)); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1812 if (!_playIsInitialized) | 1812 if (!_playIsInitialized) |
| 1813 { | 1813 { |
| 1814 return -1; | 1814 return -1; |
| 1815 } | 1815 } |
| 1816 | 1816 |
| 1817 if (_playing) | 1817 if (_playing) |
| 1818 { | 1818 { |
| 1819 return 0; | 1819 return 0; |
| 1820 } | 1820 } |
| 1821 | 1821 |
| 1822 DCHECK(!render_worker_thread_.get()); | 1822 RTC_DCHECK(!render_worker_thread_.get()); |
| 1823 render_worker_thread_ = | 1823 render_worker_thread_ = |
| 1824 ThreadWrapper::CreateThread(RunRender, this, "RenderWorkerThread"); | 1824 ThreadWrapper::CreateThread(RunRender, this, "RenderWorkerThread"); |
| 1825 render_worker_thread_->Start(); | 1825 render_worker_thread_->Start(); |
| 1826 render_worker_thread_->SetPriority(kRealtimePriority); | 1826 render_worker_thread_->SetPriority(kRealtimePriority); |
| 1827 | 1827 |
| 1828 if (_twoDevices || !_recording) | 1828 if (_twoDevices || !_recording) |
| 1829 { | 1829 { |
| 1830 OSStatus err = noErr; | 1830 OSStatus err = noErr; |
| 1831 WEBRTC_CA_RETURN_ON_ERR(AudioDeviceStart(_outputDeviceID, _deviceIOProcI
D)); | 1831 WEBRTC_CA_RETURN_ON_ERR(AudioDeviceStart(_outputDeviceID, _deviceIOProcI
D)); |
| 1832 } | 1832 } |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2459 return 0; | 2459 return 0; |
| 2460 } | 2460 } |
| 2461 | 2461 |
| 2462 OSStatus AudioDeviceMac::objectListenerProc( | 2462 OSStatus AudioDeviceMac::objectListenerProc( |
| 2463 AudioObjectID objectId, | 2463 AudioObjectID objectId, |
| 2464 UInt32 numberAddresses, | 2464 UInt32 numberAddresses, |
| 2465 const AudioObjectPropertyAddress addresses[], | 2465 const AudioObjectPropertyAddress addresses[], |
| 2466 void* clientData) | 2466 void* clientData) |
| 2467 { | 2467 { |
| 2468 AudioDeviceMac *ptrThis = (AudioDeviceMac *) clientData; | 2468 AudioDeviceMac *ptrThis = (AudioDeviceMac *) clientData; |
| 2469 DCHECK(ptrThis != NULL); | 2469 RTC_DCHECK(ptrThis != NULL); |
| 2470 | 2470 |
| 2471 ptrThis->implObjectListenerProc(objectId, numberAddresses, addresses); | 2471 ptrThis->implObjectListenerProc(objectId, numberAddresses, addresses); |
| 2472 | 2472 |
| 2473 // AudioObjectPropertyListenerProc functions are supposed to return 0 | 2473 // AudioObjectPropertyListenerProc functions are supposed to return 0 |
| 2474 return 0; | 2474 return 0; |
| 2475 } | 2475 } |
| 2476 | 2476 |
| 2477 OSStatus AudioDeviceMac::implObjectListenerProc( | 2477 OSStatus AudioDeviceMac::implObjectListenerProc( |
| 2478 const AudioObjectID objectId, | 2478 const AudioObjectID objectId, |
| 2479 const UInt32 numberAddresses, | 2479 const UInt32 numberAddresses, |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2745 // ============================================================================ | 2745 // ============================================================================ |
| 2746 | 2746 |
| 2747 OSStatus AudioDeviceMac::deviceIOProc(AudioDeviceID, const AudioTimeStamp*, | 2747 OSStatus AudioDeviceMac::deviceIOProc(AudioDeviceID, const AudioTimeStamp*, |
| 2748 const AudioBufferList* inputData, | 2748 const AudioBufferList* inputData, |
| 2749 const AudioTimeStamp* inputTime, | 2749 const AudioTimeStamp* inputTime, |
| 2750 AudioBufferList* outputData, | 2750 AudioBufferList* outputData, |
| 2751 const AudioTimeStamp* outputTime, | 2751 const AudioTimeStamp* outputTime, |
| 2752 void *clientData) | 2752 void *clientData) |
| 2753 { | 2753 { |
| 2754 AudioDeviceMac *ptrThis = (AudioDeviceMac *) clientData; | 2754 AudioDeviceMac *ptrThis = (AudioDeviceMac *) clientData; |
| 2755 DCHECK(ptrThis != NULL); | 2755 RTC_DCHECK(ptrThis != NULL); |
| 2756 | 2756 |
| 2757 ptrThis->implDeviceIOProc(inputData, inputTime, outputData, outputTime); | 2757 ptrThis->implDeviceIOProc(inputData, inputTime, outputData, outputTime); |
| 2758 | 2758 |
| 2759 // AudioDeviceIOProc functions are supposed to return 0 | 2759 // AudioDeviceIOProc functions are supposed to return 0 |
| 2760 return 0; | 2760 return 0; |
| 2761 } | 2761 } |
| 2762 | 2762 |
| 2763 OSStatus AudioDeviceMac::outConverterProc(AudioConverterRef, | 2763 OSStatus AudioDeviceMac::outConverterProc(AudioConverterRef, |
| 2764 UInt32 *numberDataPackets, | 2764 UInt32 *numberDataPackets, |
| 2765 AudioBufferList *data, | 2765 AudioBufferList *data, |
| 2766 AudioStreamPacketDescription **, | 2766 AudioStreamPacketDescription **, |
| 2767 void *userData) | 2767 void *userData) |
| 2768 { | 2768 { |
| 2769 AudioDeviceMac *ptrThis = (AudioDeviceMac *) userData; | 2769 AudioDeviceMac *ptrThis = (AudioDeviceMac *) userData; |
| 2770 DCHECK(ptrThis != NULL); | 2770 RTC_DCHECK(ptrThis != NULL); |
| 2771 | 2771 |
| 2772 return ptrThis->implOutConverterProc(numberDataPackets, data); | 2772 return ptrThis->implOutConverterProc(numberDataPackets, data); |
| 2773 } | 2773 } |
| 2774 | 2774 |
| 2775 OSStatus AudioDeviceMac::inDeviceIOProc(AudioDeviceID, const AudioTimeStamp*, | 2775 OSStatus AudioDeviceMac::inDeviceIOProc(AudioDeviceID, const AudioTimeStamp*, |
| 2776 const AudioBufferList* inputData, | 2776 const AudioBufferList* inputData, |
| 2777 const AudioTimeStamp* inputTime, | 2777 const AudioTimeStamp* inputTime, |
| 2778 AudioBufferList*, | 2778 AudioBufferList*, |
| 2779 const AudioTimeStamp*, void* clientData) | 2779 const AudioTimeStamp*, void* clientData) |
| 2780 { | 2780 { |
| 2781 AudioDeviceMac *ptrThis = (AudioDeviceMac *) clientData; | 2781 AudioDeviceMac *ptrThis = (AudioDeviceMac *) clientData; |
| 2782 DCHECK(ptrThis != NULL); | 2782 RTC_DCHECK(ptrThis != NULL); |
| 2783 | 2783 |
| 2784 ptrThis->implInDeviceIOProc(inputData, inputTime); | 2784 ptrThis->implInDeviceIOProc(inputData, inputTime); |
| 2785 | 2785 |
| 2786 // AudioDeviceIOProc functions are supposed to return 0 | 2786 // AudioDeviceIOProc functions are supposed to return 0 |
| 2787 return 0; | 2787 return 0; |
| 2788 } | 2788 } |
| 2789 | 2789 |
| 2790 OSStatus AudioDeviceMac::inConverterProc( | 2790 OSStatus AudioDeviceMac::inConverterProc( |
| 2791 AudioConverterRef, | 2791 AudioConverterRef, |
| 2792 UInt32 *numberDataPackets, | 2792 UInt32 *numberDataPackets, |
| 2793 AudioBufferList *data, | 2793 AudioBufferList *data, |
| 2794 AudioStreamPacketDescription ** /*dataPacketDescription*/, | 2794 AudioStreamPacketDescription ** /*dataPacketDescription*/, |
| 2795 void *userData) | 2795 void *userData) |
| 2796 { | 2796 { |
| 2797 AudioDeviceMac *ptrThis = static_cast<AudioDeviceMac*> (userData); | 2797 AudioDeviceMac *ptrThis = static_cast<AudioDeviceMac*> (userData); |
| 2798 DCHECK(ptrThis != NULL); | 2798 RTC_DCHECK(ptrThis != NULL); |
| 2799 | 2799 |
| 2800 return ptrThis->implInConverterProc(numberDataPackets, data); | 2800 return ptrThis->implInConverterProc(numberDataPackets, data); |
| 2801 } | 2801 } |
| 2802 | 2802 |
| 2803 OSStatus AudioDeviceMac::implDeviceIOProc(const AudioBufferList *inputData, | 2803 OSStatus AudioDeviceMac::implDeviceIOProc(const AudioBufferList *inputData, |
| 2804 const AudioTimeStamp *inputTime, | 2804 const AudioTimeStamp *inputTime, |
| 2805 AudioBufferList *outputData, | 2805 AudioBufferList *outputData, |
| 2806 const AudioTimeStamp *outputTime) | 2806 const AudioTimeStamp *outputTime) |
| 2807 { | 2807 { |
| 2808 OSStatus err = noErr; | 2808 OSStatus err = noErr; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2845 } | 2845 } |
| 2846 | 2846 |
| 2847 if (!_playing) | 2847 if (!_playing) |
| 2848 { | 2848 { |
| 2849 // This can be the case when a shared device is capturing but not | 2849 // This can be the case when a shared device is capturing but not |
| 2850 // rendering. We allow the checks above before returning to avoid a | 2850 // rendering. We allow the checks above before returning to avoid a |
| 2851 // timeout when capturing is stopped. | 2851 // timeout when capturing is stopped. |
| 2852 return 0; | 2852 return 0; |
| 2853 } | 2853 } |
| 2854 | 2854 |
| 2855 DCHECK(_outStreamFormat.mBytesPerFrame != 0); | 2855 RTC_DCHECK(_outStreamFormat.mBytesPerFrame != 0); |
| 2856 UInt32 size = outputData->mBuffers->mDataByteSize | 2856 UInt32 size = outputData->mBuffers->mDataByteSize |
| 2857 / _outStreamFormat.mBytesPerFrame; | 2857 / _outStreamFormat.mBytesPerFrame; |
| 2858 | 2858 |
| 2859 // TODO(xians): signal an error somehow? | 2859 // TODO(xians): signal an error somehow? |
| 2860 err = AudioConverterFillComplexBuffer(_renderConverter, outConverterProc, | 2860 err = AudioConverterFillComplexBuffer(_renderConverter, outConverterProc, |
| 2861 this, &size, outputData, NULL); | 2861 this, &size, outputData, NULL); |
| 2862 if (err != noErr) | 2862 if (err != noErr) |
| 2863 { | 2863 { |
| 2864 if (err == 1) | 2864 if (err == 1) |
| 2865 { | 2865 { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2886 + 0.5); | 2886 + 0.5); |
| 2887 | 2887 |
| 2888 AtomicSet32(&_renderDelayUs, renderDelayUs); | 2888 AtomicSet32(&_renderDelayUs, renderDelayUs); |
| 2889 | 2889 |
| 2890 return 0; | 2890 return 0; |
| 2891 } | 2891 } |
| 2892 | 2892 |
| 2893 OSStatus AudioDeviceMac::implOutConverterProc(UInt32 *numberDataPackets, | 2893 OSStatus AudioDeviceMac::implOutConverterProc(UInt32 *numberDataPackets, |
| 2894 AudioBufferList *data) | 2894 AudioBufferList *data) |
| 2895 { | 2895 { |
| 2896 DCHECK(data->mNumberBuffers == 1); | 2896 RTC_DCHECK(data->mNumberBuffers == 1); |
| 2897 PaRingBufferSize numSamples = *numberDataPackets | 2897 PaRingBufferSize numSamples = *numberDataPackets |
| 2898 * _outDesiredFormat.mChannelsPerFrame; | 2898 * _outDesiredFormat.mChannelsPerFrame; |
| 2899 | 2899 |
| 2900 data->mBuffers->mNumberChannels = _outDesiredFormat.mChannelsPerFrame; | 2900 data->mBuffers->mNumberChannels = _outDesiredFormat.mChannelsPerFrame; |
| 2901 // Always give the converter as much as it wants, zero padding as required. | 2901 // Always give the converter as much as it wants, zero padding as required. |
| 2902 data->mBuffers->mDataByteSize = *numberDataPackets | 2902 data->mBuffers->mDataByteSize = *numberDataPackets |
| 2903 * _outDesiredFormat.mBytesPerPacket; | 2903 * _outDesiredFormat.mBytesPerPacket; |
| 2904 data->mBuffers->mData = _renderConvertData; | 2904 data->mBuffers->mData = _renderConvertData; |
| 2905 memset(_renderConvertData, 0, sizeof(_renderConvertData)); | 2905 memset(_renderConvertData, 0, sizeof(_renderConvertData)); |
| 2906 | 2906 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2960 | 2960 |
| 2961 int32_t captureDelayUs = static_cast<int32_t> (1e-3 * (nowNs - inputTimeNs) | 2961 int32_t captureDelayUs = static_cast<int32_t> (1e-3 * (nowNs - inputTimeNs) |
| 2962 + 0.5); | 2962 + 0.5); |
| 2963 captureDelayUs | 2963 captureDelayUs |
| 2964 += static_cast<int32_t> ((1.0e6 * bufSizeSamples) | 2964 += static_cast<int32_t> ((1.0e6 * bufSizeSamples) |
| 2965 / _inStreamFormat.mChannelsPerFrame / _inStreamFormat.mSampleRate | 2965 / _inStreamFormat.mChannelsPerFrame / _inStreamFormat.mSampleRate |
| 2966 + 0.5); | 2966 + 0.5); |
| 2967 | 2967 |
| 2968 AtomicSet32(&_captureDelayUs, captureDelayUs); | 2968 AtomicSet32(&_captureDelayUs, captureDelayUs); |
| 2969 | 2969 |
| 2970 DCHECK(inputData->mNumberBuffers == 1); | 2970 RTC_DCHECK(inputData->mNumberBuffers == 1); |
| 2971 PaRingBufferSize numSamples = inputData->mBuffers->mDataByteSize | 2971 PaRingBufferSize numSamples = inputData->mBuffers->mDataByteSize |
| 2972 * _inStreamFormat.mChannelsPerFrame / _inStreamFormat.mBytesPerPacket; | 2972 * _inStreamFormat.mChannelsPerFrame / _inStreamFormat.mBytesPerPacket; |
| 2973 PaUtil_WriteRingBuffer(_paCaptureBuffer, inputData->mBuffers->mData, | 2973 PaUtil_WriteRingBuffer(_paCaptureBuffer, inputData->mBuffers->mData, |
| 2974 numSamples); | 2974 numSamples); |
| 2975 | 2975 |
| 2976 kern_return_t kernErr = semaphore_signal_all(_captureSemaphore); | 2976 kern_return_t kernErr = semaphore_signal_all(_captureSemaphore); |
| 2977 if (kernErr != KERN_SUCCESS) | 2977 if (kernErr != KERN_SUCCESS) |
| 2978 { | 2978 { |
| 2979 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 2979 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
| 2980 " semaphore_signal_all() error: %d", kernErr); | 2980 " semaphore_signal_all() error: %d", kernErr); |
| 2981 } | 2981 } |
| 2982 | 2982 |
| 2983 return err; | 2983 return err; |
| 2984 } | 2984 } |
| 2985 | 2985 |
| 2986 OSStatus AudioDeviceMac::implInConverterProc(UInt32 *numberDataPackets, | 2986 OSStatus AudioDeviceMac::implInConverterProc(UInt32 *numberDataPackets, |
| 2987 AudioBufferList *data) | 2987 AudioBufferList *data) |
| 2988 { | 2988 { |
| 2989 DCHECK(data->mNumberBuffers == 1); | 2989 RTC_DCHECK(data->mNumberBuffers == 1); |
| 2990 PaRingBufferSize numSamples = *numberDataPackets | 2990 PaRingBufferSize numSamples = *numberDataPackets |
| 2991 * _inStreamFormat.mChannelsPerFrame; | 2991 * _inStreamFormat.mChannelsPerFrame; |
| 2992 | 2992 |
| 2993 while (PaUtil_GetRingBufferReadAvailable(_paCaptureBuffer) < numSamples) | 2993 while (PaUtil_GetRingBufferReadAvailable(_paCaptureBuffer) < numSamples) |
| 2994 { | 2994 { |
| 2995 mach_timespec_t timeout; | 2995 mach_timespec_t timeout; |
| 2996 timeout.tv_sec = 0; | 2996 timeout.tv_sec = 0; |
| 2997 timeout.tv_nsec = TIMER_PERIOD_MS; | 2997 timeout.tv_nsec = TIMER_PERIOD_MS; |
| 2998 | 2998 |
| 2999 kern_return_t kernErr = semaphore_timedwait(_captureSemaphore, timeout); | 2999 kern_return_t kernErr = semaphore_timedwait(_captureSemaphore, timeout); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3232 kCGEventSourceStateHIDSystemState, | 3232 kCGEventSourceStateHIDSystemState, |
| 3233 key_index); | 3233 key_index); |
| 3234 // A false -> true change in keymap means a key is pressed. | 3234 // A false -> true change in keymap means a key is pressed. |
| 3235 key_down |= (keyState && !prev_key_state_[key_index]); | 3235 key_down |= (keyState && !prev_key_state_[key_index]); |
| 3236 // Save current state. | 3236 // Save current state. |
| 3237 prev_key_state_[key_index] = keyState; | 3237 prev_key_state_[key_index] = keyState; |
| 3238 } | 3238 } |
| 3239 return key_down; | 3239 return key_down; |
| 3240 } | 3240 } |
| 3241 } // namespace webrtc | 3241 } // namespace webrtc |
| OLD | NEW |