summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2016-10-20 09:18:19 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2016-10-21 09:28:01 +0000
commit0cb4dc5c1fded81b4f47945b51b8de0b0151bf67 (patch)
tree85f6dd02f7159c2a4de9a18797c0a97b3746848b
parentc7433f84288a33d6a5ea411dabf1618afcacfaf1 (diff)
Alsa: Use QVarLengthArrayv5.8.0-beta1
Fix g++ / Clang warnings: alsaaudioinput.cpp: In member function 'qint64 QAlsaAudioInput::read(char*, qint64)': qalsaaudioinput.cpp:530:36: warning: variable length array 'buffer' is used [-Wvla] qalsaaudiooutput.cpp: In member function 'qint64 QAlsaAudioOutput::write(const char*, qint64)': qalsaaudiooutput.cpp:570:23: warning: variable length array 'out' is used [-Wvla] (variable length arrays being C99 features). Change-Id: Id5024af7a42dffb56fbbeda59e1fadb41c660e41 Reviewed-by: Christian Stromme <christian.stromme@qt.io> Reviewed-by: Yoann Lopes <yoann.lopes@qt.io>
-rw-r--r--src/plugins/alsa/qalsaaudioinput.cpp11
-rw-r--r--src/plugins/alsa/qalsaaudiooutput.cpp7
2 files changed, 11 insertions, 7 deletions
diff --git a/src/plugins/alsa/qalsaaudioinput.cpp b/src/plugins/alsa/qalsaaudioinput.cpp
index 8109e693..5a4111a9 100644
--- a/src/plugins/alsa/qalsaaudioinput.cpp
+++ b/src/plugins/alsa/qalsaaudioinput.cpp
@@ -49,6 +49,7 @@
//
#include <QtCore/qcoreapplication.h>
+#include <QtCore/qvarlengtharray.h>
#include <QtMultimedia/private/qaudiohelpers_p.h>
#include "qalsaaudioinput.h"
#include "qalsaaudiodeviceinfo.h"
@@ -526,20 +527,22 @@ qint64 QAlsaAudioInput::read(char* data, qint64 len)
int count=0;
int err = 0;
+ QVarLengthArray<char, 4096> buffer(bytesToRead);
while(count < 5 && bytesToRead > 0) {
- char buffer[bytesToRead];
int chunks = bytesToRead / period_size;
int frames = chunks * period_frames;
if (frames > (int)buffer_frames)
frames = buffer_frames;
- int readFrames = snd_pcm_readi(handle, buffer, frames);
+ int readFrames = snd_pcm_readi(handle, buffer.data(), frames);
bytesRead = snd_pcm_frames_to_bytes(handle, readFrames);
if (m_volume < 1.0f)
- QAudioHelperInternal::qMultiplySamples(m_volume, settings, buffer, buffer, bytesRead);
+ QAudioHelperInternal::qMultiplySamples(m_volume, settings,
+ buffer.constData(),
+ buffer.data(), bytesRead);
if (readFrames >= 0) {
- ringBuffer.write(buffer, bytesRead);
+ ringBuffer.write(buffer.data(), bytesRead);
#ifdef DEBUG_AUDIO
qDebug() << QString::fromLatin1("read in bytes = %1 (frames=%2)").arg(bytesRead).arg(readFrames).toLatin1().constData();
#endif
diff --git a/src/plugins/alsa/qalsaaudiooutput.cpp b/src/plugins/alsa/qalsaaudiooutput.cpp
index 5e444a0a..cd97ae85 100644
--- a/src/plugins/alsa/qalsaaudiooutput.cpp
+++ b/src/plugins/alsa/qalsaaudiooutput.cpp
@@ -49,6 +49,7 @@
//
#include <QtCore/qcoreapplication.h>
+#include <QtCore/qvarlengtharray.h>
#include <QtMultimedia/private/qaudiohelpers_p.h>
#include "qalsaaudiooutput.h"
#include "qalsaaudiodeviceinfo.h"
@@ -567,9 +568,9 @@ qint64 QAlsaAudioOutput::write( const char *data, qint64 len )
frames = snd_pcm_bytes_to_frames(handle, space);
if (m_volume < 1.0f) {
- char out[space];
- QAudioHelperInternal::qMultiplySamples(m_volume, settings, data, out, space);
- err = snd_pcm_writei(handle, out, frames);
+ QVarLengthArray<char, 4096> out(space);
+ QAudioHelperInternal::qMultiplySamples(m_volume, settings, data, out.data(), space);
+ err = snd_pcm_writei(handle, out.constData(), frames);
} else {
err = snd_pcm_writei(handle, data, frames);
}