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
qdarwinaudiodevices_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 QDARWINAUDIODEVICES_H
5#define QDARWINAUDIODEVICES_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 <optional>
25#endif
26
27QT_BEGIN_NAMESPACE
28
29class QDarwinAudioDevices : public QPlatformAudioDevices
30{
31public:
32 QDarwinAudioDevices();
33 ~QDarwinAudioDevices() override;
34
35 QPlatformAudioSource *createAudioSource(const QAudioDevice &, const QAudioFormat &,
36 QObject *parent) override;
37 QPlatformAudioSink *createAudioSink(const QAudioDevice &, const QAudioFormat &,
38 QObject *parent) override;
39
40 using QPlatformAudioDevices::updateAudioInputsCache;
41 using QPlatformAudioDevices::updateAudioOutputsCache;
42
43 QLatin1String backendName() const override { return QLatin1String{ "CoreAudio" }; }
44
45private:
46 QList<QAudioDevice> findAudioInputs() const override;
47 QList<QAudioDevice> findAudioOutputs() const override;
48#ifdef Q_OS_MACOS
49 struct DispatchQueueDeleter
50 {
51 void operator()(dispatch_queue_t queue) const
52 {
53 if (queue)
54 dispatch_release(queue);
55 }
56 };
57 using UniqueDispatchQueue =
58 std::unique_ptr<std::remove_pointer_t<dispatch_queue_t>, DispatchQueueDeleter>;
59
60 std::unique_ptr<AudioObjectPropertyListenerBlock> m_deviceListenerBlock;
61 UniqueDispatchQueue m_listenerQueue;
62 std::shared_ptr<bool> m_destroyed = std::make_shared<bool>(false);
63#endif
64};
65
66namespace QCoreAudioUtils {
67
68#ifdef Q_OS_MACOS
70{
71public:
75
76private:
78};
79#endif
80
81} // namespace QCoreAudioUtils
82
83QT_END_NAMESPACE
84
85#endif // QDARWINAUDIODEVICES_H
Combined button and popup list for selecting options.