1 /* 2 * Strawberry Music Player 3 * This file was part of Clementine. 4 * Copyright 2014, David Sansome <me@davidsansome.com> 5 * Copyright 2017-2021, Jonas Kvinge <jonas@jkvinge.net> 6 * 7 * Strawberry is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * Strawberry is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with Strawberry. If not, see <http://www.gnu.org/licenses/>. 19 * 20 */ 21 22 #ifndef DEVICEFINDER_H 23 #define DEVICEFINDER_H 24 25 #include "config.h" 26 27 #include <QList> 28 #include <QVariant> 29 #include <QString> 30 31 // Finds audio output devices 32 class DeviceFinder { 33 34 public: 35 struct Device { 36 Device() : card(0), device(0) {} 37 QString description; 38 QVariant value; 39 QString iconname; 40 int card; 41 int device; 42 }; 43 44 virtual ~DeviceFinder() {} 45 46 QString name() const { return name_; } 47 QStringList outputs() const { return outputs_; } 48 void add_output(const QString &output) { outputs_.append(output); } 49 50 // Does any necessary setup, returning false if this DeviceFinder cannot be used. 51 virtual bool Initialize() = 0; 52 53 // Returns a list of available devices. 54 virtual QList<Device> ListDevices() = 0; 55 56 protected: 57 explicit DeviceFinder(const QString &name, const QStringList &outputs); 58 59 static QString GuessIconName(const QString &description); 60 61 private: 62 QString name_; 63 QStringList outputs_; 64 65 Q_DISABLE_COPY(DeviceFinder) 66 }; 67 68 #endif // DEVICEFINDER_H 69