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
qcoreaudioaggregatedevice_p.h
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QCOREAUDIOAGGREGATEDEVICE_P_H
5#define QCOREAUDIOAGGREGATEDEVICE_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/qaudiodevice.h>
19#include <QtCore/qstring.h>
20
21#include <chrono>
22#include <cstdint>
23#include <memory>
24#include <optional>
25
26QT_BEGIN_NAMESPACE
27
28// Test helper: creates a CoreAudio aggregate device wrapping the system default device, and
29// destroys it on request. Destroying the aggregate device looks like an unplugged device to
30// QtMultimedia, without needing any hardware to be unplugged.
31class QCoreAudioAggregateDevice
32{
33public:
34 enum class Direction : uint8_t {
35 Output,
36 Input,
37 };
38
39 static std::unique_ptr<QCoreAudioAggregateDevice> create(Direction);
40
41 Q_DISABLE_COPY_MOVE(QCoreAudioAggregateDevice)
42 ~QCoreAudioAggregateDevice();
43
44 // Polls QMediaDevices until the aggregate shows up. Nullopt on timeout.
45 std::optional<QAudioDevice> waitForQtDevice(std::chrono::milliseconds timeout) const;
46
47 bool destroyAndWaitForDisconnectNotification(std::chrono::milliseconds timeout);
48
49private:
50 struct Private;
51 explicit QCoreAudioAggregateDevice(std::unique_ptr<Private>);
52
53 std::unique_ptr<Private> d;
54};
55
56QT_END_NAMESPACE
57
58#endif // QCOREAUDIOAGGREGATEDEVICE_P_H