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
qcoreaudiodevices_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 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 QCOREAUDIODEVICES_H
5#define QCOREAUDIODEVICES_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 <private/qplatformaudiodevices_p.h>
19
20#ifdef Q_OS_MACOS
21# include <QtCore/qfuture.h>
22# include <CoreAudio/AudioHardware.h>
23# include <dispatch/dispatch.h>
24# include <memory>
25# include <optional>
26#endif
27
28QT_BEGIN_NAMESPACE
29
30class QCoreAudioDevices : public QPlatformAudioDevices
31{
32public:
33 QCoreAudioDevices();
34 ~QCoreAudioDevices() override;
35
36 QPlatformAudioSource *createAudioSource(const QAudioDevice &, const QAudioFormat &,
37 QObject *parent) override;
38 QPlatformAudioSink *createAudioSink(const QAudioDevice &, const QAudioFormat &,
39 QObject *parent) override;
40
41 using QPlatformAudioDevices::updateAudioInputsCache;
42 using QPlatformAudioDevices::updateAudioOutputsCache;
43
44 QLatin1String backendName() const override { return QLatin1String{ "CoreAudio" }; }
45 bool hasCallbackApi() const override { return true; }
46
47private:
48 QList<QAudioDevice> findAudioInputs() const override;
49 QList<QAudioDevice> findAudioOutputs() const override;
50#ifdef Q_OS_MACOS
51 struct DispatchQueueDeleter
52 {
53 void operator()(dispatch_queue_t queue) const
54 {
55 if (queue)
56 dispatch_release(queue);
57 }
58 };
59 using UniqueDispatchQueue =
60 std::unique_ptr<std::remove_pointer_t<dispatch_queue_t>, DispatchQueueDeleter>;
61
62 std::shared_ptr<AudioObjectPropertyListenerBlock> m_deviceListenerBlock;
63 UniqueDispatchQueue m_listenerQueue;
64 std::shared_ptr<bool> m_destroyed = std::make_shared<bool>(false);
65#endif
66};
67
68namespace QCoreAudioUtils {
69
70#ifdef Q_OS_MACOS
72{
73public:
76
77private:
78 struct State
79 {
82 };
83
85};
86#endif
87
88} // namespace QCoreAudioUtils
89
90QT_END_NAMESPACE
91
92#endif // QCOREAUDIODEVICES_H
Combined button and popup list for selecting options.
#define __has_feature(x)