Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
33QT_BEGIN_NAMESPACE
34
35
36class AlsaInputPrivate;
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::State state() const override;
82 snd_pcm_t* handle;
86
87private slots:
88 void userFeed();
89 bool deviceReady();
90
91private:
92 int checkBytesReady();
93 int xrun_recovery(int err);
94 int setFormat();
95 bool open();
96 void close();
97 void drain();
98
99 QTimer* timer;
100 qint64 elapsedTimeOffset;
101 RingBuffer ringBuffer;
102 qsizetype bytesAvailable;
103 bool pullMode;
104 qsizetype buffer_size;
105 int period_size;
106 unsigned int buffer_time;
107 unsigned int period_time;
108 snd_pcm_uframes_t buffer_frames;
109 snd_pcm_uframes_t period_frames;
110 snd_pcm_access_t access;
111 snd_pcm_format_t pcmformat;
112 snd_pcm_hw_params_t *hwparams;
113};
114
116{
118public:
121
122 qint64 readData( char* data, qint64 len) override;
123 qint64 writeData(const char* data, qint64 len) override;
124
125 void trigger();
126private:
127 QAlsaAudioSource *audioDevice;
128};
129
130QT_END_NAMESPACE
131
132
133#endif
qint64 readData(char *data, qint64 len) override
Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an...
qint64 writeData(const char *data, qint64 len) override
Writes up to maxSize bytes from data to the device.
void resume() override
void reset() override
void stop() override
qsizetype bytesReady() const override
QAudio::State deviceState
QIODevice * start() override
void setBufferSize(qsizetype value) override
QAudio::State state() const override
qsizetype bufferSize() const override
qint64 processedUSecs() const override
void start(QIODevice *device) override
qint64 read(char *data, qint64 len)
void suspend() override
The QAudioDevice class provides an information about audio devices and their functionality.
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)