| 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 | #include "qpulseaudiodevices_p.h" |
| 5 | #include "qmediadevices.h" |
| 6 | #include "private/qcameradevice_p.h" |
| 7 | |
| 8 | #include "qpulseaudiosource_p.h" |
| 9 | #include "qpulseaudiosink_p.h" |
| 10 | #include "qpulseaudio_contextmanager_p.h" |
| 11 | |
| 12 | QT_BEGIN_NAMESPACE |
| 13 | |
| 14 | QPulseAudioDevices::QPulseAudioDevices() |
| 15 | { |
| 16 | pulseEngine = new QPulseAudioContextManager(); |
| 17 | |
| 18 | // TODO: it might make sense to connect device changing signals |
| 19 | // to each added QMediaDevices |
| 20 | QObject::connect(sender: pulseEngine, signal: &QPulseAudioContextManager::audioInputsChanged, context: this, |
| 21 | slot: &QPulseAudioDevices::onAudioInputsChanged, type: Qt::DirectConnection); |
| 22 | QObject::connect(sender: pulseEngine, signal: &QPulseAudioContextManager::audioOutputsChanged, context: this, |
| 23 | slot: &QPulseAudioDevices::onAudioOutputsChanged, type: Qt::DirectConnection); |
| 24 | } |
| 25 | |
| 26 | QPulseAudioDevices::~QPulseAudioDevices() |
| 27 | { |
| 28 | delete pulseEngine; |
| 29 | } |
| 30 | |
| 31 | QList<QAudioDevice> QPulseAudioDevices::findAudioInputs() const |
| 32 | { |
| 33 | return pulseEngine->availableDevices(mode: QAudioDevice::Input); |
| 34 | } |
| 35 | |
| 36 | QList<QAudioDevice> QPulseAudioDevices::findAudioOutputs() const |
| 37 | { |
| 38 | return pulseEngine->availableDevices(mode: QAudioDevice::Output); |
| 39 | } |
| 40 | |
| 41 | QPlatformAudioSource *QPulseAudioDevices::createAudioSource(const QAudioDevice &deviceInfo, |
| 42 | const QAudioFormat &fmt, |
| 43 | QObject *parent) |
| 44 | { |
| 45 | return new QPulseAudioInternal::QPulseAudioSource(deviceInfo, fmt, parent); |
| 46 | } |
| 47 | |
| 48 | QPlatformAudioSink *QPulseAudioDevices::createAudioSink(const QAudioDevice &deviceInfo, |
| 49 | const QAudioFormat &fmt, |
| 50 | QObject *parent) |
| 51 | { |
| 52 | return new QPulseAudioInternal::QPulseAudioSink(deviceInfo, fmt, parent); |
| 53 | } |
| 54 | |
| 55 | QT_END_NAMESPACE |
| 56 | |