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
qalsaaudiosource_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
16#ifndef QAUDIOINPUTALSA_H
17#define QAUDIOINPUTALSA_H
18
19#include <alsa/asoundlib.h>
20
21#include <QtCore/qfile.h>
22#include <QtCore/qdebug.h>
23#include <QtCore/qtimer.h>
24#include <QtCore/qstring.h>
25#include <QtCore/qstringlist.h>
26#include <QtCore/qelapsedtimer.h>
27#include <QtCore/qiodevice.h>
28
29#include <QtMultimedia/qaudio.h>
30#include <QtMultimedia/qaudiodevice.h>
31#include <private/qaudiosystem_p.h>
32
34
35
37
39{
40public:
41 RingBuffer();
42
43 void resize(int size);
44
45 int bytesOfDataInBuffer() const;
46 int freeBytes() const;
47
48 const char *availableData() const;
49 int availableDataBlockSize() const;
50 void readBytes(int bytes);
51
52 void write(char *data, int len);
53
54private:
55 int m_head;
56 int m_tail;
57
58 QByteArray m_data;
59};
60
62{
64public:
67
68 qint64 read(char* data, qint64 len);
69
70 void start(QIODevice* device) override;
71 QIODevice* start() override;
72 void stop() override;
73 void reset() override;
74 void suspend() override;
75 void resume() override;
76 qsizetype bytesReady() const override;
77 void setBufferSize(qsizetype value) override;
78 qsizetype bufferSize() const override;
79 qint64 processedUSecs() const override;
80 QAudio::Error error() const override;
81 QAudio::State state() const override;
82 void setFormat(const QAudioFormat& fmt) override;
83 QAudioFormat format() const override;
84 void setVolume(qreal) override;
85 qreal volume() const override;
87 snd_pcm_t* handle;
93
94private slots:
95 void userFeed();
96 bool deviceReady();
97
98private:
99 int checkBytesReady();
100 int xrun_recovery(int err);
101 int setFormat();
102 bool open();
103 void close();
104 void drain();
105
106 QTimer* timer;
107 qint64 elapsedTimeOffset;
108 RingBuffer ringBuffer;
109 qsizetype bytesAvailable;
110 QByteArray m_device;
111 bool pullMode;
112 qsizetype buffer_size;
113 int period_size;
114 unsigned int buffer_time;
115 unsigned int period_time;
116 snd_pcm_uframes_t buffer_frames;
117 snd_pcm_uframes_t period_frames;
118 snd_pcm_access_t access;
119 snd_pcm_format_t pcmformat;
120 snd_pcm_hw_params_t *hwparams;
121 qreal m_volume;
122};
123
125{
127public:
130
131 qint64 readData( char* data, qint64 len) override;
132 qint64 writeData(const char* data, qint64 len) override;
133
134 void trigger();
135private:
136 QAlsaAudioSource *audioDevice;
137};
138
140
141
142#endif
IOBluetoothDevice * device
qint64 writeData(const char *data, qint64 len) override
Writes up to maxSize bytes from data to the device.
AlsaInputPrivate(QAlsaAudioSource *audio)
void resume() override
void reset() override
void stop() override
QAlsaAudioSource(const QByteArray &device, QObject *parent)
qsizetype bytesReady() const override
QAudio::State deviceState
QAudioFormat format() const override
QIODevice * start() override
void setFormat(const QAudioFormat &fmt) override
void setVolume(qreal) override
qreal volume() const override
void setBufferSize(qsizetype value) override
QAudio::Error error() const override
QAudio::State state() const override
qsizetype bufferSize() const override
qint64 processedUSecs() const override
qint64 read(char *data, qint64 len)
QAudio::Error errorState
void suspend() override
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
const char * availableData() const
int availableDataBlockSize() const
void write(char *data, int len)
int freeBytes() const
void readBytes(int bytes)
int bytesOfDataInBuffer() const
void resize(int size)
widget setFormat(format)
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
GLenum access
GLenum GLsizei len
#define Q_OBJECT
#define slots
ptrdiff_t qsizetype
Definition qtypes.h:165
long long qint64
Definition qtypes.h:60
double qreal
Definition qtypes.h:187
QVideoFrameFormat::PixelFormat fmt
QByteArray readData()