source: smplayer/trunk/src/deviceinfo.h

Last change on this file was 189, checked in by Silvan Scherrer, 8 years ago

SMPlayer: adjust version info in readme and some small glitches

  • Property svn:eol-style set to LF
File size: 3.3 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
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
19#ifndef DEVICEINFO_H
20#define DEVICEINFO_H
21
22#include <QString>
23#include <QVariant>
24#include <QList>
25
26#ifdef Q_OS_WIN
27#define USE_DSOUND_DEVICES 1
28#define USE_MPV_WASAPI_DEVICES 1
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
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
45#ifndef Q_OS_WIN
46#define CACHE_DEVICE_INFO
47#endif
48
49class QSettings;
50
51class DeviceData {
52
53public:
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
61 QVariant ID() const { return _id; };
62 QString desc() const { return _desc; };
63
64private:
65 QVariant _id;
66 QString _desc;
67};
68
69
70typedef QList<DeviceData> DeviceList;
71
72
73class DeviceInfo {
74
75public:
76#ifdef Q_OS_WIN
77 static DeviceList dsoundDevices();
78 static DeviceList displayDevices();
79#else
80 #if USE_PULSEAUDIO_DEVICES
81 static DeviceList paDevices();
82 #endif
83 #if USE_ALSA_DEVICES
84 static DeviceList alsaDevices();
85 #endif
86 #if USE_XV_ADAPTORS
87 static DeviceList xvAdaptors();
88 #endif
89#endif
90
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
113protected:
114#ifdef CACHE_DEVICE_INFO
115 static void saveList(QSettings * set, const QString & section_name, const DeviceList & list);
116 static DeviceList loadList(QSettings * set, const QString & section_name);
117#endif
118
119#ifdef Q_OS_WIN
120 enum DeviceType { Sound = 0, Display = 1 };
121
122 static DeviceList retrieveDevices(DeviceType type);
123#endif
124
125#if MPV_AUDIO_DEVICES
126 static QString mpv_bin;
127#endif
128};
129
130#endif
131
Note: See TracBrowser for help on using the repository browser.