mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Add audio device settings
Summary: Up to now, the audio device settings were not persistent. With this commit, the last audio device will be restored after application start. Reviewers: kbasan, msutcliffe Reviewed By: msutcliffe Differential Revision: https://dev.swift-project.org/D7
This commit is contained in:
committed by
Mathew Sutcliffe
parent
f0bfad40b7
commit
862794cb02
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "blackmisc/settingscache.h"
|
||||
#include "blackmisc/audio/audiosettings.h"
|
||||
#include <QString>
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
@@ -28,6 +29,21 @@ namespace BlackCore
|
||||
//! \copydoc BlackMisc::TSettingTrait::isValid
|
||||
static bool isValid(const BlackMisc::Audio::CSettings &value) { Q_UNUSED(value); return true; }
|
||||
};
|
||||
|
||||
//! Audio input device settings
|
||||
struct TInputDevice : public BlackMisc::TSettingTrait<QString>
|
||||
{
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "audio/inputdevice"; }
|
||||
};
|
||||
|
||||
//! Audio input device settings
|
||||
struct TOutputDevice : public BlackMisc::TSettingTrait<QString>
|
||||
{
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "audio/outputdevice"; }
|
||||
};
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
|
||||
@@ -88,6 +88,8 @@ namespace BlackCore
|
||||
m_unusedVoiceChannels.push_back(m_channel2);
|
||||
|
||||
m_selcalPlayer = new CSelcalPlayer(QAudioDeviceInfo::defaultOutputDevice(), this);
|
||||
|
||||
changeDeviceSettings();
|
||||
}
|
||||
|
||||
CContextAudio *CContextAudio::registerWithDBus(CDBusServer *server)
|
||||
@@ -207,6 +209,10 @@ namespace BlackCore
|
||||
this->m_voiceInputDevice->setInputDevice(audioDevice);
|
||||
changed = true;
|
||||
}
|
||||
if (m_inputDeviceSetting.get() != audioDevice.getName())
|
||||
{
|
||||
m_inputDeviceSetting.set(audioDevice.getName());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -215,6 +221,10 @@ namespace BlackCore
|
||||
this->m_voiceOutputDevice->setOutputDevice(audioDevice);
|
||||
changed = true;
|
||||
}
|
||||
if (m_outputDeviceSetting.get() != audioDevice.getName())
|
||||
{
|
||||
m_outputDeviceSetting.set(audioDevice.getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (changed)
|
||||
@@ -549,6 +559,35 @@ namespace BlackCore
|
||||
emit this->changedVoiceRoomMembers();
|
||||
}
|
||||
|
||||
void CContextAudio::changeDeviceSettings()
|
||||
{
|
||||
QString inputDeviceName = m_inputDeviceSetting.get();
|
||||
if (!inputDeviceName.isEmpty())
|
||||
{
|
||||
for (auto device : m_voiceInputDevice->getInputDevices())
|
||||
{
|
||||
if (device.getName() == inputDeviceName)
|
||||
{
|
||||
setCurrentAudioDevice(device);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString outputDeviceName = m_outputDeviceSetting.get();
|
||||
if (!outputDeviceName.isEmpty())
|
||||
{
|
||||
for (auto device : m_voiceOutputDevice->getOutputDevices())
|
||||
{
|
||||
if (device.getName() == outputDeviceName)
|
||||
{
|
||||
setCurrentAudioDevice(device);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QSharedPointer<IVoiceChannel> CContextAudio::getVoiceChannelBy(const CVoiceRoom &voiceRoom)
|
||||
{
|
||||
QSharedPointer<IVoiceChannel> voiceChannel;
|
||||
|
||||
@@ -134,6 +134,8 @@ namespace BlackCore
|
||||
//! Connection in transition
|
||||
bool inTransitionState() const;
|
||||
|
||||
void changeDeviceSettings();
|
||||
|
||||
//! Voice channel by room
|
||||
QSharedPointer<IVoiceChannel> getVoiceChannelBy(const BlackMisc::Audio::CVoiceRoom &voiceRoom);
|
||||
|
||||
@@ -156,6 +158,8 @@ namespace BlackCore
|
||||
|
||||
// settings
|
||||
BlackMisc::CSetting<BlackCore::Audio::TSettings> m_audioSettings { this };
|
||||
BlackMisc::CSetting<BlackCore::Audio::TInputDevice> m_inputDeviceSetting { this, &CContextAudio::changeDeviceSettings };
|
||||
BlackMisc::CSetting<BlackCore::Audio::TOutputDevice> m_outputDeviceSetting { this, &CContextAudio::changeDeviceSettings };
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user