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 "qpulseaudiomediadevices_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 "qpulseaudiodevice_p.h"
11#include "qaudioengine_pulse_p.h"
12
13QT_BEGIN_NAMESPACE
14
15QPulseAudioMediaDevices::QPulseAudioMediaDevices()
16 : QPlatformMediaDevices()
17{
18 pulseEngine = new QPulseAudioEngine();
19
20 // TODO: it might make sense to connect device changing signals
21 // to each added QMediaDevices
22 QObject::connect(sender: pulseEngine, signal: &QPulseAudioEngine::audioInputsChanged,
23 context: this, slot: &QPulseAudioMediaDevices::audioInputsChanged, type: Qt::DirectConnection);
24 QObject::connect(sender: pulseEngine, signal: &QPulseAudioEngine::audioOutputsChanged,
25 context: this, slot: &QPulseAudioMediaDevices::audioOutputsChanged, type: Qt::DirectConnection);
26}
27
28QPulseAudioMediaDevices::~QPulseAudioMediaDevices()
29{
30 delete pulseEngine;
31}
32
33QList<QAudioDevice> QPulseAudioMediaDevices::audioInputs() const
34{
35 return pulseEngine->availableDevices(mode: QAudioDevice::Input);
36}
37
38QList<QAudioDevice> QPulseAudioMediaDevices::audioOutputs() const
39{
40 return pulseEngine->availableDevices(mode: QAudioDevice::Output);
41}
42
43QPlatformAudioSource *QPulseAudioMediaDevices::createAudioSource(const QAudioDevice &deviceInfo,
44 QObject *parent)
45{
46 return new QPulseAudioSource(deviceInfo.id(), parent);
47}
48
49QPlatformAudioSink *QPulseAudioMediaDevices::createAudioSink(const QAudioDevice &deviceInfo,
50 QObject *parent)
51{
52 return new QPulseAudioSink(deviceInfo.id(), parent);
53}
54
55QT_END_NAMESPACE
56

source code of qtmultimedia/src/multimedia/pulseaudio/qpulseaudiomediadevices.cpp