From e55a2ff6f337e8af555af3c4fc35b95206783832 Mon Sep 17 00:00:00 2001 From: ksuprynowicz Date: Mon, 24 Mar 2025 08:10:07 +0100 Subject: [PATCH] Initialize AudioClient properties earlier. --- libraries/audio-client/src/AudioClient.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index 8caf6b6f89..b3a2aa3f2a 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -320,6 +320,18 @@ AudioClient::AudioClient() { // avoid putting a lock in the device callback assert(_localSamplesAvailable.is_lock_free()); + // Set up the desired audio format, since scripting API expects it to be set and audio scripting API + // is initialized before audio thread starts. + _desiredInputFormat.setSampleRate(AudioConstants::SAMPLE_RATE); + _desiredInputFormat.setSampleSize(16); + _desiredInputFormat.setCodec("audio/pcm"); + _desiredInputFormat.setSampleType(QAudioFormat::SignedInt); + _desiredInputFormat.setByteOrder(QAudioFormat::LittleEndian); + _desiredInputFormat.setChannelCount(1); + + _desiredOutputFormat = _desiredInputFormat; + _desiredOutputFormat.setChannelCount(OUTPUT_CHANNEL_COUNT); + // deprecate legacy settings { Setting::Handle::Deprecated("maxFramesOverDesired", InboundAudioStream::MAX_FRAMES_OVER_DESIRED);