Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qalsaaudiodevice.cpp
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// INTERNAL USE ONLY: Do NOT use for any other purpose.
13//
14
15#include "qalsaaudiodevice_p.h"
16
17#include <alsa/version.h>
18
20
23{
25
26 checkSurround();
27
30 if (surround71)
32 else if (surround40)
34 else if (surround51)
36
37 minimumSampleRate = 8000;
38 maximumSampleRate = 48000;
39
41
45}
46
48{
49}
50
51void QAlsaAudioDeviceInfo::checkSurround()
52{
53 surround40 = false;
54 surround51 = false;
55 surround71 = false;
56
57 void **hints, **n;
58 char *name, *descr, *io;
59
60 if(snd_device_name_hint(-1, "pcm", &hints) < 0)
61 return;
62
63 n = hints;
64
65 while (*n != NULL) {
66 name = snd_device_name_get_hint(*n, "NAME");
67 descr = snd_device_name_get_hint(*n, "DESC");
68 io = snd_device_name_get_hint(*n, "IOID");
69 if((name != NULL) && (descr != NULL)) {
70 QString deviceName = QLatin1String(name);
72 if(deviceName.contains(QLatin1String("surround40")))
73 surround40 = true;
74 if(deviceName.contains(QLatin1String("surround51")))
75 surround51 = true;
76 if(deviceName.contains(QLatin1String("surround71")))
77 surround71 = true;
78 }
79 }
80 if(name != NULL)
81 free(name);
82 if(descr != NULL)
83 free(descr);
84 if(io != NULL)
85 free(io);
86 ++n;
87 }
88 snd_device_name_free_hint(hints);
89}
90
QAlsaAudioDeviceInfo(const QByteArray &dev, const QString &description, QAudioDevice::Mode mode)
QAudioFormat preferredFormat
QList< QAudioFormat::SampleFormat > supportedSampleFormats
Mode
Describes the mode of this device.
constexpr void setSampleRate(int sampleRate) noexcept
Sets the sample rate to samplerate in Hertz.
constexpr void setSampleFormat(SampleFormat f) noexcept
Sets the sample format to format.
constexpr void setChannelCount(int channelCount) noexcept
Sets the channel count to channels.
\inmodule QtCore
Definition qbytearray.h:57
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition qstring.h:1217
Combined button and popup list for selecting options.
GLenum mode
GLuint name
GLfloat n
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
@ desc