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
qwindowsaudiosource_p.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// W A R N I N G
6// -------------
7//
8// This file is not part of the Qt API. It exists for the convenience
9// of other Qt classes. This header file may change from version to
10// version without notice, or even be removed.
11//
12// We mean it.
13//
14
15#ifndef QWINDOWSAUDIOINPUT_H
16#define QWINDOWSAUDIOINPUT_H
17
19
20#include <QtCore/qfile.h>
21#include <QtCore/qdebug.h>
22#include <QtCore/qelapsedtimer.h>
23#include <QtCore/qstring.h>
24#include <QtCore/qstringlist.h>
25#include <QtCore/qdatetime.h>
26#include <QtCore/qmutex.h>
27#include <QtCore/qbytearray.h>
28
29#include <QtMultimedia/qaudio.h>
30#include <QtMultimedia/qaudiodevice.h>
31#include <private/qaudiosystem_p.h>
32
33#include <qwindowsresampler_p.h>
34
35struct IMMDevice;
36struct IAudioClient;
37struct IAudioCaptureClient;
38
40class QTimer;
41
43{
45public:
46 QWindowsAudioSource(ComPtr<IMMDevice> device, QObject *parent);
48
49 qint64 read(char* data, qint64 len);
50
51 void setFormat(const QAudioFormat& fmt) override;
52 QAudioFormat format() const override;
53 QIODevice* start() override;
54 void start(QIODevice* device) override;
55 void stop() override;
56 void reset() override;
57 void suspend() override;
58 void resume() override;
59 qsizetype bytesReady() const override;
60 void setBufferSize(qsizetype value) override;
61 qsizetype bufferSize() const override;
62 qint64 processedUSecs() const override;
63 QAudio::Error error() const override;
64 QAudio::State state() const override;
65 void setVolume(qreal volume) override;
66 qreal volume() const override;
67
68private:
69 void deviceStateChange(QAudio::State state, QAudio::Error error);
70 void pullCaptureClient();
71 void schedulePull();
72 QByteArray readCaptureClientBuffer();
73
74 QTimer *m_timer = nullptr;
75 ComPtr<IMMDevice> m_device;
76 ComPtr<IAudioClient> m_audioClient;
77 ComPtr<IAudioCaptureClient> m_captureClient;
78 QWindowsResampler m_resampler;
79 int m_bufferSize = 0;
80 qreal m_volume = 1.0;
81
82 QIODevice* m_ourSink = nullptr;
83 QIODevice* m_clientSink = nullptr;
84 QAudioFormat m_format;
85 QAudio::Error m_errorState = QAudio::NoError;
86 QAudio::State m_deviceState = QAudio::StoppedState;
87
88 QByteArray m_clientBufferResidue;
89
90 bool open();
91 void close();
92};
93
95
96#endif
IOBluetoothDevice * device
The QAudioFormat class stores audio stream parameter information.
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore \reentrant
Definition qiodevice.h:34
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
\inmodule QtCore
Definition qtimer.h:20
qint64 processedUSecs() const override
qsizetype bufferSize() const override
qreal volume() const override
qint64 read(char *data, qint64 len)
void setVolume(qreal volume) override
QWindowsAudioSource(ComPtr< IMMDevice > device, QObject *parent)
void setFormat(const QAudioFormat &fmt) override
QAudio::State state() const override
qsizetype bytesReady() const override
void setBufferSize(qsizetype value) override
QAudio::Error error() const override
QAudioFormat format() const override
QIODevice * start() override
State
Definition qaudio.h:29
@ StoppedState
Definition qaudio.h:29
Error
Definition qaudio.h:28
@ NoError
Definition qaudio.h:28
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLsizei len
#define Q_OBJECT
ptrdiff_t qsizetype
Definition qtypes.h:165
long long qint64
Definition qtypes.h:60
double qreal
Definition qtypes.h:187
QVideoFrameFormat::PixelFormat fmt