From 866c38e7df6c2c310e9ab9cf0ed7ff190db9ae94 Mon Sep 17 00:00:00 2001 From: Christoffer Sterner Date: Sun, 1 Feb 2015 16:58:59 +0100 Subject: [PATCH] Add support for playback audio slider setting --- src/audio.cpp | 5 +++++ src/audio.h | 1 + src/widget/form/settings/avform.cpp | 6 ++++++ src/widget/form/settings/avform.h | 1 + src/widget/form/settings/avsettings.ui | 3 +-- 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/audio.cpp b/src/audio.cpp index 2037f0b77..ecc3c95ce 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -41,6 +41,7 @@ ALCdevice* Audio::alInDev{nullptr}; ALCdevice* Audio::alOutDev{nullptr}; ALCcontext* Audio::alContext{nullptr}; ALuint Audio::alMainSource{0}; +float Audio::outputVolume{1.0}; void audioDebugLog(QString msg) { @@ -261,7 +262,10 @@ void Audio::playGroupAudio(int group, int peer, const int16_t* data, return; if (!call.alSources.contains(peer)) + { alGenSources(1, &call.alSources[peer]); + alSourcef(call.alSources[peer], AL_GAIN, outputVolume); + } playAudioBuffer(call.alSources[peer], data, samples, channels, sample_rate); } @@ -301,6 +305,7 @@ void Audio::playAudioBuffer(ALuint alSource, const int16_t *data, int samples, u ALint state; alGetSourcei(alSource, AL_SOURCE_STATE, &state); + alSourcef(alSource, AL_GAIN, outputVolume); if (state != AL_PLAYING) alSourcePlay(alSource); } diff --git a/src/audio.h b/src/audio.h index c27c47aec..d43e60071 100644 --- a/src/audio.h +++ b/src/audio.h @@ -73,6 +73,7 @@ public: static QThread* audioThread; static ALCcontext* alContext; static ALuint alMainSource; + static float outputVolume; private: explicit Audio()=default; diff --git a/src/widget/form/settings/avform.cpp b/src/widget/form/settings/avform.cpp index 233e0a206..3c170821e 100644 --- a/src/widget/form/settings/avform.cpp +++ b/src/widget/form/settings/avform.cpp @@ -47,6 +47,7 @@ AVForm::AVForm() : connect(bodyUI->outDevCombobox, qcomboboxIndexChanged, this, &AVForm::onOutDevChanged); connect(bodyUI->filterAudio, SIGNAL(toggled(bool)), this, SLOT(onFilterAudioToggled(bool))); connect(bodyUI->rescanButton, &QPushButton::clicked, this, [=](){getAudioInDevices(); getAudioOutDevices();}); + bodyUI->playbackSlider->setValue(100); } AVForm::~AVForm() @@ -258,3 +259,8 @@ void AVForm::on_ContrastSlider_valueChanged(int value) { Camera::getInstance()->setProp(Camera::CONTRAST, value / 100.0); } + +void AVForm::on_playbackSlider_valueChanged(int value) +{ + Audio::getInstance().outputVolume = value / 100.0; +} diff --git a/src/widget/form/settings/avform.h b/src/widget/form/settings/avform.h index 5f0d95872..9b3980189 100644 --- a/src/widget/form/settings/avform.h +++ b/src/widget/form/settings/avform.h @@ -53,6 +53,7 @@ private slots: void onInDevChanged(const QString& deviceDescriptor); void onOutDevChanged(const QString& deviceDescriptor); void onFilterAudioToggled(bool filterAudio); + void on_playbackSlider_valueChanged(int value); // camera void onPropProbingFinished(Camera::Prop prop, double val); diff --git a/src/widget/form/settings/avsettings.ui b/src/widget/form/settings/avsettings.ui index b2557b77a..81cb23026 100644 --- a/src/widget/form/settings/avsettings.ui +++ b/src/widget/form/settings/avsettings.ui @@ -61,8 +61,7 @@ Qt::Horizontal - Use slider to set volume of your speakers. -WARNING: slider is not supposed to work yet. + Use slider to set volume of your speakers.