2017-11-24 11:12:53 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2017 F4EXB //
|
|
|
|
// written by Edouard Griffiths //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-03-23 13:08:38 -04:00
|
|
|
#ifndef INCLUDE_AUDIODEVICEMANGER_H
|
|
|
|
#define INCLUDE_AUDIODEVICEMANGER_H
|
2017-11-24 11:12:53 -05:00
|
|
|
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QList>
|
|
|
|
#include <QAudioDeviceInfo>
|
|
|
|
|
2018-03-23 12:52:16 -04:00
|
|
|
#include "audio/audioinput.h"
|
|
|
|
#include "audio/audiooutput.h"
|
2018-03-20 08:49:21 -04:00
|
|
|
#include "export.h"
|
2017-11-24 11:12:53 -05:00
|
|
|
|
2018-03-23 12:52:16 -04:00
|
|
|
class AudioFifo;
|
|
|
|
|
2018-03-23 13:08:38 -04:00
|
|
|
class SDRBASE_API AudioDeviceManager {
|
2017-11-24 11:12:53 -05:00
|
|
|
public:
|
2018-03-23 13:08:38 -04:00
|
|
|
AudioDeviceManager();
|
2017-11-24 11:12:53 -05:00
|
|
|
|
|
|
|
const QList<QAudioDeviceInfo>& getInputDevices() const { return m_inputDevicesInfo; }
|
|
|
|
const QList<QAudioDeviceInfo>& getOutputDevices() const { return m_outputDevicesInfo; }
|
2018-03-23 12:52:16 -04:00
|
|
|
|
2017-11-24 11:12:53 -05:00
|
|
|
int getInputDeviceIndex() const { return m_inputDeviceIndex; }
|
|
|
|
int getOutputDeviceIndex() const { return m_outputDeviceIndex; }
|
|
|
|
float getInputVolume() const { return m_inputVolume; }
|
2018-03-23 12:52:16 -04:00
|
|
|
|
2017-11-24 11:12:53 -05:00
|
|
|
void setInputDeviceIndex(int inputDeviceIndex);
|
|
|
|
void setOutputDeviceIndex(int inputDeviceIndex);
|
|
|
|
void setInputVolume(float inputVolume);
|
|
|
|
|
2018-03-23 12:52:16 -04:00
|
|
|
unsigned int getAudioSampleRate() const { return m_audioOutputSampleRate; }
|
|
|
|
|
|
|
|
void addAudioSink(AudioFifo* audioFifo); //!< Add the audio sink
|
|
|
|
void removeAudioSink(AudioFifo* audioFifo); //!< Remove the audio sink
|
|
|
|
|
|
|
|
void addAudioSource(AudioFifo* audioFifo); //!< Add an audio source
|
|
|
|
void removeAudioSource(AudioFifo* audioFifo); //!< Remove an audio source
|
|
|
|
|
|
|
|
void startAudioOutput();
|
|
|
|
void stopAudioOutput();
|
|
|
|
void startAudioOutputImmediate();
|
|
|
|
void stopAudioOutputImmediate();
|
|
|
|
|
|
|
|
void startAudioInput();
|
|
|
|
void stopAudioInput();
|
|
|
|
void startAudioInputImmediate();
|
|
|
|
void stopAudioInputImmediate();
|
|
|
|
void setAudioInputVolume(float volume) { m_audioInput.setVolume(volume); }
|
|
|
|
|
2017-11-24 11:12:53 -05:00
|
|
|
private:
|
|
|
|
QList<QAudioDeviceInfo> m_inputDevicesInfo;
|
|
|
|
QList<QAudioDeviceInfo> m_outputDevicesInfo;
|
|
|
|
int m_inputDeviceIndex;
|
|
|
|
int m_outputDeviceIndex;
|
2018-03-23 12:52:16 -04:00
|
|
|
unsigned int m_audioOutputSampleRate;
|
|
|
|
unsigned int m_audioInputSampleRate;
|
|
|
|
AudioOutput m_audioOutput;
|
|
|
|
AudioInput m_audioInput;
|
2017-11-24 11:12:53 -05:00
|
|
|
float m_inputVolume;
|
|
|
|
|
|
|
|
void resetToDefaults();
|
|
|
|
QByteArray serialize() const;
|
|
|
|
bool deserialize(const QByteArray& data);
|
|
|
|
|
|
|
|
friend class AudioDialog;
|
|
|
|
friend class MainSettings;
|
|
|
|
};
|
|
|
|
|
2018-03-23 13:08:38 -04:00
|
|
|
#endif // INCLUDE_AUDIODEVICEMANGER_H
|