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
qandroidaudiosource_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 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#ifndef QOPENSLESAUDIOINPUT_H
5#define QOPENSLESAUDIOINPUT_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <private/qaudiosystem_p.h>
19#include <QElapsedTimer>
20#include <SLES/OpenSLES.h>
21
22#ifdef ANDROID
23#include <SLES/OpenSLES_Android.h>
24
25#define QT_ANDROID_PRESET_MIC "mic"
26#define QT_ANDROID_PRESET_CAMCORDER "camcorder"
27#define QT_ANDROID_PRESET_VOICE_RECOGNITION "voicerecognition"
28#define QT_ANDROID_PRESET_VOICE_COMMUNICATION "voicecommunication"
29
30#endif
31
33
34class QOpenSLESEngine;
35class QIODevice;
36class QBuffer;
37
39{
41
42public:
45
46 void start(QIODevice *device);
48 void stop();
49 void reset();
50 void suspend();
51 void resume();
52 qsizetype bytesReady() const;
54 qsizetype bufferSize() const;
55 qint64 processedUSecs() const;
56 QAudio::Error error() const;
57 QAudio::State state() const;
58 void setFormat(const QAudioFormat &format);
59 QAudioFormat format() const;
60
62 qreal volume() const;
63
64public Q_SLOTS:
65 void processBuffer();
66
67private:
68 bool startRecording();
69 void stopRecording();
70 void writeDataToDevice(const char *data, int size);
71 void flushBuffers();
72
73 QByteArray m_device;
74 QOpenSLESEngine *m_engine;
75 SLObjectItf m_recorderObject;
76 SLRecordItf m_recorder;
77#ifdef ANDROID
78 SLuint32 m_recorderPreset;
79 SLAndroidSimpleBufferQueueItf m_bufferQueue;
80#else
81 SLBufferQueueItf m_bufferQueue;
82#endif
83
84 bool m_pullMode;
85 qint64 m_processedBytes;
86 QIODevice *m_audioSource;
87 QBuffer *m_bufferIODevice;
88 QByteArray m_pushBuffer;
89 QAudioFormat m_format;
90 QAudio::Error m_errorState;
91 QAudio::State m_deviceState;
92 qint64 m_lastNotifyTime;
93 qreal m_volume;
94 int m_bufferSize;
95 QByteArray *m_buffers;
96 int m_currentBuffer;
97};
98
100
101#endif // QOPENSLESAUDIOINPUT_H
IOBluetoothDevice * device
void setBufferSize(qsizetype value)
void setFormat(const QAudioFormat &format)
QAudioFormat format() const
QAudio::Error error() const
qsizetype bufferSize() const
void setVolume(qreal volume)
qsizetype bytesReady() const
QAndroidAudioSource(const QByteArray &device, QObject *parent)
QAudio::State state() const
The QAudioFormat class stores audio stream parameter information.
\inmodule QtCore \reentrant
Definition qbuffer.h:16
\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
State
Definition qaudio.h:29
Error
Definition qaudio.h:28
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei GLsizei GLenum format
#define Q_OBJECT
#define Q_SLOTS
ptrdiff_t qsizetype
Definition qtypes.h:165
long long qint64
Definition qtypes.h:60
double qreal
Definition qtypes.h:187