mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-16 05:11:49 -05:00
New audio devices dialog and handling: make settings persistent using main settings
This commit is contained in:
parent
58b90c7914
commit
fb3e6dc90d
@ -1,6 +1,6 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
|
// Copyright (C) 2017 F4EXB //
|
||||||
// written by Christian Daniel //
|
// written by Edouard Griffiths //
|
||||||
// //
|
// //
|
||||||
// This program is free software; you can redistribute it and/or modify //
|
// 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 //
|
// it under the terms of the GNU General Public License as published by //
|
||||||
@ -16,12 +16,52 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "audio/audiodeviceinfo.h"
|
#include "audio/audiodeviceinfo.h"
|
||||||
|
#include "util/simpleserializer.h"
|
||||||
|
|
||||||
AudioDeviceInfo::AudioDeviceInfo() :
|
AudioDeviceInfo::AudioDeviceInfo() :
|
||||||
m_inputDeviceIndex(-1), // default device
|
m_inputDeviceIndex(-1), // default device
|
||||||
m_outputDeviceIndex(-1), // default device
|
m_outputDeviceIndex(-1), // default device
|
||||||
m_inputVolume(0.5f)
|
m_inputVolume(1.0f)
|
||||||
{
|
{
|
||||||
m_inputDevicesInfo = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
|
m_inputDevicesInfo = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
|
||||||
m_outputDevicesInfo = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
m_outputDevicesInfo = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioDeviceInfo::resetToDefaults()
|
||||||
|
{
|
||||||
|
m_inputDeviceIndex = -1;
|
||||||
|
m_outputDeviceIndex = -1;
|
||||||
|
m_inputVolume = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray AudioDeviceInfo::serialize() const
|
||||||
|
{
|
||||||
|
SimpleSerializer s(1);
|
||||||
|
s.writeS32(1, m_inputDeviceIndex);
|
||||||
|
s.writeS32(2, m_outputDeviceIndex);
|
||||||
|
s.writeFloat(3, m_inputVolume);
|
||||||
|
return s.final();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AudioDeviceInfo::deserialize(const QByteArray& data)
|
||||||
|
{
|
||||||
|
SimpleDeserializer d(data);
|
||||||
|
|
||||||
|
if(!d.isValid()) {
|
||||||
|
resetToDefaults();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(d.getVersion() == 1)
|
||||||
|
{
|
||||||
|
d.readS32(1, &m_inputDeviceIndex, -1);
|
||||||
|
d.readS32(2, &m_outputDeviceIndex, -1);
|
||||||
|
d.readFloat(3, &m_inputVolume, 1.0f);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
resetToDefaults();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
|
// Copyright (C) 2017 F4EXB //
|
||||||
// written by Christian Daniel //
|
// written by Edouard Griffiths //
|
||||||
// //
|
// //
|
||||||
// This program is free software; you can redistribute it and/or modify //
|
// 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 //
|
// it under the terms of the GNU General Public License as published by //
|
||||||
@ -35,13 +35,18 @@ public:
|
|||||||
float getInputVolume() const { return m_inputVolume; }
|
float getInputVolume() const { return m_inputVolume; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QAudioDeviceInfo> m_inputDevicesInfo = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
|
QList<QAudioDeviceInfo> m_inputDevicesInfo;
|
||||||
QList<QAudioDeviceInfo> m_outputDevicesInfo = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
|
QList<QAudioDeviceInfo> m_outputDevicesInfo;
|
||||||
int m_inputDeviceIndex;
|
int m_inputDeviceIndex;
|
||||||
int m_outputDeviceIndex;
|
int m_outputDeviceIndex;
|
||||||
float m_inputVolume;
|
float m_inputVolume;
|
||||||
|
|
||||||
|
void resetToDefaults();
|
||||||
|
QByteArray serialize() const;
|
||||||
|
bool deserialize(const QByteArray& data);
|
||||||
|
|
||||||
friend class AudioDialog;
|
friend class AudioDialog;
|
||||||
|
friend class MainSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INCLUDE_AUDIODEVICEINFO_H
|
#endif // INCLUDE_AUDIODEVICEINFO_H
|
||||||
|
@ -69,6 +69,8 @@ MainWindow::MainWindow(QWidget* parent) :
|
|||||||
{
|
{
|
||||||
qDebug() << "MainWindow::MainWindow: start";
|
qDebug() << "MainWindow::MainWindow: start";
|
||||||
|
|
||||||
|
m_settings.setAudioDeviceInfo(m_audioDeviceInfo);
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
createStatusBar();
|
createStatusBar();
|
||||||
|
|
||||||
|
@ -23,6 +23,11 @@ void MainSettings::load()
|
|||||||
m_preferences.deserialize(qUncompress(QByteArray::fromBase64(s.value("preferences").toByteArray())));
|
m_preferences.deserialize(qUncompress(QByteArray::fromBase64(s.value("preferences").toByteArray())));
|
||||||
m_workingPreset.deserialize(qUncompress(QByteArray::fromBase64(s.value("current").toByteArray())));
|
m_workingPreset.deserialize(qUncompress(QByteArray::fromBase64(s.value("current").toByteArray())));
|
||||||
|
|
||||||
|
if (m_audioDeviceInfo)
|
||||||
|
{
|
||||||
|
m_audioDeviceInfo->deserialize(qUncompress(QByteArray::fromBase64(s.value("audio").toByteArray())));
|
||||||
|
}
|
||||||
|
|
||||||
QStringList groups = s.childGroups();
|
QStringList groups = s.childGroups();
|
||||||
|
|
||||||
for(int i = 0; i < groups.size(); ++i)
|
for(int i = 0; i < groups.size(); ++i)
|
||||||
@ -53,6 +58,11 @@ void MainSettings::save() const
|
|||||||
s.setValue("preferences", qCompress(m_preferences.serialize()).toBase64());
|
s.setValue("preferences", qCompress(m_preferences.serialize()).toBase64());
|
||||||
s.setValue("current", qCompress(m_workingPreset.serialize()).toBase64());
|
s.setValue("current", qCompress(m_workingPreset.serialize()).toBase64());
|
||||||
|
|
||||||
|
if (m_audioDeviceInfo)
|
||||||
|
{
|
||||||
|
s.setValue("audio", qCompress(m_audioDeviceInfo->serialize()).toBase64());
|
||||||
|
}
|
||||||
|
|
||||||
QStringList groups = s.childGroups();
|
QStringList groups = s.childGroups();
|
||||||
|
|
||||||
for(int i = 0; i < groups.size(); ++i)
|
for(int i = 0; i < groups.size(); ++i)
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
#include "preset.h"
|
#include "preset.h"
|
||||||
|
#include "audio/audiodeviceinfo.h"
|
||||||
|
|
||||||
class MainSettings {
|
class MainSettings {
|
||||||
public:
|
public:
|
||||||
@ -30,8 +31,12 @@ public:
|
|||||||
float getLatitude() const { return m_preferences.getLatitude(); }
|
float getLatitude() const { return m_preferences.getLatitude(); }
|
||||||
float getLongitude() const { return m_preferences.getLongitude(); }
|
float getLongitude() const { return m_preferences.getLongitude(); }
|
||||||
|
|
||||||
|
const AudioDeviceInfo *getAudioDeviceInfo() const { return m_audioDeviceInfo; }
|
||||||
|
void setAudioDeviceInfo(AudioDeviceInfo *audioDeviceInfo) { m_audioDeviceInfo = audioDeviceInfo; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Preferences m_preferences;
|
Preferences m_preferences;
|
||||||
|
AudioDeviceInfo *m_audioDeviceInfo;
|
||||||
Preset m_workingPreset;
|
Preset m_workingPreset;
|
||||||
typedef QList<Preset*> Presets;
|
typedef QList<Preset*> Presets;
|
||||||
Presets m_presets;
|
Presets m_presets;
|
||||||
|
Loading…
Reference in New Issue
Block a user