mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 16:43:33 +02:00
Ensure audio devices are made on the right thread
This commit is contained in:
parent
9ace80c709
commit
29ff47c6fb
2 changed files with 13 additions and 2 deletions
|
@ -1463,6 +1463,8 @@ void AudioClient::outputFormatChanged() {
|
|||
}
|
||||
|
||||
bool AudioClient::switchInputToAudioDevice(const QAudioDeviceInfo inputDeviceInfo, bool isShutdownRequest) {
|
||||
Q_ASSERT_X(QThread::currentThread() == thread(), Q_FUNC_INFO, "Function invoked on wrong thread");
|
||||
|
||||
qCDebug(audioclient) << __FUNCTION__ << "inputDeviceInfo: [" << inputDeviceInfo.deviceName() << "]";
|
||||
bool supportedFormat = false;
|
||||
|
||||
|
@ -1663,6 +1665,8 @@ void AudioClient::outputNotify() {
|
|||
}
|
||||
|
||||
bool AudioClient::switchOutputToAudioDevice(const QAudioDeviceInfo outputDeviceInfo, bool isShutdownRequest) {
|
||||
Q_ASSERT_X(QThread::currentThread() == thread(), Q_FUNC_INFO, "Function invoked on wrong thread");
|
||||
|
||||
qCDebug(audioclient) << "AudioClient::switchOutputToAudioDevice() outputDeviceInfo: [" << outputDeviceInfo.deviceName() << "]";
|
||||
bool supportedFormat = false;
|
||||
|
||||
|
@ -2021,7 +2025,7 @@ void AudioClient::setAvatarBoundingBoxParameters(glm::vec3 corner, glm::vec3 sca
|
|||
|
||||
|
||||
void AudioClient::startThread() {
|
||||
moveToNewNamedThread(this, "Audio Thread", [this] { start(); });
|
||||
moveToNewNamedThread(this, "Audio Thread", [this] { start(); }, QThread::TimeCriticalPriority);
|
||||
}
|
||||
|
||||
void AudioClient::setInputVolume(float volume, bool emitSignal) {
|
||||
|
|
|
@ -63,8 +63,15 @@ ScriptAudioInjector* AudioScriptingInterface::playSound(SharedSoundPointer sound
|
|||
bool AudioScriptingInterface::setStereoInput(bool stereo) {
|
||||
bool stereoInputChanged = false;
|
||||
if (_localAudioInterface) {
|
||||
stereoInputChanged = _localAudioInterface->setIsStereoInput(stereo);
|
||||
if (QThread::currentThread() != _localAudioInterface->thread()) {
|
||||
// TODO: This can block the main thread which is not ideal, make this function and the UI calling it async
|
||||
BLOCKING_INVOKE_METHOD(_localAudioInterface, "setIsStereoInput", Q_RETURN_ARG(bool, stereoInputChanged),
|
||||
Q_ARG(bool, stereo));
|
||||
} else {
|
||||
stereoInputChanged = _localAudioInterface->setIsStereoInput(stereo);
|
||||
}
|
||||
}
|
||||
|
||||
return stereoInputChanged;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue