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:
ykeara
2019-05-02 11:29:49 -05:00
committed by GitHub
parent ef67888405
commit 84d5be7771
6 changed files with 262 additions and 56 deletions
+2 -2
View File
@@ -736,7 +736,8 @@ void OverlayController::mainEventLoop()
m_moveCenterTabController.shutdown(); m_moveCenterTabController.shutdown();
// Un-mute mic before Exiting VR, as it is set at system level Not // Un-mute mic before Exiting VR, as it is set at system level Not
// Vr level. // Vr level.
m_audioTabController.setMicMuted( false, false ); // m_audioTabController.setMicMuted( false, false );
m_audioTabController.shutdown();
m_chaperoneTabController.shutdown(); m_chaperoneTabController.shutdown();
Shutdown(); Shutdown();
QApplication::exit(); QApplication::exit();
@@ -857,7 +858,6 @@ void OverlayController::mainEventLoop()
m_settingsTabController.eventLoopTick(); m_settingsTabController.eventLoopTick();
m_reviveTabController.eventLoopTick(); m_reviveTabController.eventLoopTick();
m_audioTabController.eventLoopTick(); m_audioTabController.eventLoopTick();
// TODO do I need loop for vide?
if ( m_ulOverlayThumbnailHandle != vr::k_ulOverlayHandleInvalid ) if ( m_ulOverlayThumbnailHandle != vr::k_ulOverlayHandleInvalid )
{ {
@@ -21,7 +21,7 @@ RowLayout {
Layout.preferredWidth: 850 Layout.preferredWidth: 850
onActivated: { onActivated: {
if (deviceIndex >= 0) { if (deviceIndex >= 0) {
AudioTabController.setPlaybackDeviceIndex(deviceIndex, false) AudioTabController.setPlaybackDeviceIndex(deviceIndex)
} }
setShownAudioDevice(index) setShownAudioDevice(index)
} }
@@ -6,13 +6,16 @@ import "../../common"
MyDialogOkCancelPopup { MyDialogOkCancelPopup {
id: audioDeleteProfileDialog id: audioDeleteProfileDialog
dialogWidth: 600
dialogHeight: 300
y: -300
x: 100
property int profileIndex: -1 property int profileIndex: -1
dialogTitle: "Delete Profile" dialogTitle: "Delete Profile"
dialogText: "Do you really want to delete this audio profile?" dialogText: "Do you really want to delete this audio profile?"
onClosed: { onClosed: {
if (okClicked) { if (okClicked) {
AudioTabController.deleteAudioProfile(profileIndex) AudioTabController.deleteAudioProfile(profileIndex)
pttProfileComboBox.currentIndex = 0
} }
} }
} }
@@ -8,6 +8,10 @@ MyDialogOkCancelPopup {
id: pttDeleteProfileDialog id: pttDeleteProfileDialog
property int profileIndex: -1 property int profileIndex: -1
dialogTitle: "Delete Profile" dialogTitle: "Delete Profile"
dialogWidth: 600
dialogHeight: 300
y: -300
x: 100
dialogText: "Do you really want to delete this ptt profile?" dialogText: "Do you really want to delete this ptt profile?"
onClosed: { onClosed: {
if (okClicked) { if (okClicked) {
+239 -52
View File
@@ -51,7 +51,7 @@ void AudioTabController::initStage1()
reloadPttProfiles(); reloadPttProfiles();
reloadPttConfig(); reloadPttConfig();
reloadAudioProfiles(); reloadAudioProfiles();
applyDefaultProfile(); // applyDefaultProfile();
reloadAudioSettings(); reloadAudioSettings();
eventLoopTick(); 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() int AudioTabController::getRecordingDeviceCount()
{ {
return static_cast<int>( m_recordingDevices.size() ); 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 ) QString AudioTabController::getRecordingDeviceName( int index )
{ {
if ( index >= 0 && static_cast<size_t>( index ) < m_playbackDevices.size() ) if ( index >= 0 && static_cast<size_t>( index ) < m_playbackDevices.size() )
@@ -484,6 +515,7 @@ QString AudioTabController::getRecordingDeviceName( int index )
return "<ERROR>"; return "<ERROR>";
} }
} }
int AudioTabController::playbackDeviceIndex() const int AudioTabController::playbackDeviceIndex() const
{ {
return m_playbackDeviceIndex; return m_playbackDeviceIndex;
@@ -507,28 +539,9 @@ void AudioTabController::setPlaybackDeviceIndex( int index, bool notify )
&& static_cast<size_t>( index ) < m_playbackDevices.size() && static_cast<size_t>( index ) < m_playbackDevices.size()
&& index != m_mirrorDeviceIndex ) && index != m_mirrorDeviceIndex )
{ {
vr::EVRSettingsError vrSettingsError; // Code to only change the Device and not apply changes to SteamVR
// Applys Audio Switch IN VR audioManager->setPlaybackDevice(
vr::VRSettings()->SetString( m_playbackDevices[static_cast<size_t>( index )].first, notify );
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 );
}
} }
else if ( notify ) else if ( notify )
{ {
@@ -605,27 +618,10 @@ void AudioTabController::setMicDeviceIndex( int index, bool notify )
if ( index >= 0 if ( index >= 0
&& static_cast<size_t>( index ) < m_recordingDevices.size() ) && static_cast<size_t>( index ) < m_recordingDevices.size() )
{ {
vr::EVRSettingsError vrSettingsError; // code to just change Mic
vr::VRSettings()->SetString( audioManager->setMicDevice(
vr::k_pch_audio_Section, m_recordingDevices[static_cast<size_t>( index )].first,
vr::k_pch_audio_OnRecordDevice_String, notify );
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 );
}
} }
else if ( notify ) else if ( notify )
{ {
@@ -763,6 +759,11 @@ void AudioTabController::reloadAudioProfiles()
entry.micVol = settings->value( "micVol", 1.0 ).toFloat(); entry.micVol = settings->value( "micVol", 1.0 ).toFloat();
entry.defaultProfile entry.defaultProfile
= settings->value( "defaultProfile", false ).toBool(); = 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->endArray();
settings->endGroup(); settings->endGroup();
@@ -802,6 +803,12 @@ void AudioTabController::saveAudioProfiles()
settings->setValue( "micVol", p.micVol ); settings->setValue( "micVol", p.micVol );
settings->setValue( "mirrorVol", p.mirrorVol ); settings->setValue( "mirrorVol", p.mirrorVol );
settings->setValue( "defaultProfile", p.defaultProfile ); 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++; i++;
} }
settings->endArray(); settings->endArray();
@@ -852,8 +859,16 @@ void AudioTabController::addAudioProfile( QString name )
profile->mirrorVol = m_mirrorVolume; profile->mirrorVol = m_mirrorVolume;
profile->micVol = m_micVolume; profile->micVol = m_micVolume;
profile->defaultProfile = m_isDefaultAudioProfile; profile->defaultProfile = m_isDefaultAudioProfile;
profile->playbackID = getPlaybackDeviceID( m_playbackDeviceIndex );
profile->mirrorID = getMirrorDeviceID( m_mirrorDeviceIndex );
profile->recordingID = getRecordingDeviceID( m_recordingDeviceIndex );
if ( m_isDefaultAudioProfile ) if ( m_isDefaultAudioProfile )
{ {
setDefaultMic( m_recordingDeviceIndex );
setDefaultPlayback( m_playbackDeviceIndex );
removeOtherDefaultProfiles( name ); removeOtherDefaultProfiles( name );
setAudioProfileDefault( false ); setAudioProfileDefault( false );
@@ -877,15 +892,15 @@ other: none
Description: Applies the required logic to activate the audio profile. Description: Applies the required logic to activate the audio profile.
*/ */
// TODO Remembers Mirror Volume when switching to main volume.
void AudioTabController::applyAudioProfile( unsigned index ) void AudioTabController::applyAudioProfile( unsigned index )
{ {
std::lock_guard<std::recursive_mutex> lock( eventLoopMutex ); std::lock_guard<std::recursive_mutex> lock( eventLoopMutex );
if ( index < audioProfiles.size() ) if ( index < audioProfiles.size() )
{ {
auto& profile = audioProfiles[index]; auto& profile = audioProfiles[index];
int mInd = getMirrorIndex( profile.mirrorName ); int mInd = getMirrorIndex( profile.mirrorID );
int pInd = getPlaybackIndex( profile.playbackName ); int pInd = getPlaybackIndex( profile.playbackID );
// Needed to keep remembering when swtiching from mirror/main etc. // Needed to keep remembering when swtiching from mirror/main etc.
// TODO OPTI can possibly clean up logic to reduce overhead in future. // TODO OPTI can possibly clean up logic to reduce overhead in future.
@@ -908,7 +923,7 @@ void AudioTabController::applyAudioProfile( unsigned index )
setPlaybackDeviceIndex( pInd, true ); setPlaybackDeviceIndex( pInd, true );
} }
setMicDeviceIndex( getRecordingIndex( profile.micName ), true ); setMicDeviceIndex( getRecordingIndex( profile.recordingID ), true );
setMicMuted( profile.micMute, true ); setMicMuted( profile.micMute, true );
setMirrorMuted( profile.mirrorMute, true ); setMirrorMuted( profile.mirrorMute, true );
setMicVolume( profile.micVol, true ); setMicVolume( profile.micVol, true );
@@ -934,6 +949,46 @@ void AudioTabController::deleteAudioProfile( unsigned index )
if ( index < audioProfiles.size() ) if ( index < audioProfiles.size() )
{ {
auto pos = audioProfiles.begin() + index; 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 ); audioProfiles.erase( pos );
saveAudioProfiles(); saveAudioProfiles();
OverlayController::appSettings()->sync(); OverlayController::appSettings()->sync();
@@ -957,7 +1012,7 @@ QString AudioTabController::getAudioProfileName( unsigned index )
/* /*
Name: getPlaybackIndex, getRecordingIndex, and getMirrorIndex 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), output: integer for use In: setMicDeviceIndex(int,bool),
setMirrorDeviceIndex(int,bool) setPlayBackDeviceIndex(int,bool) setMirrorDeviceIndex(int,bool) setPlayBackDeviceIndex(int,bool)
description: Gets proper index value for selecting specific devices. description: Gets proper index value for selecting specific devices.
@@ -968,7 +1023,7 @@ int AudioTabController::getPlaybackIndex( std::string str )
// increment it. // increment it.
for ( unsigned int i = 0; i < m_playbackDevices.size(); i++ ) 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 ); return static_cast<int>( i );
} }
@@ -982,7 +1037,7 @@ int AudioTabController::getRecordingIndex( std::string str )
// increment it. // increment it.
for ( unsigned int i = 0; i < m_recordingDevices.size(); i++ ) 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 ); return static_cast<int>( i );
} }
@@ -996,7 +1051,7 @@ int AudioTabController::getMirrorIndex( std::string str )
// increment it. // increment it.
for ( unsigned int i = 0; i < m_playbackDevices.size(); i++ ) 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 ); return static_cast<int>( i );
} }
@@ -1004,6 +1059,112 @@ int AudioTabController::getMirrorIndex( std::string str )
return -1; 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 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 } // namespace advsettings
+12
View File
@@ -18,6 +18,9 @@ struct AudioProfile
std::string playbackName; std::string playbackName;
std::string mirrorName; std::string mirrorName;
std::string micName; std::string micName;
std::string recordingID;
std::string playbackID;
std::string mirrorID;
float mirrorVol = 0.0; float mirrorVol = 0.0;
float micVol = 0.0; float micVol = 0.0;
bool micMute = false; bool micMute = false;
@@ -103,6 +106,14 @@ private:
void removeOtherDefaultProfiles( QString name ); 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; std::vector<AudioProfile> audioProfiles;
public: public:
@@ -147,6 +158,7 @@ public:
void onNewPlaybackDevice(); void onNewPlaybackDevice();
void onNewMirrorDevice(); void onNewMirrorDevice();
void onDeviceStateChanged(); void onDeviceStateChanged();
void shutdown();
public slots: public slots:
void setMirrorVolume( float value, bool notify = true ); void setMirrorVolume( float value, bool notify = true );