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
8QAlsaAudioDeviceInfo::QAlsaAudioDeviceInfo(const QByteArray &dev, const QString &desc,
9 QAudioDevice::Mode mode)
10 : QAudioDevicePrivate(dev, mode, desc)
11{
12 checkSurround();
13
14 minimumChannelCount = 1;
15 maximumChannelCount = 2;
16 if (surround71)
17 maximumChannelCount = 8;
18 else if (surround40)
19 maximumChannelCount = 4;
20 else if (surround51)
21 maximumChannelCount = 6;
22
23 minimumSampleRate = 8000;
24 maximumSampleRate = 48000;
25
26 supportedSampleFormats = {
27 QAudioFormat::UInt8,
28 QAudioFormat::Int16,
29 QAudioFormat::Int32,
30 QAudioFormat::Float,
31 };
32
33 preferredFormat.setChannelCount(mode == QAudioDevice::Input ? 1 : 2);
34 preferredFormat.setSampleFormat(QAudioFormat::Float);
35 preferredFormat.setSampleRate(48000);
36}
37
38QAlsaAudioDeviceInfo::~QAlsaAudioDeviceInfo() = default;
39
40void QAlsaAudioDeviceInfo::checkSurround()
41{
42 if (mode != QAudioDevice::Output)
43 return;
44
45 surround40 = false;
46 surround51 = false;
47 surround71 = false;
48
49 if (id.startsWith(QLatin1String("surround40")))
50 surround40 = true;
51 if (id.startsWith(QLatin1String("surround51")))
52 surround51 = true;
53 if (id.startsWith(QLatin1String("surround71")))
54 surround71 = true;
55}
56
57QT_END_NAMESPACE