Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qaudiobuffer.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qaudiobuffer.h"
5
6#include <QObject>
7#include <QDebug>
8
10
12{
13public:
16 {
17 }
18
22};
23
25
52QAudioBuffer::QAudioBuffer() noexcept = default;
53
58QAudioBuffer::QAudioBuffer(const QAudioBuffer &other) noexcept = default;
59
75{
76 if (!format.isValid() || !data.size())
77 return;
79}
80
91{
92 if (!format.isValid() || !numFrames)
93 return;
94
95 QByteArray data(format.bytesForFrames(numFrames), '\0');
97}
98
121
126
137{
138 if (!d)
139 return;
140 d = new QAudioBufferPrivate(*d);
141}
142
151{
152 if (!d)
153 return QAudioFormat();
154 return d->format;
155}
156
164{
165 if (!d)
166 return 0;
167 return d->format.framesForBytes(d->data.size());
168}
169
182{
183 return frameCount() * format().channelCount();
184}
185
190{
191 return d ? d->data.size() : 0;
192}
193
200{
202}
203
210{
211 if (!d)
212 return -1;
213 return d->startTime;
214}
215
233const void *QAudioBuffer::constData() const noexcept
234{
235 if (!d)
236 return nullptr;
237 return d->data.constData();
238}
239
256const void *QAudioBuffer::data() const noexcept
257{
258 if (!d)
259 return nullptr;
260 return d->data.constData();
261}
262
263/*
264 Template data/constData functions caused override problems with qdoc,
265 so moved their docs into the non template versions.
266*/
267
285void *QAudioBuffer::data()
286{
287 if (!d)
288 return nullptr;
289 return d->data.data();
290}
291
QAudioBufferPrivate(const QAudioFormat &f, const QByteArray &d, qint64 start)
\inmodule QtMultimedia
QAudioBuffer() noexcept
Create a new, empty, invalid buffer.
QAudioBuffer & operator=(const QAudioBuffer &other)
Moves other into this QAudioBuffer.
qsizetype sampleCount() const noexcept
Returns the number of samples in this buffer.
qint64 startTime() const noexcept
Returns the time in a stream that this buffer starts at (in microseconds).
const T * constData() const
~QAudioBuffer()
Destroys this audio buffer.
const T * data() const
qsizetype byteCount() const noexcept
Returns the size of this buffer, in bytes.
qsizetype frameCount() const noexcept
Returns the number of complete audio frames in this buffer.
void detach()
Detaches this audio buffers from other copies that might share data with it.
qint64 duration() const noexcept
Returns the duration of audio in this buffer, in microseconds.
QAudioFormat format() const noexcept
Returns the \l {QAudioFormat}{format} of this buffer.
The QAudioFormat class stores audio stream parameter information.
constexpr int channelCount() const noexcept
Returns the current channel count value.
Q_MULTIMEDIA_EXPORT qint64 durationForFrames(qint32 frameCount) const
Return the number of microseconds represented by frameCount frames in this format.
Q_MULTIMEDIA_EXPORT qint32 framesForBytes(qint32 byteCount) const
Returns the number of frames represented by byteCount in this format.
\inmodule QtCore
Definition qbytearray.h:57
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
Definition qbytearray.h:534
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
Definition qbytearray.h:474
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
Definition qbytearray.h:122
\inmodule QtCore
Definition qshareddata.h:19
Combined button and popup list for selecting options.
qint64 startTime
GLfloat GLfloat f
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint start
GLint GLsizei GLsizei GLenum format
#define QT_DEFINE_QESDP_SPECIALIZATION_DTOR(Class)
ptrdiff_t qsizetype
Definition qtypes.h:70
long long qint64
Definition qtypes.h:55
QSharedPointer< T > other(t)
[5]