[112] | 1 | /* smplayer, GUI front-end for mplayer.
|
---|
[188] | 2 | Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
[112] | 3 |
|
---|
| 4 | This program is free software; you can redistribute it and/or modify
|
---|
| 5 | it under the terms of the GNU General Public License as published by
|
---|
| 6 | the Free Software Foundation; either version 2 of the License, or
|
---|
| 7 | (at your option) any later version.
|
---|
| 8 |
|
---|
| 9 | This program is distributed in the hope that it will be useful,
|
---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 12 | GNU General Public License for more details.
|
---|
| 13 |
|
---|
| 14 | You should have received a copy of the GNU General Public License
|
---|
| 15 | along with this program; if not, write to the Free Software
|
---|
| 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 17 | */
|
---|
| 18 |
|
---|
[176] | 19 | #ifndef DEVICEINFO_H
|
---|
| 20 | #define DEVICEINFO_H
|
---|
[112] | 21 |
|
---|
| 22 | #include <QString>
|
---|
| 23 | #include <QVariant>
|
---|
| 24 | #include <QList>
|
---|
| 25 |
|
---|
[188] | 26 | #ifdef Q_OS_WIN
|
---|
| 27 | #define USE_DSOUND_DEVICES 1
|
---|
| 28 | #define USE_MPV_WASAPI_DEVICES 1
|
---|
[189] | 29 | #elif defined(Q_OS_OS2)
|
---|
| 30 | #define USE_ALSA_DEVICES 1
|
---|
| 31 | #define USE_MPV_ALSA_DEVICES 0
|
---|
| 32 | #define USE_PULSEAUDIO_DEVICES 0
|
---|
| 33 | #define USE_XV_ADAPTORS 0
|
---|
[188] | 34 | #else
|
---|
| 35 | #define USE_ALSA_DEVICES 0
|
---|
| 36 | #define USE_MPV_ALSA_DEVICES 0
|
---|
| 37 | #define USE_PULSEAUDIO_DEVICES 1
|
---|
| 38 | #define USE_XV_ADAPTORS 1
|
---|
| 39 | #endif
|
---|
| 40 |
|
---|
| 41 | #if defined(USE_MPV_ALSA_DEVICES) || defined(USE_MPV_WASAPI_DEVICES)
|
---|
| 42 | #define MPV_AUDIO_DEVICES 1
|
---|
| 43 | #endif
|
---|
| 44 |
|
---|
[181] | 45 | #ifndef Q_OS_WIN
|
---|
| 46 | #define CACHE_DEVICE_INFO
|
---|
| 47 | #endif
|
---|
| 48 |
|
---|
[176] | 49 | class QSettings;
|
---|
| 50 |
|
---|
[112] | 51 | class DeviceData {
|
---|
| 52 |
|
---|
| 53 | public:
|
---|
| 54 | DeviceData() {};
|
---|
| 55 | DeviceData(QVariant ID, QString desc) { _id = ID; _desc = desc; };
|
---|
| 56 | ~DeviceData() {};
|
---|
| 57 |
|
---|
| 58 | void setID(QVariant ID) { _id = ID; };
|
---|
| 59 | void setDesc(QString desc) { _desc = desc; };
|
---|
| 60 |
|
---|
[176] | 61 | QVariant ID() const { return _id; };
|
---|
| 62 | QString desc() const { return _desc; };
|
---|
[112] | 63 |
|
---|
| 64 | private:
|
---|
| 65 | QVariant _id;
|
---|
| 66 | QString _desc;
|
---|
| 67 | };
|
---|
| 68 |
|
---|
| 69 |
|
---|
| 70 | typedef QList<DeviceData> DeviceList;
|
---|
| 71 |
|
---|
| 72 |
|
---|
| 73 | class DeviceInfo {
|
---|
| 74 |
|
---|
| 75 | public:
|
---|
| 76 | #ifdef Q_OS_WIN
|
---|
| 77 | static DeviceList dsoundDevices();
|
---|
| 78 | static DeviceList displayDevices();
|
---|
| 79 | #else
|
---|
[188] | 80 | #if USE_PULSEAUDIO_DEVICES
|
---|
| 81 | static DeviceList paDevices();
|
---|
| 82 | #endif
|
---|
| 83 | #if USE_ALSA_DEVICES
|
---|
[112] | 84 | static DeviceList alsaDevices();
|
---|
[188] | 85 | #endif
|
---|
| 86 | #if USE_XV_ADAPTORS
|
---|
[112] | 87 | static DeviceList xvAdaptors();
|
---|
[188] | 88 | #endif
|
---|
[112] | 89 | #endif
|
---|
| 90 |
|
---|
[188] | 91 | #if MPV_AUDIO_DEVICES
|
---|
| 92 | static void setMpvBin(const QString & bin) { mpv_bin = bin; };
|
---|
| 93 |
|
---|
| 94 | #if USE_MPV_ALSA_DEVICES
|
---|
| 95 | static DeviceList mpvAlsaDevices();
|
---|
| 96 | #endif
|
---|
| 97 |
|
---|
| 98 | #if USE_MPV_WASAPI_DEVICES
|
---|
| 99 | static DeviceList mpvWasapiDevices();
|
---|
| 100 | #endif
|
---|
| 101 |
|
---|
| 102 | static DeviceList mpvAudioDevices(const QString & mpv_bin, const QString & filter);
|
---|
| 103 | static DeviceList mpvAudioDevices(const QString & filter);
|
---|
| 104 | #endif
|
---|
| 105 |
|
---|
| 106 | static QString printableName(const QString & driver_name, const DeviceData & device);
|
---|
| 107 | static QString internalName(const QString & driver_name, const DeviceData & device);
|
---|
| 108 |
|
---|
| 109 | static QString printableName(const QString & driver_name, const QString & id, const QString & desc);
|
---|
| 110 | static QString internalName(const QString & driver_name, const QString & id, const QString & desc);
|
---|
| 111 | static QStringList extractDevice(const QString & internal_name);
|
---|
| 112 |
|
---|
[112] | 113 | protected:
|
---|
[181] | 114 | #ifdef CACHE_DEVICE_INFO
|
---|
[176] | 115 | static void saveList(QSettings * set, const QString & section_name, const DeviceList & list);
|
---|
| 116 | static DeviceList loadList(QSettings * set, const QString & section_name);
|
---|
[181] | 117 | #endif
|
---|
[176] | 118 |
|
---|
[112] | 119 | #ifdef Q_OS_WIN
|
---|
| 120 | enum DeviceType { Sound = 0, Display = 1 };
|
---|
| 121 |
|
---|
| 122 | static DeviceList retrieveDevices(DeviceType type);
|
---|
| 123 | #endif
|
---|
[188] | 124 |
|
---|
| 125 | #if MPV_AUDIO_DEVICES
|
---|
| 126 | static QString mpv_bin;
|
---|
| 127 | #endif
|
---|
[112] | 128 | };
|
---|
| 129 |
|
---|
| 130 | #endif
|
---|
| 131 |
|
---|