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
qandroidaudioutil.cpp
Go to the documentation of this file.
1// Copyright (C) 2025 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
9
10namespace QAndroidAudioUtil {
11
13{
14 static const bool lowLatencyIsSupported = []() {
15 // clang-format off
16 QJniObject ctx(QNativeInterface::QAndroidApplication::context());
17 if (!ctx.isValid())
18 return false;
19
20 QJniObject pm = ctx.callObjectMethod("getPackageManager",
21 "()Landroid/content/pm/PackageManager;");
22 if (!pm.isValid())
23 return false;
24
25 QJniObject audioFeatureField =
26 QJniObject::getStaticObjectField("android/content/pm/PackageManager",
27 "FEATURE_AUDIO_LOW_LATENCY",
28 "Ljava/lang/String;");
29 if (!audioFeatureField.isValid())
30 return false;
31
32 bool hasFeature = pm.callMethod<jboolean>("hasSystemFeature",
33 "(Ljava/lang/String;)Z",
34 audioFeatureField.object());
35 return hasFeature;
36 // clang-format on
37 }();
38
39 return lowLatencyIsSupported;
40}
41
42bool isDefaultBluetoothDevice(const QAudioDevice &device)
43{
44 return device.isDefault() && QAudioDevicePrivate::handle<QAndroidAudioDevice>(device)->isBluetoothDevice();
45}
46
47} // namespace QAndroidAudioUtil
48
49QT_END_NAMESPACE
Q_MULTIMEDIA_EXPORT bool supportsLowLatency()
Q_MULTIMEDIA_EXPORT bool isDefaultBluetoothDevice(const QAudioDevice &device)