Added combo-boxes to allow audio device selection.
This commit is contained in:
@@ -11,21 +11,23 @@ namespace advsettings {
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
audioManager.reset(new AudioManagerWindows());
|
||||
audioManager->init(this);
|
||||
char mirrorDeviceId[1024];
|
||||
vr::VRSettings()->GetString(vr::k_pch_audio_Section, vr::k_pch_audio_OnPlaybackMirrorDevice_String, mirrorDeviceId, 1024, &vrSettingsError);
|
||||
m_playbackDevices = audioManager->getPlaybackDevices();
|
||||
m_recordingDevices = audioManager->getRecordingDevices();
|
||||
findPlaybackDeviceIndex(audioManager->getPlaybackDevId(), false);
|
||||
char deviceId[1024];
|
||||
vr::VRSettings()->GetString(vr::k_pch_audio_Section, vr::k_pch_audio_OnPlaybackMirrorDevice_String, deviceId, 1024, &vrSettingsError);
|
||||
if (vrSettingsError != vr::VRSettingsError_None) {
|
||||
LOG(WARNING) << "Could not read \"" << vr::k_pch_audio_OnPlaybackMirrorDevice_String << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError);
|
||||
} else {
|
||||
audioManager->setMirrorDevice(deviceId);
|
||||
findMirrorDeviceIndex(audioManager->getMirrorDevId(), false);
|
||||
lastMirrorDevId = deviceId;
|
||||
m_mirrorVolume = audioManager->getMirrorVolume();
|
||||
m_mirrorMuted = audioManager->getMirrorMuted();
|
||||
}
|
||||
audioManager->setMirrorDevice(mirrorDeviceId);
|
||||
lastMirrorDevId = mirrorDeviceId;
|
||||
m_micPresent = audioManager->isMicValid();
|
||||
findMicDeviceIndex(audioManager->getMicDevId(), false);
|
||||
m_micVolume = audioManager->getMicVolume();
|
||||
m_micMuted = audioManager->getMicMuted();
|
||||
m_micDevName = QString::fromStdString(audioManager->getMicDevName());
|
||||
m_mirrorPresent = audioManager->isMirrorValid();
|
||||
m_mirrorVolume = audioManager->getMirrorVolume();
|
||||
m_mirrorMuted = audioManager->getMirrorMuted();
|
||||
m_mirrorDevName = QString::fromStdString(audioManager->getMirrorDevName());
|
||||
reloadPttProfiles();
|
||||
reloadPttConfig();
|
||||
eventLoopTick();
|
||||
@@ -58,16 +60,6 @@ namespace advsettings {
|
||||
}
|
||||
|
||||
|
||||
bool AudioTabController::mirrorPresent() const {
|
||||
return m_mirrorPresent;
|
||||
}
|
||||
|
||||
|
||||
QString AudioTabController::mirrorDevName() const {
|
||||
return m_mirrorDevName;
|
||||
}
|
||||
|
||||
|
||||
float AudioTabController::mirrorVolume() const {
|
||||
return m_mirrorVolume;
|
||||
}
|
||||
@@ -78,16 +70,6 @@ namespace advsettings {
|
||||
}
|
||||
|
||||
|
||||
bool AudioTabController::micPresent() const {
|
||||
return m_micPresent;
|
||||
}
|
||||
|
||||
|
||||
QString AudioTabController::micDevName() const {
|
||||
return m_micDevName;
|
||||
}
|
||||
|
||||
|
||||
float AudioTabController::micVolume() const {
|
||||
return m_micVolume;
|
||||
}
|
||||
@@ -110,24 +92,14 @@ namespace advsettings {
|
||||
}
|
||||
if (lastMirrorDevId.compare(mirrorDeviceId) != 0) {
|
||||
audioManager->setMirrorDevice(mirrorDeviceId);
|
||||
if (audioManager->isMirrorValid()) {
|
||||
if (!m_mirrorPresent) {
|
||||
m_mirrorPresent = true;
|
||||
emit mirrorPresentChanged(m_mirrorPresent);
|
||||
}
|
||||
m_mirrorDevName = QString::fromStdString(audioManager->getMirrorDevName());
|
||||
emit mirrorDevNameChanged(m_mirrorDevName);
|
||||
} else if (m_mirrorPresent) {
|
||||
m_mirrorPresent = false;
|
||||
emit mirrorPresentChanged(m_mirrorPresent);
|
||||
}
|
||||
findMirrorDeviceIndex(audioManager->getMirrorDevId());
|
||||
lastMirrorDevId = mirrorDeviceId;
|
||||
}
|
||||
if (m_mirrorPresent) {
|
||||
if (m_mirrorDeviceIndex >= 0) {
|
||||
setMirrorVolume(audioManager->getMirrorVolume());
|
||||
setMirrorMuted(audioManager->getMirrorMuted());
|
||||
}
|
||||
if (m_micPresent) {
|
||||
if (m_recordingDeviceIndex >= 0) {
|
||||
setMicVolume(audioManager->getMicVolume());
|
||||
setMicMuted(audioManager->getMicMuted());
|
||||
}
|
||||
@@ -212,20 +184,172 @@ namespace advsettings {
|
||||
}
|
||||
|
||||
void AudioTabController::onNewRecordingDevice() {
|
||||
if (audioManager->isMicValid()) {
|
||||
if (!m_micPresent) {
|
||||
m_micPresent = true;
|
||||
emit micPresentChanged(m_micPresent);
|
||||
}
|
||||
setMicVolume(audioManager->getMicVolume());
|
||||
setMicMuted(audioManager->getMicMuted());
|
||||
m_micDevName = QString::fromStdString(audioManager->getMicDevName());
|
||||
findMicDeviceIndex(audioManager->getMicDevId());
|
||||
}
|
||||
|
||||
emit micDevNameChanged(m_micDevName);
|
||||
void AudioTabController::onNewPlaybackDevice() {
|
||||
findPlaybackDeviceIndex(audioManager->getPlaybackDevId());
|
||||
}
|
||||
|
||||
void AudioTabController::onNewMirrorDevice() {
|
||||
}
|
||||
|
||||
void AudioTabController::onDeviceAdded() {
|
||||
}
|
||||
|
||||
void AudioTabController::onDeviceRemoved() {
|
||||
}
|
||||
|
||||
int AudioTabController::getPlaybackDeviceCount() {
|
||||
return (int)m_playbackDevices.size();
|
||||
}
|
||||
|
||||
QString AudioTabController::getPlaybackDeviceName(int index) {
|
||||
if (index < m_playbackDevices.size()) {
|
||||
return QString::fromStdString(m_playbackDevices[index].second);
|
||||
} else {
|
||||
if (m_micPresent) {
|
||||
m_micPresent = false;
|
||||
emit micPresentChanged(m_micPresent);
|
||||
return "<ERROR>";
|
||||
}
|
||||
}
|
||||
|
||||
int AudioTabController::getRecordingDeviceCount() {
|
||||
return (int)m_recordingDevices.size();
|
||||
}
|
||||
|
||||
QString AudioTabController::getRecordingDeviceName(int index) {
|
||||
if (index < m_recordingDevices.size()) {
|
||||
return QString::fromStdString(m_recordingDevices[index].second);
|
||||
} else {
|
||||
return "<ERROR>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int AudioTabController::playbackDeviceIndex() const {
|
||||
return m_playbackDeviceIndex;
|
||||
}
|
||||
|
||||
int AudioTabController::mirrorDeviceIndex() const {
|
||||
return m_mirrorDeviceIndex;
|
||||
}
|
||||
|
||||
int AudioTabController::micDeviceIndex() const {
|
||||
return m_recordingDeviceIndex;
|
||||
}
|
||||
|
||||
void AudioTabController::setPlaybackDeviceIndex(int index, bool notify) {
|
||||
if (index != m_playbackDeviceIndex) {
|
||||
if (index < m_playbackDevices.size() && index != m_mirrorDeviceIndex) {
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
vr::VRSettings()->SetString(vr::k_pch_audio_Section, vr::k_pch_audio_OnPlaybackDevice_String, m_playbackDevices[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[index].first, notify);
|
||||
}
|
||||
} else if (notify) {
|
||||
emit playbackDeviceIndexChanged(m_playbackDeviceIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioTabController::setMirrorDeviceIndex(int index, bool notify) {
|
||||
if (index != m_mirrorDeviceIndex) {
|
||||
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 if (index < m_playbackDevices.size() && index != m_playbackDeviceIndex && index != m_mirrorDeviceIndex) {
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
vr::VRSettings()->SetString(vr::k_pch_audio_Section, vr::k_pch_audio_OnPlaybackMirrorDevice_String, m_playbackDevices[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[index].first, notify);
|
||||
}
|
||||
} else if (notify) {
|
||||
emit mirrorDeviceIndexChanged(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioTabController::setMicDeviceIndex(int index, bool notify) {
|
||||
if (index != m_recordingDeviceIndex) {
|
||||
if (index < m_recordingDevices.size()) {
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
vr::VRSettings()->SetString(vr::k_pch_audio_Section, vr::k_pch_audio_OnRecordDevice_String, m_recordingDevices[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[index].first, notify);
|
||||
}
|
||||
} else if (notify) {
|
||||
emit micDeviceIndexChanged(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioTabController::findPlaybackDeviceIndex(std::string id, bool notify) {
|
||||
int i = 0;
|
||||
bool deviceFound = false;
|
||||
for (auto d : m_playbackDevices) {
|
||||
if (d.first.compare(id) == 0) {
|
||||
deviceFound = true;
|
||||
break;
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
if (deviceFound) {
|
||||
m_playbackDeviceIndex = i;
|
||||
if (notify) {
|
||||
emit playbackDeviceIndexChanged(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioTabController::findMirrorDeviceIndex(std::string id, bool notify) {
|
||||
int i = 0;
|
||||
bool deviceFound = false;
|
||||
for (auto d : m_playbackDevices) {
|
||||
if (d.first.compare(id) == 0) {
|
||||
deviceFound = true;
|
||||
break;
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
if (deviceFound && m_mirrorDeviceIndex != i) {
|
||||
m_mirrorDeviceIndex = i;
|
||||
if (notify) {
|
||||
emit mirrorDeviceIndexChanged(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioTabController::findMicDeviceIndex(std::string id, bool notify) {
|
||||
int i = 0;
|
||||
bool deviceFound = false;
|
||||
for (auto d : m_recordingDevices) {
|
||||
if (d.first.compare(id) == 0) {
|
||||
deviceFound = true;
|
||||
break;
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
if (deviceFound) {
|
||||
m_recordingDeviceIndex = i;
|
||||
if (notify) {
|
||||
emit micDeviceIndexChanged(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user