Add audio profiles to new settings object API
Audio profiles are not currently activated due to SteamVR changes. micVol has been changed to default initilize to 1.0f since that was being applied in the settings load anyway.
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include "../overlaycontroller.h"
|
#include "../overlaycontroller.h"
|
||||||
#include "../settings/settings.h"
|
#include "../settings/settings.h"
|
||||||
|
#include "../settings/settings_object.h"
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# include "audiomanager/AudioManagerWindows.h"
|
# include "audiomanager/AudioManagerWindows.h"
|
||||||
#else
|
#else
|
||||||
@@ -672,111 +673,14 @@ void AudioTabController::findMicDeviceIndex( std::string id, bool notify )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*AUDIO PROFILE FUNCTIONS
|
|
||||||
The following section includes the code required to save and load Audio
|
|
||||||
Profiles.
|
|
||||||
|
|
||||||
Saved Settings Include:
|
|
||||||
Playback Device
|
|
||||||
Mirror Device
|
|
||||||
Mirror Vol
|
|
||||||
Microphone
|
|
||||||
Microphone Volume
|
|
||||||
Profile Name
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Name: reloadAudioProfiles
|
|
||||||
|
|
||||||
Inputs: args: none
|
|
||||||
other: Reads audioProfiles setting from file
|
|
||||||
|
|
||||||
|
|
||||||
Output: return:none
|
|
||||||
other:none
|
|
||||||
|
|
||||||
Description: Clears working copy, and reloads from Settings file.
|
|
||||||
|
|
||||||
*/
|
|
||||||
void AudioTabController::reloadAudioProfiles()
|
void AudioTabController::reloadAudioProfiles()
|
||||||
{
|
{
|
||||||
audioProfiles.clear();
|
settings::loadAllObjects( audioProfiles );
|
||||||
auto settings = OverlayController::appSettings();
|
|
||||||
settings->beginGroup( getSettingsName() );
|
|
||||||
auto profileCount = settings->beginReadArray( "audioProfiles" );
|
|
||||||
for ( int i = 0; i < profileCount; i++ )
|
|
||||||
{
|
|
||||||
settings->setArrayIndex( i );
|
|
||||||
audioProfiles.emplace_back();
|
|
||||||
auto& entry = audioProfiles[static_cast<size_t>( i )];
|
|
||||||
entry.profileName
|
|
||||||
= settings->value( "profileName" ).toString().toStdString();
|
|
||||||
entry.playbackName
|
|
||||||
= settings->value( "playbackName" ).toString().toStdString();
|
|
||||||
entry.micName = settings->value( "micName" ).toString().toStdString();
|
|
||||||
entry.mirrorName
|
|
||||||
= settings->value( "mirrorName" ).toString().toStdString();
|
|
||||||
entry.micMute = settings->value( "micMute", false ).toBool();
|
|
||||||
entry.mirrorMute = settings->value( "mirrorMute", false ).toBool();
|
|
||||||
entry.mirrorVol = settings->value( "mirrorVol", 0.0 ).toFloat();
|
|
||||||
entry.micVol = settings->value( "micVol", 1.0 ).toFloat();
|
|
||||||
entry.defaultProfile
|
|
||||||
= settings->value( "defaultProfile", false ).toBool();
|
|
||||||
entry.mirrorID = settings->value( "mirrorID" ).toString().toStdString();
|
|
||||||
entry.recordingID
|
|
||||||
= settings->value( "recordingID" ).toString().toStdString();
|
|
||||||
entry.playbackID
|
|
||||||
= settings->value( "playbackID" ).toString().toStdString();
|
|
||||||
}
|
|
||||||
settings->endArray();
|
|
||||||
settings->endGroup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Name: saveAudioProfile
|
|
||||||
|
|
||||||
Inputs: args: none
|
|
||||||
other: none
|
|
||||||
|
|
||||||
|
|
||||||
Output: return: none
|
|
||||||
other: Writes audioProfiles setting to file
|
|
||||||
|
|
||||||
Description: saves a copy of the audio profiles from working to Settings file.
|
|
||||||
|
|
||||||
*/
|
|
||||||
void AudioTabController::saveAudioProfiles()
|
void AudioTabController::saveAudioProfiles()
|
||||||
{
|
{
|
||||||
auto settings = OverlayController::appSettings();
|
settings::saveAllObjects( audioProfiles );
|
||||||
settings->beginGroup( getSettingsName() );
|
|
||||||
settings->beginWriteArray( "audioProfiles" );
|
|
||||||
int i = 0;
|
|
||||||
for ( auto& p : audioProfiles )
|
|
||||||
{
|
|
||||||
settings->setArrayIndex( i );
|
|
||||||
settings->setValue( "profileName",
|
|
||||||
QString::fromStdString( p.profileName ) );
|
|
||||||
settings->setValue( "playbackName",
|
|
||||||
QString::fromStdString( p.playbackName ) );
|
|
||||||
settings->setValue( "micName", QString::fromStdString( p.micName ) );
|
|
||||||
settings->setValue( "mirrorName",
|
|
||||||
QString::fromStdString( p.mirrorName ) );
|
|
||||||
settings->setValue( "micMute", p.micMute );
|
|
||||||
settings->setValue( "mirrorMute", p.mirrorMute );
|
|
||||||
settings->setValue( "micVol", p.micVol );
|
|
||||||
settings->setValue( "mirrorVol", p.mirrorVol );
|
|
||||||
settings->setValue( "defaultProfile", p.defaultProfile );
|
|
||||||
|
|
||||||
settings->setValue( "playbackID",
|
|
||||||
QString::fromStdString( p.playbackID ) );
|
|
||||||
settings->setValue( "mirrorID", QString::fromStdString( p.mirrorID ) );
|
|
||||||
settings->setValue( "recordingID",
|
|
||||||
QString::fromStdString( p.recordingID ) );
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
settings->endArray();
|
|
||||||
settings->endGroup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -838,7 +742,6 @@ void AudioTabController::addAudioProfile( QString name )
|
|||||||
setAudioProfileDefault( false );
|
setAudioProfileDefault( false );
|
||||||
}
|
}
|
||||||
saveAudioProfiles();
|
saveAudioProfiles();
|
||||||
OverlayController::appSettings()->sync();
|
|
||||||
emit audioProfilesUpdated();
|
emit audioProfilesUpdated();
|
||||||
emit audioProfileAdded();
|
emit audioProfileAdded();
|
||||||
}
|
}
|
||||||
@@ -949,7 +852,6 @@ void AudioTabController::deleteAudioProfile( unsigned index )
|
|||||||
}
|
}
|
||||||
audioProfiles.erase( pos );
|
audioProfiles.erase( pos );
|
||||||
saveAudioProfiles();
|
saveAudioProfiles();
|
||||||
OverlayController::appSettings()->sync();
|
|
||||||
emit audioProfilesUpdated();
|
emit audioProfilesUpdated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "audiomanager/AudioManager.h"
|
#include "audiomanager/AudioManager.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "../utils/FrameRateUtils.h"
|
#include "../utils/FrameRateUtils.h"
|
||||||
|
#include "../settings/settings_object.h"
|
||||||
|
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
// application namespace
|
// application namespace
|
||||||
@@ -14,7 +15,7 @@ namespace advsettings
|
|||||||
// forward declaration
|
// forward declaration
|
||||||
class OverlayController;
|
class OverlayController;
|
||||||
|
|
||||||
struct AudioProfile
|
struct AudioProfile : settings::ISettingsObject
|
||||||
{
|
{
|
||||||
std::string profileName;
|
std::string profileName;
|
||||||
std::string playbackName;
|
std::string playbackName;
|
||||||
@@ -24,10 +25,54 @@ struct AudioProfile
|
|||||||
std::string playbackID;
|
std::string playbackID;
|
||||||
std::string mirrorID;
|
std::string mirrorID;
|
||||||
float mirrorVol = 0.0;
|
float mirrorVol = 0.0;
|
||||||
float micVol = 0.0;
|
float micVol = 1.0;
|
||||||
bool micMute = false;
|
bool micMute = false;
|
||||||
bool mirrorMute = false;
|
bool mirrorMute = false;
|
||||||
bool defaultProfile = false;
|
bool defaultProfile = false;
|
||||||
|
|
||||||
|
virtual settings::SettingsObjectData saveSettings() const
|
||||||
|
{
|
||||||
|
settings::SettingsObjectData o;
|
||||||
|
|
||||||
|
o.addValue( profileName );
|
||||||
|
o.addValue( playbackName );
|
||||||
|
o.addValue( mirrorName );
|
||||||
|
o.addValue( micName );
|
||||||
|
o.addValue( recordingID );
|
||||||
|
o.addValue( playbackID );
|
||||||
|
o.addValue( mirrorID );
|
||||||
|
|
||||||
|
o.addValue( static_cast<double>( mirrorVol ) );
|
||||||
|
o.addValue( static_cast<double>( micVol ) );
|
||||||
|
|
||||||
|
o.addValue( micMute );
|
||||||
|
o.addValue( mirrorMute );
|
||||||
|
o.addValue( defaultProfile );
|
||||||
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void loadSettings( settings::SettingsObjectData& obj )
|
||||||
|
{
|
||||||
|
profileName = obj.getNextValueOrDefault( "" );
|
||||||
|
playbackName = obj.getNextValueOrDefault( "" );
|
||||||
|
mirrorName = obj.getNextValueOrDefault( "" );
|
||||||
|
micName = obj.getNextValueOrDefault( "" );
|
||||||
|
recordingID = obj.getNextValueOrDefault( "" );
|
||||||
|
playbackID = obj.getNextValueOrDefault( "" );
|
||||||
|
mirrorID = obj.getNextValueOrDefault( "" );
|
||||||
|
|
||||||
|
mirrorVol = static_cast<float>( obj.getNextValueOrDefault( 0.0 ) );
|
||||||
|
micVol = static_cast<float>( obj.getNextValueOrDefault( 1.0 ) );
|
||||||
|
micMute = obj.getNextValueOrDefault( false );
|
||||||
|
mirrorMute = obj.getNextValueOrDefault( false );
|
||||||
|
defaultProfile = obj.getNextValueOrDefault( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual std::string settingsName() const
|
||||||
|
{
|
||||||
|
return "AudioTabController::AudioProfile";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class AudioTabController : public QObject
|
class AudioTabController : public QObject
|
||||||
@@ -97,10 +142,6 @@ private:
|
|||||||
|
|
||||||
std::recursive_mutex eventLoopMutex;
|
std::recursive_mutex eventLoopMutex;
|
||||||
|
|
||||||
QString getSettingsName()
|
|
||||||
{
|
|
||||||
return "audioSettings";
|
|
||||||
}
|
|
||||||
void onPttStart();
|
void onPttStart();
|
||||||
void onPttStop();
|
void onPttStop();
|
||||||
void onPttEnabled();
|
void onPttEnabled();
|
||||||
|
|||||||
Reference in New Issue
Block a user