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
qaudioformat_p.h
Go to the documentation of this file.
1
// Copyright (C) 2024 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
#
ifndef
QAUDIOFORMAT_P_H
5
#
define
QAUDIOFORMAT_P_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists purely as an
12
// implementation detail. This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#
include
<
QtMultimedia
/
qaudioformat
.
h
>
19
#
include
<
QtMultimedia
/
qtmultimediaglobal
.
h
>
20
#
include
<
QtMultimedia
/
private
/
qmultimedia_ranges_p
.
h
>
21
22
#
include
<
array
>
23
24
QT_BEGIN_NAMESPACE
25
26
namespace
QtMultimediaPrivate
{
27
28
inline
constexpr
std
::array
allSupportedSampleRates
{
29
8'000, 11'025, 12'000, 16'000, 22'050, 24'000, 32'000, 44'100,
30
48'000, 64'000, 88'200, 96'000, 128'000, 176'400, 192'000,
31
};
32
33
inline
constexpr
std
::array
allSupportedSampleFormats
{
34
QAudioFormat
::
UInt8
,
35
QAudioFormat
::
Int16
,
36
QAudioFormat
::
Int32
,
37
QAudioFormat
::
Float
,
38
};
39
40
template
<
typename
T>
41
int
findClosestSamplingRate
(
int
rate, QSpan<
const
T> supportedRates)
42
{
43
Q_ASSERT(!supportedRates.empty());
44
namespace
ranges = QtMultimediaPrivate::ranges;
45
46
auto
exactMatchIt = ranges::find(supportedRates, T(rate));
47
if
(exactMatchIt != supportedRates.end())
48
return
int
(*exactMatchIt);
49
50
// find supported rate, which is closest to the default pipewire sampling rate (using a
51
// logarithmic scaling)
52
auto
ratioToRate = [&](
int
arg) {
53
return
arg > rate ?
float
(arg) / rate : rate /
float
(arg);
54
};
55
56
return
ranges::min(supportedRates, [&](
auto
lhs,
auto
rhs) {
57
return
ratioToRate(lhs) < ratioToRate(rhs);
58
});
59
}
60
61
}
// namespace QtMultimediaPrivate
62
63
QT_END_NAMESPACE
64
65
#
endif
// QAUDIOFORMAT_P_H
QtMultimediaPrivate
Definition
qaudiosystem_p.h:49
QtMultimediaPrivate::allSupportedSampleRates
constexpr std::array allSupportedSampleRates
Definition
qaudioformat_p.h:28
QtMultimediaPrivate::allSupportedSampleFormats
constexpr std::array allSupportedSampleFormats
Definition
qaudioformat_p.h:33
QtMultimediaPrivate::findClosestSamplingRate
int findClosestSamplingRate(int rate, QSpan< const T > supportedRates)
Definition
qaudioformat_p.h:41
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qtmultimedia
src
multimedia
audio
qaudioformat_p.h
Generated on
for Qt by
1.16.1