mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 04:53:25 +02:00
getting wrapper to correctly detect default and fixed clang formatting changes by vs19
This commit is contained in:
parent
0de7628d48
commit
68cd8cc8a6
3 changed files with 56 additions and 42 deletions
|
@ -89,6 +89,7 @@ using Mutex = std::mutex;
|
||||||
using Lock = std::unique_lock<Mutex>;
|
using Lock = std::unique_lock<Mutex>;
|
||||||
Mutex _deviceMutex;
|
Mutex _deviceMutex;
|
||||||
Mutex _recordMutex;
|
Mutex _recordMutex;
|
||||||
|
QAudioDeviceInfo defaultAudioDeviceForMode(QAudio::Mode mode);
|
||||||
|
|
||||||
// thread-safe
|
// thread-safe
|
||||||
QList<HifiAudioDeviceInfo> getAvailableDevices(QAudio::Mode mode) {
|
QList<HifiAudioDeviceInfo> getAvailableDevices(QAudio::Mode mode) {
|
||||||
|
@ -97,16 +98,9 @@ QList<HifiAudioDeviceInfo> getAvailableDevices(QAudio::Mode mode) {
|
||||||
auto devices = QAudioDeviceInfo::availableDevices(mode);
|
auto devices = QAudioDeviceInfo::availableDevices(mode);
|
||||||
|
|
||||||
QList<HifiAudioDeviceInfo> newDevices;
|
QList<HifiAudioDeviceInfo> newDevices;
|
||||||
QAudioDeviceInfo::defaultOutputDevice();
|
|
||||||
|
|
||||||
for (auto& device : devices) {
|
for (auto& device : devices) {
|
||||||
bool isDefault = false;
|
newDevices.push_back(HifiAudioDeviceInfo(device, false, mode));
|
||||||
if (mode == QAudio::Mode::AudioInput) {
|
|
||||||
isDefault = device == QAudioDeviceInfo::defaultInputDevice();
|
|
||||||
} else {
|
|
||||||
isDefault = device == QAudioDeviceInfo::defaultOutputDevice();
|
|
||||||
}
|
|
||||||
newDevices.push_back(HifiAudioDeviceInfo(device, isDefault, mode));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return newDevices;
|
return newDevices;
|
||||||
|
@ -124,6 +118,9 @@ void AudioClient::checkDevices() {
|
||||||
auto inputDevices = getAvailableDevices(QAudio::AudioInput);
|
auto inputDevices = getAvailableDevices(QAudio::AudioInput);
|
||||||
auto outputDevices = getAvailableDevices(QAudio::AudioOutput);
|
auto outputDevices = getAvailableDevices(QAudio::AudioOutput);
|
||||||
|
|
||||||
|
QMetaObject::invokeMethod(this, "setDefaultDevice", Qt::BlockingQueuedConnection, Q_ARG(QList<HifiAudioDeviceInfo>&, inputDevices), Q_ARG(QAudio::Mode, QAudio::AudioInput));
|
||||||
|
QMetaObject::invokeMethod(this, "setDefaultDevice", Qt::BlockingQueuedConnection, Q_ARG(QList<HifiAudioDeviceInfo>&, outputDevices), Q_ARG(QAudio::Mode, QAudio::AudioOutput));
|
||||||
|
|
||||||
Lock lock(_deviceMutex);
|
Lock lock(_deviceMutex);
|
||||||
if (inputDevices != _inputDevices) {
|
if (inputDevices != _inputDevices) {
|
||||||
_inputDevices.swap(inputDevices);
|
_inputDevices.swap(inputDevices);
|
||||||
|
@ -409,6 +406,21 @@ void AudioClient::setAudioPaused(bool pause) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioClient::setDefaultDevice(QList<HifiAudioDeviceInfo>& devices ,QAudio::Mode mode) {
|
||||||
|
QAudioDeviceInfo defDevice = defaultAudioDeviceForMode(mode);
|
||||||
|
for (auto& device : devices) {
|
||||||
|
if (device.getDevice() == defDevice) {
|
||||||
|
if (!device.isDefault()) {
|
||||||
|
device.setIsDefault(true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (device.isDefault()) {
|
||||||
|
device.setIsDefault(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QAudioDeviceInfo getNamedAudioDeviceForMode(QAudio::Mode mode, const QString& deviceName) {
|
QAudioDeviceInfo getNamedAudioDeviceForMode(QAudio::Mode mode, const QString& deviceName) {
|
||||||
QAudioDeviceInfo result;
|
QAudioDeviceInfo result;
|
||||||
foreach (HifiAudioDeviceInfo audioDevice, getAvailableDevices(mode)) {
|
foreach (HifiAudioDeviceInfo audioDevice, getAvailableDevices(mode)) {
|
||||||
|
|
|
@ -56,13 +56,13 @@
|
||||||
#include "HifiAudioDeviceInfo.h"
|
#include "HifiAudioDeviceInfo.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#pragma warning(push)
|
#pragma warning( push )
|
||||||
#pragma warning(disable : 4273)
|
#pragma warning( disable : 4273 )
|
||||||
#pragma warning(disable : 4305)
|
#pragma warning( disable : 4305 )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#pragma warning(pop)
|
#pragma warning( pop )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
|
@ -121,7 +121,7 @@ public:
|
||||||
AudioClient* _audio;
|
AudioClient* _audio;
|
||||||
int _unfulfilledReads;
|
int _unfulfilledReads;
|
||||||
};
|
};
|
||||||
|
|
||||||
void startThread();
|
void startThread();
|
||||||
void negotiateAudioFormat();
|
void negotiateAudioFormat();
|
||||||
void selectAudioFormat(const QString& selectedCodecName);
|
void selectAudioFormat(const QString& selectedCodecName);
|
||||||
|
@ -132,6 +132,7 @@ public:
|
||||||
Q_INVOKABLE float getAudioInboundPPS() const { return _audioInbound.rate(); }
|
Q_INVOKABLE float getAudioInboundPPS() const { return _audioInbound.rate(); }
|
||||||
Q_INVOKABLE float getSilentOutboundPPS() const { return _silentOutbound.rate(); }
|
Q_INVOKABLE float getSilentOutboundPPS() const { return _silentOutbound.rate(); }
|
||||||
Q_INVOKABLE float getAudioOutboundPPS() const { return _audioOutbound.rate(); }
|
Q_INVOKABLE float getAudioOutboundPPS() const { return _audioOutbound.rate(); }
|
||||||
|
Q_INVOKABLE void setDefaultDevice(QList<HifiAudioDeviceInfo>& devices, QAudio::Mode mode);
|
||||||
|
|
||||||
const MixedProcessedAudioStream& getReceivedAudioStream() const { return _receivedAudioStream; }
|
const MixedProcessedAudioStream& getReceivedAudioStream() const { return _receivedAudioStream; }
|
||||||
MixedProcessedAudioStream& getReceivedAudioStream() { return _receivedAudioStream; }
|
MixedProcessedAudioStream& getReceivedAudioStream() { return _receivedAudioStream; }
|
||||||
|
@ -167,7 +168,7 @@ public:
|
||||||
|
|
||||||
HifiAudioDeviceInfo getActiveAudioDevice(QAudio::Mode mode) const;
|
HifiAudioDeviceInfo getActiveAudioDevice(QAudio::Mode mode) const;
|
||||||
QList<HifiAudioDeviceInfo> getAudioDevices(QAudio::Mode mode) const;
|
QList<HifiAudioDeviceInfo> getAudioDevices(QAudio::Mode mode) const;
|
||||||
|
|
||||||
void enablePeakValues(bool enable) { _enablePeakValues = enable; }
|
void enablePeakValues(bool enable) { _enablePeakValues = enable; }
|
||||||
bool peakValuesAvailable() const;
|
bool peakValuesAvailable() const;
|
||||||
|
|
||||||
|
@ -181,6 +182,7 @@ public:
|
||||||
bool startRecording(const QString& filename);
|
bool startRecording(const QString& filename);
|
||||||
void stopRecording();
|
void stopRecording();
|
||||||
void setAudioPaused(bool pause);
|
void setAudioPaused(bool pause);
|
||||||
|
|
||||||
|
|
||||||
AudioSolo& getAudioSolo() override { return _solo; }
|
AudioSolo& getAudioSolo() override { return _solo; }
|
||||||
|
|
||||||
|
@ -355,7 +357,7 @@ private:
|
||||||
QIODevice* _inputDevice;
|
QIODevice* _inputDevice;
|
||||||
int _numInputCallbackBytes;
|
int _numInputCallbackBytes;
|
||||||
QAudioOutput* _audioOutput;
|
QAudioOutput* _audioOutput;
|
||||||
std::atomic<bool> _audioOutputInitialized{ false };
|
std::atomic<bool> _audioOutputInitialized { false };
|
||||||
QAudioFormat _desiredOutputFormat;
|
QAudioFormat _desiredOutputFormat;
|
||||||
QAudioFormat _outputFormat;
|
QAudioFormat _outputFormat;
|
||||||
int _outputFrameSize;
|
int _outputFrameSize;
|
||||||
|
@ -366,11 +368,11 @@ private:
|
||||||
LocalInjectorsStream _localInjectorsStream;
|
LocalInjectorsStream _localInjectorsStream;
|
||||||
// In order to use _localInjectorsStream as a lock-free pipe,
|
// In order to use _localInjectorsStream as a lock-free pipe,
|
||||||
// use it with a single producer/consumer, and track available samples and injectors
|
// use it with a single producer/consumer, and track available samples and injectors
|
||||||
std::atomic<int> _localSamplesAvailable{ 0 };
|
std::atomic<int> _localSamplesAvailable { 0 };
|
||||||
std::atomic<bool> _localInjectorsAvailable{ false };
|
std::atomic<bool> _localInjectorsAvailable { false };
|
||||||
MixedProcessedAudioStream _receivedAudioStream;
|
MixedProcessedAudioStream _receivedAudioStream;
|
||||||
bool _isStereoInput;
|
bool _isStereoInput;
|
||||||
std::atomic<bool> _enablePeakValues{ false };
|
std::atomic<bool> _enablePeakValues { false };
|
||||||
|
|
||||||
quint64 _outputStarveDetectionStartTimeMsec;
|
quint64 _outputStarveDetectionStartTimeMsec;
|
||||||
int _outputStarveDetectionCount;
|
int _outputStarveDetectionCount;
|
||||||
|
@ -398,9 +400,9 @@ private:
|
||||||
AudioEffectOptions _scriptReverbOptions;
|
AudioEffectOptions _scriptReverbOptions;
|
||||||
AudioEffectOptions _zoneReverbOptions;
|
AudioEffectOptions _zoneReverbOptions;
|
||||||
AudioEffectOptions* _reverbOptions;
|
AudioEffectOptions* _reverbOptions;
|
||||||
AudioReverb _sourceReverb{ AudioConstants::SAMPLE_RATE };
|
AudioReverb _sourceReverb { AudioConstants::SAMPLE_RATE };
|
||||||
AudioReverb _listenerReverb{ AudioConstants::SAMPLE_RATE };
|
AudioReverb _listenerReverb { AudioConstants::SAMPLE_RATE };
|
||||||
AudioReverb _localReverb{ AudioConstants::SAMPLE_RATE };
|
AudioReverb _localReverb { AudioConstants::SAMPLE_RATE };
|
||||||
|
|
||||||
// possible streams needed for resample
|
// possible streams needed for resample
|
||||||
AudioSRC* _inputToNetworkResampler;
|
AudioSRC* _inputToNetworkResampler;
|
||||||
|
@ -412,18 +414,18 @@ private:
|
||||||
int16_t _networkScratchBuffer[AudioConstants::NETWORK_FRAME_SAMPLES_AMBISONIC];
|
int16_t _networkScratchBuffer[AudioConstants::NETWORK_FRAME_SAMPLES_AMBISONIC];
|
||||||
|
|
||||||
// for output audio (used by this thread)
|
// for output audio (used by this thread)
|
||||||
int _outputPeriod{ 0 };
|
int _outputPeriod { 0 };
|
||||||
float* _outputMixBuffer{ NULL };
|
float* _outputMixBuffer { NULL };
|
||||||
int16_t* _outputScratchBuffer{ NULL };
|
int16_t* _outputScratchBuffer { NULL };
|
||||||
std::atomic<float> _outputGain{ 1.0f };
|
std::atomic<float> _outputGain { 1.0f };
|
||||||
float _lastOutputGain{ 1.0f };
|
float _lastOutputGain { 1.0f };
|
||||||
|
|
||||||
// for local audio (used by audio injectors thread)
|
// for local audio (used by audio injectors thread)
|
||||||
std::atomic<float> _localInjectorGain{ 1.0f };
|
std::atomic<float> _localInjectorGain { 1.0f };
|
||||||
std::atomic<float> _systemInjectorGain{ 1.0f };
|
std::atomic<float> _systemInjectorGain { 1.0f };
|
||||||
float _localMixBuffer[AudioConstants::NETWORK_FRAME_SAMPLES_STEREO];
|
float _localMixBuffer[AudioConstants::NETWORK_FRAME_SAMPLES_STEREO];
|
||||||
int16_t _localScratchBuffer[AudioConstants::NETWORK_FRAME_SAMPLES_AMBISONIC];
|
int16_t _localScratchBuffer[AudioConstants::NETWORK_FRAME_SAMPLES_AMBISONIC];
|
||||||
float* _localOutputMixBuffer{ NULL };
|
float* _localOutputMixBuffer { NULL };
|
||||||
Mutex _localAudioMutex;
|
Mutex _localAudioMutex;
|
||||||
AudioLimiter _audioLimiter;
|
AudioLimiter _audioLimiter;
|
||||||
|
|
||||||
|
@ -437,9 +439,9 @@ private:
|
||||||
static const int WEBRTC_CHANNELS_MAX = 2;
|
static const int WEBRTC_CHANNELS_MAX = 2;
|
||||||
static const int WEBRTC_FRAMES_MAX = webrtc::AudioProcessing::kChunkSizeMs * WEBRTC_SAMPLE_RATE_MAX / 1000;
|
static const int WEBRTC_FRAMES_MAX = webrtc::AudioProcessing::kChunkSizeMs * WEBRTC_SAMPLE_RATE_MAX / 1000;
|
||||||
|
|
||||||
webrtc::AudioProcessing* _apm{ nullptr };
|
webrtc::AudioProcessing* _apm { nullptr };
|
||||||
|
|
||||||
int16_t _fifoFarEnd[WEBRTC_CHANNELS_MAX * WEBRTC_FRAMES_MAX]{};
|
int16_t _fifoFarEnd[WEBRTC_CHANNELS_MAX * WEBRTC_FRAMES_MAX] {};
|
||||||
int _numFifoFarEnd = 0; // numFrames saved in fifo
|
int _numFifoFarEnd = 0; // numFrames saved in fifo
|
||||||
|
|
||||||
void configureWebrtc();
|
void configureWebrtc();
|
||||||
|
@ -460,8 +462,8 @@ private:
|
||||||
|
|
||||||
AudioIOStats _stats;
|
AudioIOStats _stats;
|
||||||
|
|
||||||
AudioGate* _audioGate{ nullptr };
|
AudioGate* _audioGate { nullptr };
|
||||||
bool _audioGateOpen{ true };
|
bool _audioGateOpen { true };
|
||||||
|
|
||||||
AudioPositionGetter _positionGetter;
|
AudioPositionGetter _positionGetter;
|
||||||
AudioOrientationGetter _orientationGetter;
|
AudioOrientationGetter _orientationGetter;
|
||||||
|
@ -483,16 +485,16 @@ private:
|
||||||
|
|
||||||
AudioFileWav _audioFileWav;
|
AudioFileWav _audioFileWav;
|
||||||
|
|
||||||
bool _hasReceivedFirstPacket{ false };
|
bool _hasReceivedFirstPacket { false };
|
||||||
|
|
||||||
QVector<AudioInjectorPointer> _activeLocalAudioInjectors;
|
QVector<AudioInjectorPointer> _activeLocalAudioInjectors;
|
||||||
|
|
||||||
bool _isPlayingBackRecording{ false };
|
bool _isPlayingBackRecording { false };
|
||||||
bool _audioPaused{ false };
|
bool _audioPaused { false };
|
||||||
|
|
||||||
CodecPluginPointer _codec;
|
CodecPluginPointer _codec;
|
||||||
QString _selectedCodecName;
|
QString _selectedCodecName;
|
||||||
Encoder* _encoder{ nullptr }; // for outbound mic stream
|
Encoder* _encoder { nullptr }; // for outbound mic stream
|
||||||
|
|
||||||
RateCounter<> _silentOutbound;
|
RateCounter<> _silentOutbound;
|
||||||
RateCounter<> _audioOutbound;
|
RateCounter<> _audioOutbound;
|
||||||
|
@ -500,17 +502,17 @@ private:
|
||||||
RateCounter<> _audioInbound;
|
RateCounter<> _audioInbound;
|
||||||
|
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
bool _shouldRestartInputSetup{ true }; // Should we restart the input device because of an unintended stop?
|
bool _shouldRestartInputSetup { true }; // Should we restart the input device because of an unintended stop?
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
AudioSolo _solo;
|
AudioSolo _solo;
|
||||||
|
|
||||||
Mutex _checkDevicesMutex;
|
Mutex _checkDevicesMutex;
|
||||||
QTimer* _checkDevicesTimer{ nullptr };
|
QTimer* _checkDevicesTimer { nullptr };
|
||||||
Mutex _checkPeakValuesMutex;
|
Mutex _checkPeakValuesMutex;
|
||||||
QTimer* _checkPeakValuesTimer{ nullptr };
|
QTimer* _checkPeakValuesTimer { nullptr };
|
||||||
|
|
||||||
bool _isRecording{ false };
|
bool _isRecording { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AudioClient_h
|
#endif // hifi_AudioClient_h
|
||||||
|
|
|
@ -6,7 +6,7 @@ void HifiAudioDeviceInfo::setMode(QAudio::Mode mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HifiAudioDeviceInfo::setIsDefault(bool isDefault) {
|
void HifiAudioDeviceInfo::setIsDefault(bool isDefault) {
|
||||||
isDefault = isDefault;
|
_isDefault = isDefault;
|
||||||
setDeviceName();
|
setDeviceName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue