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 <optional>
25#endif
26
27QT_BEGIN_NAMESPACE
28
29class QCoreAudioDevices : public QPlatformAudioDevices
30{
31public:
32 QCoreAudioDevices();
33 ~QCoreAudioDevices() 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 bool hasCallbackApi() const override { return true; }
45
46private:
47 QList<QAudioDevice> findAudioInputs() const override;
48 QList<QAudioDevice> findAudioOutputs() const override;
49#ifdef Q_OS_MACOS
50 struct DispatchQueueDeleter
51 {
52 void operator()(dispatch_queue_t queue) const
53 {
54 if (queue)
55 dispatch_release(queue);
56 }
57 };
58 using UniqueDispatchQueue =
59 std::unique_ptr<std::remove_pointer_t<dispatch_queue_t>, DispatchQueueDeleter>;
60
61 std::unique_ptr<AudioObjectPropertyListenerBlock> m_deviceListenerBlock;
62 UniqueDispatchQueue m_listenerQueue;
63 std::shared_ptr<bool> m_destroyed = std::make_shared<bool>(false);
64#endif
65};
66
67namespace QCoreAudioUtils {
68
69#ifdef Q_OS_MACOS
71{
72public:
76
77private:
79};
80#endif
81
82} // namespace QCoreAudioUtils
83
84QT_END_NAMESPACE
85
86#endif // QCOREAUDIODEVICES_H
Combined button and popup list for selecting options.