Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qaudiosource.h
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
5
#
ifndef
QAUDIOINPUT_H
6
#
define
QAUDIOINPUT_H
7
8
#
include
<
QtMultimedia
/
qaudiodevice
.
h
>
9
#
include
<
QtMultimedia
/
qaudioformat
.
h
>
10
#
include
<
QtMultimedia
/
qtaudio
.
h
>
11
#
include
<
QtMultimedia
/
qtmultimediaglobal
.
h
>
12
#
include
<
QtCore
/
qiodevice
.
h
>
13
14
15
QT_BEGIN_NAMESPACE
16
17
class
QPlatformAudioSource;
18
19
class
Q_MULTIMEDIA_EXPORT
QAudioSource
:
public
QObject
20
{
21
Q_OBJECT
22
23
public
:
24
explicit
QAudioSource(
const
QAudioFormat &format = QAudioFormat(), QObject *parent =
nullptr
);
25
explicit
QAudioSource(
const
QAudioDevice &audioDeviceInfo,
const
QAudioFormat &format = QAudioFormat(), QObject *parent =
nullptr
);
26
~QAudioSource() override;
27
28
bool
isNull()
const
{
return
!d; }
29
30
QAudioFormat format()
const
;
31
32
void
start(QIODevice *device);
33
QIODevice* start();
34
35
template
<
typename
Callback, QtAudio::if_audio_source_callback<Callback> =
true
>
36
void
start(Callback &&cb)
37
{
38
Q_ASSERT(QtAudioPrivate::isNonnullFunction(cb));
39
40
if
constexpr
(!std::is_copy_constructible_v<Callback>) {
41
// poor man's move-only function
42
using
CallbackType =
typename
QtAudioPrivate::GetSampleType<Callback>::type;
43
auto
callback = std::make_shared<std::decay_t<Callback>>(std::forward<Callback>(cb));
44
start([callback = std::move(callback)](QSpan<
const
CallbackType> arg) {
45
(*callback)(arg);
46
});
47
}
else
{
48
startABIImpl(QtAudioPrivate::AudioSourceCallback(std::forward<Callback>(cb)));
49
}
50
}
51
52
void
stop();
53
void
reset();
54
void
suspend();
55
void
resume();
56
57
void
setBufferSize(qsizetype bytes);
58
qsizetype bufferSize()
const
;
59
60
void
setBufferFrameCount(qsizetype frames);
61
qsizetype bufferFrameCount()
const
;
62
63
void
setNativePeriodFrameCount(qsizetype frameCount);
64
qsizetype nativePeriodFrameCount()
const
;
65
66
qsizetype bytesAvailable()
const
;
67
qsizetype framesAvailable()
const
;
68
69
void
setVolume(qreal volume);
70
qreal volume()
const
;
71
72
qint64 processedUSecs()
const
;
73
qint64 elapsedUSecs()
const
;
74
75
QtAudio::Error error()
const
;
76
QtAudio::State state()
const
;
77
78
Q_SIGNALS:
79
#
if
defined
(
Q_QDOC
)
80
void
stateChanged(QtAudio::State state);
81
#
else
82
// use QAudio here to keep string-based connections working
83
void
stateChanged(QAudio::State state);
84
#
endif
85
86
private
:
87
template
<
typename
T>
88
void
startImpl(T &&);
89
90
void
startABIImpl(QtAudioPrivate::AudioSourceCallback &&);
91
92
Q_DISABLE_COPY(QAudioSource)
93
friend
class
QPlatformAudioSource;
94
95
QPlatformAudioSource *d;
96
};
97
98
QT_END_NAMESPACE
99
100
#
endif
// QAUDIOINPUT_H
QAudioSource
The QAudioSource class provides an interface for receiving audio data from an audio input device.
Definition
qaudiosource.h:20
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
validateFormatAtStart
static bool validateFormatAtStart(QPlatformAudioSource *d)
Definition
qaudiosource.cpp:163
qtmultimedia
src
multimedia
audio
qaudiosource.h
Generated on
for Qt by
1.18.0