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
qaudiosink.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
QAUDIOOUTPUT_H
6
#
define
QAUDIOOUTPUT_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
QT_BEGIN_NAMESPACE
15
16
class
QPlatformAudioSink;
17
18
class
Q_MULTIMEDIA_EXPORT
QAudioSink
:
public
QObject
19
{
20
Q_OBJECT
21
22
public
:
23
explicit
QAudioSink(
const
QAudioFormat &format = QAudioFormat(), QObject *parent =
nullptr
);
24
explicit
QAudioSink(
const
QAudioDevice &audioDeviceInfo,
const
QAudioFormat &format = QAudioFormat(), QObject *parent =
nullptr
);
25
~QAudioSink() override;
26
27
bool
isNull()
const
{
return
!d; }
28
29
QAudioFormat format()
const
;
30
31
void
start(QIODevice *device);
32
QIODevice* start();
33
34
template
<
typename
Callback, QtAudio::if_audio_sink_callback<Callback> =
true
>
35
void
start(Callback &&cb)
36
{
37
Q_ASSERT(QtAudioPrivate::isNonnullFunction(cb));
38
39
if
constexpr
(!std::is_copy_constructible_v<Callback>) {
40
// poor man's move-only function
41
using
CallbackType =
typename
QtAudioPrivate::GetSampleType<Callback>::type;
42
auto
callback = std::make_shared<std::decay_t<Callback>>(std::forward<Callback>(cb));
43
start([callback = std::move(callback)](QSpan<CallbackType> arg) {
44
(*callback)(arg);
45
});
46
}
else
{
47
startABIImpl(QtAudioPrivate::AudioSinkCallback(std::forward<Callback>(cb)));
48
}
49
}
50
51
void
stop();
52
void
reset();
53
void
suspend();
54
void
resume();
55
56
void
setBufferSize(qsizetype bytes);
57
qsizetype bufferSize()
const
;
58
59
void
setBufferFrameCount(qsizetype framesCount);
60
qsizetype bufferFrameCount()
const
;
61
62
void
setNativePeriodFrameCount(qsizetype frameCount);
63
qsizetype nativePeriodFrameCount()
const
;
64
65
qsizetype bytesFree()
const
;
66
qsizetype framesFree()
const
;
67
68
qint64 processedUSecs()
const
;
69
qint64 elapsedUSecs()
const
;
70
71
QtAudio::Error error()
const
;
72
QtAudio::State state()
const
;
73
74
void
setVolume(qreal);
75
qreal volume()
const
;
76
77
Q_SIGNALS:
78
#
if
defined
(
Q_QDOC
)
79
void
stateChanged(QtAudio::State state);
80
#
else
81
// use QAudio here to keep string-based connections working
82
void
stateChanged(QAudio::State state);
83
#
endif
84
85
private
:
86
template
<
typename
T>
87
void
startImpl(T &&callback);
88
89
void
startABIImpl(QtAudioPrivate::AudioSinkCallback &&);
90
91
Q_DISABLE_COPY(QAudioSink)
92
93
friend
class
QPlatformAudioSink;
94
QPlatformAudioSink *d;
95
};
96
97
QT_END_NAMESPACE
98
99
#
endif
// QAUDIOOUTPUT_H
QAudioSink
The QAudioSink class provides an interface for sending audio data to an audio output device.
Definition
qaudiosink.h:19
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
validateFormatAtStart
static bool validateFormatAtStart(QPlatformAudioSink *d)
Definition
qaudiosink.cpp:165
qtmultimedia
src
multimedia
audio
qaudiosink.h
Generated on
for Qt by
1.18.0