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
qalsaaudiosink_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 QAUDIOOUTPUTALSA_H
16#define QAUDIOOUTPUTALSA_H
17
18#include <alsa/asoundlib.h>
19
20#include <QtCore/qfile.h>
21#include <QtCore/qdebug.h>
22#include <QtCore/qtimer.h>
23#include <QtCore/qstring.h>
24#include <QtCore/qstringlist.h>
25#include <QtCore/qelapsedtimer.h>
26#include <QtCore/qiodevice.h>
27
28#include <QtMultimedia/qaudio.h>
29#include <QtMultimedia/qaudiodevice.h>
30#include <private/qaudiosystem_p.h>
31
33
35{
36 friend class AlsaOutputPrivate;
38public:
41
42 qint64 write( const char *data, qint64 len );
43
44 void start(QIODevice* device) override;
45 QIODevice* start() override;
46 void stop() override;
47 void reset() override;
48 void suspend() override;
49 void resume() override;
50 qsizetype bytesFree() const override;
51 void setBufferSize(qsizetype value) override;
52 qsizetype bufferSize() const override;
53 qint64 processedUSecs() const override;
54 QAudio::Error error() const override;
55 QAudio::State state() const override;
56 void setFormat(const QAudioFormat& fmt) override;
57 QAudioFormat format() const override;
58 void setVolume(qreal) override;
59 qreal volume() const override;
60
61
67
68private slots:
69 void userFeed();
70 bool deviceReady();
71
74
75private:
76 bool opened = false;
77 bool pullMode = true;
78 bool resuming = false;
79 int buffer_size = 0;
80 int period_size = 0;
81 qint64 totalTimeValue = 0;
82 unsigned int buffer_time = 100000;
83 unsigned int period_time = 20000;
84 snd_pcm_uframes_t buffer_frames;
85 snd_pcm_uframes_t period_frames;
86 int xrun_recovery(int err);
87
88 int setFormat();
89 bool open();
90 void close();
91
92 QTimer* timer = nullptr;
93 QByteArray m_device;
94 int bytesAvailable = 0;
95 qint64 elapsedTimeOffset = 0;
96 char* audioBuffer = nullptr;
97 snd_pcm_t* handle = nullptr;
98 snd_pcm_access_t access = SND_PCM_ACCESS_RW_INTERLEAVED;
99 snd_pcm_hw_params_t *hwparams = nullptr;
100 qreal m_volume = 1.0f;
101};
102
104{
105 friend class QAlsaAudioSink;
107public:
110
111 qint64 readData( char* data, qint64 len) override;
112 qint64 writeData(const char* data, qint64 len) override;
113
114private:
115 QAlsaAudioSink *audioDevice;
116};
117
119
120
121#endif
IOBluetoothDevice * device
qint64 writeData(const char *data, qint64 len) override
Writes up to maxSize bytes from data to the device.
AlsaOutputPrivate(QAlsaAudioSink *audio)
QIODevice * start() override
void setBufferSize(qsizetype value) override
QAudio::State suspendedInState
QAlsaAudioSink(const QByteArray &device, QObject *parent)
QIODevice * audioSource
qint64 processedUSecs() const override
void setFormat(const QAudioFormat &fmt) override
void setVolume(qreal) override
void processMore()
void suspend() override
QAudio::State deviceState
QAudio::State state() const override
qreal volume() const override
void resume() override
qsizetype bytesFree() const override
QAudioFormat format() const override
QAudioFormat settings
qsizetype bufferSize() const override
QAudio::Error errorState
void stop() override
QAudio::Error error() const override
qint64 write(const char *data, qint64 len)
void reset() 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
State
Definition qaudio.h:29
@ StoppedState
Definition qaudio.h:29
@ SuspendedState
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]
GLuint64 GLenum void * handle
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum access
GLenum GLsizei len
#define Q_OBJECT
#define slots
#define signals
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()