Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
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
234const void *QAudioBuffer::constData() const noexcept
235{
236 if (!d)
237 return nullptr;
238 return d->data.constData();
239}
240
258const void *QAudioBuffer::data() const noexcept
259{
260 if (!d)
261 return nullptr;
262 return d->data.constData();
263}
264
283void *QAudioBuffer::data()
284{
285 if (!d)
286 return nullptr;
287 return d->data.data();
288}
289
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).
~QAudioBuffer()
Destroys this audio buffer.
qsizetype byteCount() const noexcept
Returns the size of this buffer, in bytes.
const T * constData() const
Returns a pointer to this buffer's data.
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.
const T * data() const
Returns a pointer to this buffer's data.
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:611
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
Definition qbytearray.h:494
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
Definition qbytearray.h:124
\inmodule QtCore
Definition qshareddata.h:19
Combined button and popup list for selecting options.
qint64 startTime
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat GLfloat f
GLuint start
GLint GLsizei GLsizei GLenum format
#define QT_DEFINE_QESDP_SPECIALIZATION_DTOR(Class)
ptrdiff_t qsizetype
Definition qtypes.h:165
long long qint64
Definition qtypes.h:60
QSharedPointer< T > other(t)
[5]