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
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
5
7
8namespace {
9
11createAlsaAudioDeviceFormatFromDeviceName(const QByteArray &dev, QAudioDevice::Mode mode)
12{
13 QAudioDevicePrivate::AudioDeviceFormat format;
14
15 // Check surround capabilities
16 bool surround40 = false;
17 bool surround51 = false;
18 bool surround71 = false;
19
20 if (mode == QAudioDevice::Output) {
21 if (dev.startsWith(QLatin1String("surround40")))
22 surround40 = true;
23 if (dev.startsWith(QLatin1String("surround51")))
24 surround51 = true;
25 if (dev.startsWith(QLatin1String("surround71")))
26 surround71 = true;
27 }
28
29 format.minimumChannelCount = 1;
30 format.maximumChannelCount = 2;
31 if (surround71)
32 format.maximumChannelCount = 8;
33 else if (surround40)
34 format.maximumChannelCount = 4;
35 else if (surround51)
36 format.maximumChannelCount = 6;
37
38 format.minimumSampleRate = 8000;
39 format.maximumSampleRate = 48000;
40
41 format.supportedSampleFormats = {
42 QAudioFormat::UInt8,
43 QAudioFormat::Int16,
44 QAudioFormat::Int32,
45 QAudioFormat::Float,
46 };
47
48 format.preferredFormat.setChannelCount(mode == QAudioDevice::Input ? 1 : 2);
49 format.preferredFormat.setSampleFormat(QAudioFormat::Float);
50 format.preferredFormat.setSampleRate(48000);
51
52 return format;
53}
54
55} // namespace
56
57QAlsaAudioDeviceInfo::QAlsaAudioDeviceInfo(const QByteArray &dev, const QString &desc,
58 QAudioDevice::Mode mode)
59 : QAudioDevicePrivate(dev, mode, desc, false,
60 createAlsaAudioDeviceFormatFromDeviceName(dev, mode))
61{
62}
63
64QAlsaAudioDeviceInfo::~QAlsaAudioDeviceInfo() = default;
65
66QT_END_NAMESPACE
Combined button and popup list for selecting options.
QAudioDevicePrivate::AudioDeviceFormat createAlsaAudioDeviceFormatFromDeviceName(const QByteArray &dev, QAudioDevice::Mode mode)