1 /* -*- c++ -*- */
2 /*
3  * Gqrx SDR: Software defined radio receiver powered by GNU Radio and Qt
4  *           https://gqrx.dk/
5  *
6  * Copyright 2011-2014 Alexandru Csete OZ9AEC.
7  *
8  * Gqrx is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3, or (at your option)
11  * any later version.
12  *
13  * Gqrx is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Gqrx; see the file COPYING.  If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street,
21  * Boston, MA 02110-1301, USA.
22  */
23 #ifndef IOCONFIG_H
24 #define IOCONFIG_H
25 
26 #include <QDialog>
27 #include <QSettings>
28 #include <QString>
29 
30 #ifdef WITH_PULSEAUDIO
31 #include "pulseaudio/pa_device_list.h"
32 #elif WITH_PORTAUDIO
33 #include "portaudio/device_list.h"
34 #elif defined(Q_OS_DARWIN)
35 #include "osxaudio/device_list.h"
36 #endif
37 
38 
39 namespace Ui {
40     class CIoConfig;
41 }
42 
43 /** @brief Inout/output device configurator. */
44 class CIoConfig : public QDialog
45 {
46     Q_OBJECT
47 
48 public:
49     explicit CIoConfig(QSettings *settings, std::map<QString, QVariant> &devList, QWidget *parent = 0);
50     virtual ~CIoConfig();
51     static void getDeviceList(std::map<QString, QVariant> &devList);
52 
53 private slots:
54     void saveConfig();
55     void inputDeviceSelected(int index);
56     void inputDevstrChanged(const QString &text);
57     void inputRateChanged(const QString &text);
58     void decimationChanged(int index);
59     void onScanButtonClicked();
60 
61 private:
62     void updateInputSampleRates(int rate);
63     void updateDecimations(void);
64     void updateInDev(const QSettings *settings, const std::map<QString, QVariant> &devList);
65     void updateOutDev();
66     int  idx2decim(int idx) const;
67     int  decim2idx(int decim) const;
68 
69 private:
70     Ui::CIoConfig  *ui;
71     QSettings      *m_settings;
72     QPushButton    *m_scanButton;
73     std::map<QString, QVariant> *m_devList; // will point to devList from constructor
74 
75 #ifdef WITH_PULSEAUDIO
76     vector<pa_device>           outDevList;
77 #elif WITH_PORTAUDIO
78     vector<portaudio_device>    outDevList;
79 #elif defined(Q_OS_DARWIN)
80     vector<osxaudio_device>     outDevList;
81 #endif
82 
83 };
84 
85 #endif // IOCONFIG_H
86