1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Add support for playback audio slider setting

This commit is contained in:
Christoffer Sterner 2015-02-01 16:58:59 +01:00
parent 58b3e66c6b
commit 866c38e7df
5 changed files with 14 additions and 2 deletions

View File

@ -41,6 +41,7 @@ ALCdevice* Audio::alInDev{nullptr};
ALCdevice* Audio::alOutDev{nullptr}; ALCdevice* Audio::alOutDev{nullptr};
ALCcontext* Audio::alContext{nullptr}; ALCcontext* Audio::alContext{nullptr};
ALuint Audio::alMainSource{0}; ALuint Audio::alMainSource{0};
float Audio::outputVolume{1.0};
void audioDebugLog(QString msg) void audioDebugLog(QString msg)
{ {
@ -261,7 +262,10 @@ void Audio::playGroupAudio(int group, int peer, const int16_t* data,
return; return;
if (!call.alSources.contains(peer)) if (!call.alSources.contains(peer))
{
alGenSources(1, &call.alSources[peer]); alGenSources(1, &call.alSources[peer]);
alSourcef(call.alSources[peer], AL_GAIN, outputVolume);
}
playAudioBuffer(call.alSources[peer], data, samples, channels, sample_rate); 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; ALint state;
alGetSourcei(alSource, AL_SOURCE_STATE, &state); alGetSourcei(alSource, AL_SOURCE_STATE, &state);
alSourcef(alSource, AL_GAIN, outputVolume);
if (state != AL_PLAYING) if (state != AL_PLAYING)
alSourcePlay(alSource); alSourcePlay(alSource);
} }

View File

@ -73,6 +73,7 @@ public:
static QThread* audioThread; static QThread* audioThread;
static ALCcontext* alContext; static ALCcontext* alContext;
static ALuint alMainSource; static ALuint alMainSource;
static float outputVolume;
private: private:
explicit Audio()=default; explicit Audio()=default;

View File

@ -47,6 +47,7 @@ AVForm::AVForm() :
connect(bodyUI->outDevCombobox, qcomboboxIndexChanged, this, &AVForm::onOutDevChanged); connect(bodyUI->outDevCombobox, qcomboboxIndexChanged, this, &AVForm::onOutDevChanged);
connect(bodyUI->filterAudio, SIGNAL(toggled(bool)), this, SLOT(onFilterAudioToggled(bool))); connect(bodyUI->filterAudio, SIGNAL(toggled(bool)), this, SLOT(onFilterAudioToggled(bool)));
connect(bodyUI->rescanButton, &QPushButton::clicked, this, [=](){getAudioInDevices(); getAudioOutDevices();}); connect(bodyUI->rescanButton, &QPushButton::clicked, this, [=](){getAudioInDevices(); getAudioOutDevices();});
bodyUI->playbackSlider->setValue(100);
} }
AVForm::~AVForm() AVForm::~AVForm()
@ -258,3 +259,8 @@ void AVForm::on_ContrastSlider_valueChanged(int value)
{ {
Camera::getInstance()->setProp(Camera::CONTRAST, value / 100.0); Camera::getInstance()->setProp(Camera::CONTRAST, value / 100.0);
} }
void AVForm::on_playbackSlider_valueChanged(int value)
{
Audio::getInstance().outputVolume = value / 100.0;
}

View File

@ -53,6 +53,7 @@ private slots:
void onInDevChanged(const QString& deviceDescriptor); void onInDevChanged(const QString& deviceDescriptor);
void onOutDevChanged(const QString& deviceDescriptor); void onOutDevChanged(const QString& deviceDescriptor);
void onFilterAudioToggled(bool filterAudio); void onFilterAudioToggled(bool filterAudio);
void on_playbackSlider_valueChanged(int value);
// camera // camera
void onPropProbingFinished(Camera::Prop prop, double val); void onPropProbingFinished(Camera::Prop prop, double val);

View File

@ -61,8 +61,7 @@
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Use slider to set volume of your speakers. <string>Use slider to set volume of your speakers.</string>
WARNING: slider is not supposed to work yet.</string>
</property> </property>
</widget> </widget>
</item> </item>