Fixes Various Audio Issues. (#185)
* perf graph overlay/checkbox added * added toggle Chaperone action * toggle chaperone non-functional * fixed chaperone toggle action const to once * Added Proximity Sensor Action back-end, not implemented via logic Until fixed by valve * added default WMR controller profile * formated * formated steamvrtabcontroller.h * fixed un-intended change * fixed audio profile Bug w/ changed devices * fixed name being used as param instead of ID * fixed loop logic in saveAudioProfile * audio profile fix WIP defaults OVR integration * fixed profile Saves, delete logic and mirror logic needed * fixed QML format, added TODO message * Fixed Audio Profile Behavior * fixed qml reference error * audiodeviceselector changed qml * Removed some comments
This commit is contained in:
@@ -51,7 +51,7 @@ void AudioTabController::initStage1()
|
||||
reloadPttProfiles();
|
||||
reloadPttConfig();
|
||||
reloadAudioProfiles();
|
||||
applyDefaultProfile();
|
||||
// applyDefaultProfile();
|
||||
reloadAudioSettings();
|
||||
|
||||
eventLoopTick();
|
||||
@@ -467,11 +467,42 @@ QString AudioTabController::getPlaybackDeviceName( int index )
|
||||
}
|
||||
}
|
||||
|
||||
std::string AudioTabController::getPlaybackDeviceID( int index )
|
||||
{
|
||||
if ( index >= 0 && static_cast<size_t>( index ) < m_playbackDevices.size() )
|
||||
{
|
||||
return m_playbackDevices[static_cast<size_t>( index )].first;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG( ERROR ) << "Playback Device does not have a unique id";
|
||||
return "<ERROR>";
|
||||
}
|
||||
}
|
||||
|
||||
std::string AudioTabController::getMirrorDeviceID( int index )
|
||||
{
|
||||
return getPlaybackDeviceID( index );
|
||||
}
|
||||
|
||||
int AudioTabController::getRecordingDeviceCount()
|
||||
{
|
||||
return static_cast<int>( m_recordingDevices.size() );
|
||||
}
|
||||
|
||||
std::string AudioTabController::getRecordingDeviceID( int index )
|
||||
{
|
||||
if ( index >= 0 && static_cast<size_t>( index ) < m_playbackDevices.size() )
|
||||
{
|
||||
return m_recordingDevices[static_cast<size_t>( index )].first;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG( ERROR ) << "Recording Device does not have a unique id";
|
||||
return "<ERROR>";
|
||||
}
|
||||
}
|
||||
|
||||
QString AudioTabController::getRecordingDeviceName( int index )
|
||||
{
|
||||
if ( index >= 0 && static_cast<size_t>( index ) < m_playbackDevices.size() )
|
||||
@@ -484,6 +515,7 @@ QString AudioTabController::getRecordingDeviceName( int index )
|
||||
return "<ERROR>";
|
||||
}
|
||||
}
|
||||
|
||||
int AudioTabController::playbackDeviceIndex() const
|
||||
{
|
||||
return m_playbackDeviceIndex;
|
||||
@@ -507,28 +539,9 @@ void AudioTabController::setPlaybackDeviceIndex( int index, bool notify )
|
||||
&& static_cast<size_t>( index ) < m_playbackDevices.size()
|
||||
&& index != m_mirrorDeviceIndex )
|
||||
{
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
// Applys Audio Switch IN VR
|
||||
vr::VRSettings()->SetString(
|
||||
vr::k_pch_audio_Section,
|
||||
vr::k_pch_audio_OnPlaybackDevice_String,
|
||||
m_playbackDevices[static_cast<size_t>( index )].first.c_str(),
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING )
|
||||
<< "Could not write \""
|
||||
<< vr::k_pch_audio_OnPlaybackDevice_String << "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
else
|
||||
{
|
||||
vr::VRSettings()->Sync();
|
||||
audioManager->setPlaybackDevice(
|
||||
m_playbackDevices[static_cast<size_t>( index )].first,
|
||||
notify );
|
||||
}
|
||||
// Code to only change the Device and not apply changes to SteamVR
|
||||
audioManager->setPlaybackDevice(
|
||||
m_playbackDevices[static_cast<size_t>( index )].first, notify );
|
||||
}
|
||||
else if ( notify )
|
||||
{
|
||||
@@ -605,27 +618,10 @@ void AudioTabController::setMicDeviceIndex( int index, bool notify )
|
||||
if ( index >= 0
|
||||
&& static_cast<size_t>( index ) < m_recordingDevices.size() )
|
||||
{
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
vr::VRSettings()->SetString(
|
||||
vr::k_pch_audio_Section,
|
||||
vr::k_pch_audio_OnRecordDevice_String,
|
||||
m_recordingDevices[static_cast<size_t>( index )].first.c_str(),
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING )
|
||||
<< "Could not write \""
|
||||
<< vr::k_pch_audio_OnRecordDevice_String << "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
else
|
||||
{
|
||||
vr::VRSettings()->Sync();
|
||||
audioManager->setMicDevice(
|
||||
m_recordingDevices[static_cast<size_t>( index )].first,
|
||||
notify );
|
||||
}
|
||||
// code to just change Mic
|
||||
audioManager->setMicDevice(
|
||||
m_recordingDevices[static_cast<size_t>( index )].first,
|
||||
notify );
|
||||
}
|
||||
else if ( notify )
|
||||
{
|
||||
@@ -763,6 +759,11 @@ void AudioTabController::reloadAudioProfiles()
|
||||
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();
|
||||
@@ -802,6 +803,12 @@ void AudioTabController::saveAudioProfiles()
|
||||
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();
|
||||
@@ -852,8 +859,16 @@ void AudioTabController::addAudioProfile( QString name )
|
||||
profile->mirrorVol = m_mirrorVolume;
|
||||
profile->micVol = m_micVolume;
|
||||
profile->defaultProfile = m_isDefaultAudioProfile;
|
||||
|
||||
profile->playbackID = getPlaybackDeviceID( m_playbackDeviceIndex );
|
||||
profile->mirrorID = getMirrorDeviceID( m_mirrorDeviceIndex );
|
||||
profile->recordingID = getRecordingDeviceID( m_recordingDeviceIndex );
|
||||
|
||||
if ( m_isDefaultAudioProfile )
|
||||
{
|
||||
setDefaultMic( m_recordingDeviceIndex );
|
||||
setDefaultPlayback( m_playbackDeviceIndex );
|
||||
|
||||
removeOtherDefaultProfiles( name );
|
||||
|
||||
setAudioProfileDefault( false );
|
||||
@@ -877,15 +892,15 @@ other: none
|
||||
Description: Applies the required logic to activate the audio profile.
|
||||
|
||||
*/
|
||||
// TODO Remembers Mirror Volume when switching to main volume.
|
||||
|
||||
void AudioTabController::applyAudioProfile( unsigned index )
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock( eventLoopMutex );
|
||||
if ( index < audioProfiles.size() )
|
||||
{
|
||||
auto& profile = audioProfiles[index];
|
||||
int mInd = getMirrorIndex( profile.mirrorName );
|
||||
int pInd = getPlaybackIndex( profile.playbackName );
|
||||
int mInd = getMirrorIndex( profile.mirrorID );
|
||||
int pInd = getPlaybackIndex( profile.playbackID );
|
||||
|
||||
// Needed to keep remembering when swtiching from mirror/main etc.
|
||||
// TODO OPTI can possibly clean up logic to reduce overhead in future.
|
||||
@@ -908,7 +923,7 @@ void AudioTabController::applyAudioProfile( unsigned index )
|
||||
setPlaybackDeviceIndex( pInd, true );
|
||||
}
|
||||
|
||||
setMicDeviceIndex( getRecordingIndex( profile.micName ), true );
|
||||
setMicDeviceIndex( getRecordingIndex( profile.recordingID ), true );
|
||||
setMicMuted( profile.micMute, true );
|
||||
setMirrorMuted( profile.mirrorMute, true );
|
||||
setMicVolume( profile.micVol, true );
|
||||
@@ -934,6 +949,46 @@ void AudioTabController::deleteAudioProfile( unsigned index )
|
||||
if ( index < audioProfiles.size() )
|
||||
{
|
||||
auto pos = audioProfiles.begin() + index;
|
||||
// Remove PlayBack and Mic from Steam API Mirror Is handled @ shutdown
|
||||
// This is necessary because Mirror Device does not appear to be handled
|
||||
// via native windows api.
|
||||
if ( audioProfiles.at( index ).defaultProfile )
|
||||
{
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
vr::VRSettings()->RemoveKeyInSection(
|
||||
vr::k_pch_audio_Section,
|
||||
vr::k_pch_audio_OnPlaybackDevice_String,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING )
|
||||
<< "Could not remove \""
|
||||
<< vr::k_pch_audio_OnPlaybackDevice_String << "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
else
|
||||
{
|
||||
vr::VRSettings()->Sync();
|
||||
}
|
||||
|
||||
vr::VRSettings()->RemoveKeyInSection(
|
||||
vr::k_pch_audio_Section,
|
||||
vr::k_pch_audio_OnRecordDevice_String,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING )
|
||||
<< "Could not remove \""
|
||||
<< vr::k_pch_audio_OnRecordDevice_String << "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
else
|
||||
{
|
||||
vr::VRSettings()->Sync();
|
||||
}
|
||||
}
|
||||
audioProfiles.erase( pos );
|
||||
saveAudioProfiles();
|
||||
OverlayController::appSettings()->sync();
|
||||
@@ -957,7 +1012,7 @@ QString AudioTabController::getAudioProfileName( unsigned index )
|
||||
|
||||
/*
|
||||
Name: getPlaybackIndex, getRecordingIndex, and getMirrorIndex
|
||||
input: string, of microphone/playback device name
|
||||
input: string, of microphone/playback device ID
|
||||
output: integer for use In: setMicDeviceIndex(int,bool),
|
||||
setMirrorDeviceIndex(int,bool) setPlayBackDeviceIndex(int,bool)
|
||||
description: Gets proper index value for selecting specific devices.
|
||||
@@ -968,7 +1023,7 @@ int AudioTabController::getPlaybackIndex( std::string str )
|
||||
// increment it.
|
||||
for ( unsigned int i = 0; i < m_playbackDevices.size(); i++ )
|
||||
{
|
||||
if ( str.compare( m_playbackDevices[i].second ) == 0 )
|
||||
if ( str.compare( m_playbackDevices[i].first ) == 0 )
|
||||
{
|
||||
return static_cast<int>( i );
|
||||
}
|
||||
@@ -982,7 +1037,7 @@ int AudioTabController::getRecordingIndex( std::string str )
|
||||
// increment it.
|
||||
for ( unsigned int i = 0; i < m_recordingDevices.size(); i++ )
|
||||
{
|
||||
if ( str.compare( m_recordingDevices[i].second ) == 0 )
|
||||
if ( str.compare( m_recordingDevices[i].first ) == 0 )
|
||||
{
|
||||
return static_cast<int>( i );
|
||||
}
|
||||
@@ -996,7 +1051,7 @@ int AudioTabController::getMirrorIndex( std::string str )
|
||||
// increment it.
|
||||
for ( unsigned int i = 0; i < m_playbackDevices.size(); i++ )
|
||||
{
|
||||
if ( str.compare( m_playbackDevices[i].second ) == 0 )
|
||||
if ( str.compare( m_playbackDevices[i].first ) == 0 )
|
||||
{
|
||||
return static_cast<int>( i );
|
||||
}
|
||||
@@ -1004,6 +1059,112 @@ int AudioTabController::getMirrorIndex( std::string str )
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: setDefaultPlayback/Mirror/Mic
|
||||
|
||||
input int index = index of m_playbackDevices to set
|
||||
|
||||
description: sets the SteamVR "on launch" audio options
|
||||
|
||||
NOTE: We Assume Index passed is good, and valid
|
||||
*/
|
||||
|
||||
void AudioTabController::setDefaultPlayback( int index, bool notify )
|
||||
{
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
vr::VRSettings()->SetString(
|
||||
vr::k_pch_audio_Section,
|
||||
vr::k_pch_audio_OnPlaybackDevice_String,
|
||||
m_playbackDevices[static_cast<size_t>( index )].first.c_str(),
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not write \""
|
||||
<< vr::k_pch_audio_OnPlaybackDevice_String
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
else
|
||||
{
|
||||
vr::VRSettings()->Sync();
|
||||
audioManager->setPlaybackDevice(
|
||||
m_playbackDevices[static_cast<size_t>( index )].first, notify );
|
||||
}
|
||||
}
|
||||
|
||||
void AudioTabController::setDefaultMic( int index, bool notify )
|
||||
{
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
vr::VRSettings()->SetString(
|
||||
vr::k_pch_audio_Section,
|
||||
vr::k_pch_audio_OnRecordDevice_String,
|
||||
m_recordingDevices[static_cast<size_t>( index )].first.c_str(),
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not write \""
|
||||
<< vr::k_pch_audio_OnRecordDevice_String
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
else
|
||||
{
|
||||
vr::VRSettings()->Sync();
|
||||
audioManager->setMicDevice(
|
||||
m_recordingDevices[static_cast<size_t>( index )].first, notify );
|
||||
}
|
||||
}
|
||||
|
||||
void AudioTabController::setDefaultMirror( int index, bool notify )
|
||||
{
|
||||
if ( index == -1 )
|
||||
{
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
vr::VRSettings()->RemoveKeyInSection(
|
||||
vr::k_pch_audio_Section,
|
||||
vr::k_pch_audio_OnPlaybackMirrorDevice_String,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not remove \""
|
||||
<< vr::k_pch_audio_OnPlaybackMirrorDevice_String
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
else
|
||||
{
|
||||
vr::VRSettings()->Sync();
|
||||
audioManager->setMirrorDevice( "", notify );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
vr::VRSettings()->SetString(
|
||||
vr::k_pch_audio_Section,
|
||||
vr::k_pch_audio_OnPlaybackMirrorDevice_String,
|
||||
m_playbackDevices[static_cast<size_t>( index )].first.c_str(),
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not write \""
|
||||
<< vr::k_pch_audio_OnPlaybackMirrorDevice_String
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
else
|
||||
{
|
||||
vr::VRSettings()->Sync();
|
||||
audioManager->setMirrorDevice(
|
||||
m_playbackDevices[static_cast<size_t>( index )].first, notify );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Name: removeOtherDefaultProfiles
|
||||
|
||||
@@ -1057,4 +1218,30 @@ int AudioTabController::getDefaultAudioProfileIndex()
|
||||
/* ---------------------------*/
|
||||
/*----------------------------*/
|
||||
|
||||
void AudioTabController::shutdown()
|
||||
{
|
||||
setMicMuted( false, false );
|
||||
std::string mID;
|
||||
bool hasDefaultProfile = false;
|
||||
for ( unsigned i = 0; i < audioProfiles.size(); i++ )
|
||||
{
|
||||
auto& profile = audioProfiles[i];
|
||||
if ( profile.defaultProfile )
|
||||
{
|
||||
mID = profile.mirrorID;
|
||||
hasDefaultProfile = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( hasDefaultProfile )
|
||||
{
|
||||
setMirrorDeviceIndex( getMirrorIndex( mID ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
setMirrorDeviceIndex( -1 );
|
||||
}
|
||||
LOG( INFO ) << "Audio Tab Controller Has Shut Down";
|
||||
}
|
||||
|
||||
} // namespace advsettings
|
||||
|
||||
@@ -18,6 +18,9 @@ struct AudioProfile
|
||||
std::string playbackName;
|
||||
std::string mirrorName;
|
||||
std::string micName;
|
||||
std::string recordingID;
|
||||
std::string playbackID;
|
||||
std::string mirrorID;
|
||||
float mirrorVol = 0.0;
|
||||
float micVol = 0.0;
|
||||
bool micMute = false;
|
||||
@@ -103,6 +106,14 @@ private:
|
||||
|
||||
void removeOtherDefaultProfiles( QString name );
|
||||
|
||||
std::string getPlaybackDeviceID( int index );
|
||||
std::string getMirrorDeviceID( int index );
|
||||
std::string getRecordingDeviceID( int index );
|
||||
|
||||
void setDefaultPlayback( int index, bool notify = true );
|
||||
void setDefaultMirror( int index, bool notify = true );
|
||||
void setDefaultMic( int index, bool notify = true );
|
||||
|
||||
std::vector<AudioProfile> audioProfiles;
|
||||
|
||||
public:
|
||||
@@ -147,6 +158,7 @@ public:
|
||||
void onNewPlaybackDevice();
|
||||
void onNewMirrorDevice();
|
||||
void onDeviceStateChanged();
|
||||
void shutdown();
|
||||
|
||||
public slots:
|
||||
void setMirrorVolume( float value, bool notify = true );
|
||||
|
||||
Reference in New Issue
Block a user