File: audiodevices.h

package info (click to toggle)
wfview 2.11-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,256 kB
  • sloc: cpp: 43,386; ansic: 3,196; sh: 32; xml: 29; makefile: 11
file content (106 lines) | stat: -rw-r--r-- 2,899 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef AUDIODEVICES_H
#define AUDIODEVICES_H
#include <QObject>

#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
#include <QAudioDeviceInfo>
#else
#include <QMediaDevices>
#include <QAudioDevice>
#include <QString>
#endif

#include <QFontMetrics>

#include <portaudio.h>
#ifndef Q_OS_LINUX
#include "RtAudio.h"
#else
#include "rtaudio/RtAudio.h"
#endif

#include "wfviewtypes.h"


struct audioDevice {
    audioDevice(QString name, int deviceInt, bool isDefault) : name(name), deviceInt(deviceInt), isDefault(isDefault) {};

#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
    audioDevice(QString name, const QAudioDeviceInfo deviceInfo, QString realm, bool isDefault) : name(name), deviceInfo(deviceInfo), realm(realm), isDefault(isDefault) {};
#else
    audioDevice(QString name, QAudioDevice deviceInfo, QString realm, bool isDefault) : name(name), deviceInfo(deviceInfo), realm(realm), isDefault(isDefault) {};
#endif

    QString name;
    int deviceInt;

#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
    const QAudioDeviceInfo deviceInfo;
#else
    QAudioDevice deviceInfo;
#endif

    QString realm;
    bool isDefault;
};

class audioDevices : public QObject
{
    Q_OBJECT

public:
    explicit audioDevices(audioType type, QFontMetrics fm, QObject* parent = nullptr);
    ~audioDevices();
    void setAudioType(audioType type) { system = type; };
    audioType getAudioType() { return system; };
    int getNumCharsIn() { return numCharsIn; };
    int getNumCharsOut() { return numCharsOut; };

    QString getInputName(int num) { return inputs[num]->name; };
    QString getOutputName(int num) { return outputs[num]->name; };

    int getInputDeviceInt(int num) { return inputs[num]->deviceInt; };
    int getOutputDeviceInt(int num) { return outputs[num]->deviceInt; };

#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
    const QAudioDeviceInfo getInputDeviceInfo(int num) { return inputs[num]->deviceInfo; };
    const QAudioDeviceInfo getOutputDeviceInfo(int num) { return outputs[num]->deviceInfo; };
#else
    const QAudioDevice getInputDeviceInfo(int num) { return inputs[num]->deviceInfo; };
    const QAudioDevice getOutputDeviceInfo(int num) { return outputs[num]->deviceInfo; };
#endif

    void enumerate();

    QStringList getInputs();
    QStringList getOutputs();

    int findInput(QString type, QString name, bool ignoreDefault=false);
    int findOutput(QString type, QString name, bool ignoreDefault=false);

#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
    QMediaDevices mediaDevices;
#endif

public slots:

signals:
    void updated();
protected:
private:

    audioType system;
    QFontMetrics fm;
    QString defaultInputDeviceName;
    QString defaultOutputDeviceName;
    int numInputDevices;
    int numOutputDevices;
    QList<audioDevice*> inputs;
    QList<audioDevice*> outputs;
    int numCharsIn = 0;
    int numCharsOut = 0;
    QString audioApi = "wasapi";

};

#endif