Skip to content
Permalink
Browse files

Merge PR #3068: Added a "Undo Idle action upon activity" setting.

  • Loading branch information...
mkrautz committed May 14, 2017
2 parents 10511de + 48c2cc3 commit 5c9a46e98d7cb6b15e2b8e37d3c8272e7909899c
@@ -143,6 +143,7 @@ void AudioInputDialog::load(const Settings &r) {
// Idle auto actions
qsbIdle->setValue(r.iIdleTime / 60);
loadComboBox(qcbIdleAction, r.iaeIdleAction);
loadCheckBox(qcbUndoIdleAction, r.bUndoIdleActionUponActivity);

int echo = 0;
if (r.bEcho)
@@ -168,6 +169,7 @@ void AudioInputDialog::save() const {
// Idle auto actions
s.iIdleTime = qsbIdle->value() * 60;
s.iaeIdleAction = static_cast<Settings::IdleAction>(qcbIdleAction->currentIndex());
s.bUndoIdleActionUponActivity = qcbUndoIdleAction->isChecked();

s.bShowPTTButtonWindow = qcbPushWindow->isChecked();
s.bTxAudioCue = qcbPushClick->isChecked();
@@ -397,6 +399,7 @@ void AudioInputDialog::on_qcbIdleAction_currentIndexChanged(int v) {
qlIdle->setEnabled(enabled);
qlIdle2->setEnabled(enabled);
qsbIdle->setEnabled(enabled);
qcbUndoIdleAction->setEnabled(enabled);
}

AudioOutputDialog::AudioOutputDialog(Settings &st) : ConfigWidget(st) {
@@ -78,6 +78,7 @@ AudioInput::AudioInput() : opusBuffer(g.s.iFramesPerPacket * (SAMPLE_RATE / 100)

umtType = MessageHandler::UDPVoiceCELTAlpha;

activityState = ActivityStateActive;
cCodec = NULL;
ceEncoder = NULL;

@@ -811,17 +812,27 @@ void AudioInput::encodeAudioFrame() {
if (! bIsSpeech && ! bPreviousVoice) {
iBitrate = 0;

if (g.s.iaeIdleAction != Settings::Nothing && ((tIdle.elapsed() / 1000000ULL) > g.s.iIdleTime)) {

if ((tIdle.elapsed() / 1000000ULL) > g.s.iIdleTime) {
activityState = ActivityStateIdle;
tIdle.restart();
if (g.s.iaeIdleAction == Settings::Deafen && !g.s.bDeaf) {
tIdle.restart();
emit doDeaf();
} else if (g.s.iaeIdleAction == Settings::Mute && !g.s.bMute) {
tIdle.restart();
emit doMute();
}
}

if (activityState == ActivityStateReturnedFromIdle) {
activityState = ActivityStateActive;
if (g.s.iaeIdleAction != Settings::Nothing && g.s.bUndoIdleActionUponActivity) {
if (g.s.iaeIdleAction == Settings::Deafen && g.s.bDeaf) {
emit doDeaf();
} else if (g.s.iaeIdleAction == Settings::Mute && g.s.bMute) {
emit doMute();
}
}
}

spx_int32_t increment = 0;
speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_AGC_INCREMENT, &increment);
return;
@@ -142,6 +142,10 @@ class AudioInput : public QThread {
void doDeaf();
void doMute();
public:
typedef enum { ActivityStateIdle, ActivityStateReturnedFromIdle, ActivityStateActive } ActivityState;

ActivityState activityState;

bool bResetProcessor;

Timer tIdle;
@@ -786,6 +786,16 @@
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="QCheckBox" name="qcbUndoIdleAction">
<property name="toolTip">
<string>The idle action will be reversed upon any key or mouse button input</string>
</property>
<property name="text">
<string>Undo Idle action upon activity</string>
</property>
</widget>
</item>
<item row="3" column="4">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@@ -849,8 +849,14 @@ bool GlobalShortcutEngine::handleButton(const QVariant &button, bool down) {

if (down) {
AudioInputPtr ai = g.ai;
if (ai.get())
if (ai.get()) {
// XXX: This is a data race: we write to ai->activityState
// (accessed by the AudioInput thread) from the main thread.
if (ai->activityState == AudioInput::ActivityStateIdle) {
ai->activityState = AudioInput::ActivityStateReturnedFromIdle;
}
ai->tIdle.restart();
}
}

int idx = qlButtonList.indexOf(button);
@@ -244,6 +244,7 @@ Settings::Settings() {
// Idle auto actions
iIdleTime = 5 * 60;
iaeIdleAction = Nothing;
bUndoIdleActionUponActivity = false;

vsVAD = Amplitude;
fVADmin = 0.80f;
@@ -611,6 +612,7 @@ void Settings::load(QSettings* settings_ptr) {
// Idle auto actions
SAVELOAD(iIdleTime, "audio/idletime");
LOADENUM(iaeIdleAction, "audio/idleaction");
SAVELOAD(bUndoIdleActionUponActivity, "audio/undoidleactionuponactivity");

SAVELOAD(fAudioMinDistance, "audio/mindistance");
SAVELOAD(fAudioMaxDistance, "audio/maxdistance");
@@ -938,6 +940,7 @@ void Settings::save() {
// Idle auto actions
SAVELOAD(iIdleTime, "audio/idletime");
SAVELOAD(iaeIdleAction, "audio/idleaction");
SAVELOAD(bUndoIdleActionUponActivity, "audio/undoidleactionuponactivity");

SAVELOAD(fAudioMinDistance, "audio/mindistance");
SAVELOAD(fAudioMaxDistance, "audio/maxdistance");
@@ -187,6 +187,7 @@ struct Settings {
// Idle auto actions
unsigned int iIdleTime;
IdleAction iaeIdleAction;
bool bUndoIdleActionUponActivity;

VADSource vsVAD;
float fVADmin, fVADmax;

0 comments on commit 5c9a46e

Please sign in to comment.
You can’t perform that action at this time.