From b28d0698a282518dd52ee290660e0e2b467501cc Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Thu, 26 Sep 2024 11:16:31 +0000 Subject: [PATCH] Remove VLA from audio device code. Those trigger new warnings when importing the Chromium roll. Follow-up to https://webrtc-review.googlesource.com/c/src/+/363740. Bug: None Change-Id: If32d8981bc0f73d697848fb27a8fd80384a7837e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/363861 Reviewed-by: Harald Alvestrand Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#43085} --- modules/audio_device/mac/audio_device_mac.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/audio_device/mac/audio_device_mac.cc b/modules/audio_device/mac/audio_device_mac.cc index ed7b0e4669..f64d4313c6 100644 --- a/modules/audio_device/mac/audio_device_mac.cc +++ b/modules/audio_device/mac/audio_device_mac.cc @@ -15,6 +15,7 @@ #include // sysctlbyname() #include +#include #include "modules/audio_device/audio_device_config.h" #include "modules/third_party/portaudio/pa_ringbuffer.h" @@ -2428,7 +2429,7 @@ bool AudioDeviceMac::CaptureWorkerThread() { OSStatus err = noErr; UInt32 noRecSamples = ENGINE_REC_BUF_SIZE_IN_SAMPLES * _inDesiredFormat.mChannelsPerFrame; - SInt16 recordBuffer[noRecSamples]; + std::vector recordBuffer(noRecSamples); UInt32 size = ENGINE_REC_BUF_SIZE_IN_SAMPLES; AudioBufferList engineBuffer; @@ -2436,7 +2437,7 @@ bool AudioDeviceMac::CaptureWorkerThread() { engineBuffer.mBuffers->mNumberChannels = _inDesiredFormat.mChannelsPerFrame; engineBuffer.mBuffers->mDataByteSize = _inDesiredFormat.mBytesPerPacket * noRecSamples; - engineBuffer.mBuffers->mData = recordBuffer; + engineBuffer.mBuffers->mData = recordBuffer.data(); err = AudioConverterFillComplexBuffer(_captureConverter, inConverterProc, this, &size, &engineBuffer, NULL); @@ -2471,7 +2472,8 @@ bool AudioDeviceMac::CaptureWorkerThread() { // store the recorded buffer (no action will be taken if the // #recorded samples is not a full buffer) - _ptrAudioBuffer->SetRecordedBuffer((int8_t*)&recordBuffer, (uint32_t)size); + _ptrAudioBuffer->SetRecordedBuffer((int8_t*)recordBuffer.data(), + (uint32_t)size); _ptrAudioBuffer->SetVQEData(msecOnPlaySide, msecOnRecordSide); _ptrAudioBuffer->SetTypingStatus(KeyPressed());