Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qalsamediadevices.cpp
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
5#include "qmediadevices.h"
6#include "qcameradevice_p.h"
7
8#include "private/qalsaaudiosource_p.h"
9#include "private/qalsaaudiosink_p.h"
10#include "private/qalsaaudiodevice_p.h"
11
12#include <alsa/asoundlib.h>
13
15
18{
19}
20
22{
24
26
27 // Create a list of all current audio devices that support mode
28 void **hints, **n;
29 char *name, *descr, *io;
30
31 if(snd_device_name_hint(-1, "pcm", &hints) < 0) {
32 qWarning() << "no alsa devices available";
33 return devices;
34 }
35 n = hints;
36
38 filter = "Input";
39 } else {
40 filter = "Output";
41 }
42
43 while (*n != NULL) {
44 name = snd_device_name_get_hint(*n, "NAME");
45 if (name != 0 && qstrcmp(name, "null") != 0) {
46 descr = snd_device_name_get_hint(*n, "DESC");
47 io = snd_device_name_get_hint(*n, "IOID");
48
49 if ((descr != NULL) && ((io == NULL) || (io == filter))) {
50 auto *infop = new QAlsaAudioDeviceInfo(name, QString::fromUtf8(descr), mode);
51 devices.append(infop->create());
52 if (strcmp(name, "default") == 0)
53 infop->isDefault = true;
54 }
55
56 free(descr);
57 free(io);
58 }
59 free(name);
60 ++n;
61 }
62 snd_device_name_free_hint(hints);
63
64 return devices;
65}
66
68{
70}
71
73{
75}
76
79{
80 return new QAlsaAudioSource(deviceInfo.id(), parent);
81}
82
85{
86 return new QAlsaAudioSink(deviceInfo.id(), parent);
87}
88
QList< QAudioDevice > audioOutputs() const override
QPlatformAudioSource * createAudioSource(const QAudioDevice &deviceInfo, QObject *parent) override
QList< QAudioDevice > audioInputs() const override
QPlatformAudioSink * createAudioSink(const QAudioDevice &deviceInfo, QObject *parent) override
The QAudioDevice class provides an information about audio devices and their functionality.
Mode
Describes the mode of this device.
QByteArray id
\qmlproperty string QtMultimedia::audioDevice::id
\inmodule QtCore
Definition qbytearray.h:57
Definition qlist.h:74
\inmodule QtCore
Definition qobject.h:90
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:311
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5857
Combined button and popup list for selecting options.
static QList< QAudioDevice > availableDevices(QAudioDevice::Mode mode)
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
EGLDeviceEXT * devices
#define qWarning
Definition qlogging.h:162
GLenum mode
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLuint name
GLfloat n
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent