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:
Roland Winklmeier
2017-04-23 16:02:27 +02:00
committed by Mathew Sutcliffe
parent f0bfad40b7
commit 862794cb02
3 changed files with 59 additions and 0 deletions

View File

@@ -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;