Skip to content

Commit 132d116

Browse files
committed
Format sources
1 parent 50486a2 commit 132d116

File tree

3 files changed

+31
-39
lines changed

3 files changed

+31
-39
lines changed
Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
#pragma once
22

3-
#include <mutex>
4-
#include <chrono>
53
#include <android/log.h>
4+
#include <chrono>
5+
#include <mutex>
66

7-
class FecChangeController
8-
{
7+
class FecChangeController {
98
static constexpr const char *TAG = "FecChangeController";
10-
public:
9+
10+
public:
1111
/// \brief Query the current (possibly decayed) fec_change value.
1212
/// Call this as often as you like; the class handles its own timing.
13-
int value()
14-
{
15-
if (!mEnabled)
16-
return 0;
13+
int value() {
14+
if (!mEnabled) return 0;
1715

1816
std::lock_guard<std::mutex> lock(mx_);
1917
decayLocked_();
@@ -22,52 +20,47 @@ class FecChangeController
2220

2321
/// \brief Raise fec_change. If newValue <= current, the call is ignored.
2422
/// A successful bump resets the 5-second “hold” timer.
25-
void bump(int newValue)
26-
{
23+
void bump(int newValue) {
2724
std::lock_guard<std::mutex> lock(mx_);
2825
if (newValue > val_) {
2926
__android_log_print(ANDROID_LOG_ERROR, TAG, "bumping FEC: %d", newValue);
3027

31-
val_ = newValue;
28+
val_ = newValue;
3229
lastChange_ = Clock::now();
3330
}
3431
}
3532

36-
void setEnabled(bool use){
37-
mEnabled = use;
38-
}
33+
void setEnabled(bool use) { mEnabled = use; }
3934

40-
private:
35+
private:
4136
using Clock = std::chrono::steady_clock;
42-
static constexpr std::chrono::seconds kTick{1}; // length of one hold/decay window
37+
static constexpr std::chrono::seconds kTick{1}; // length of one hold/decay window
4338

44-
void decayLocked_()
45-
{
39+
void decayLocked_() {
4640
if (val_ == 0) return;
4741

48-
auto now = Clock::now();
42+
auto now = Clock::now();
4943
auto elapsed = now - lastChange_;
5044

5145
// Still inside the mandatory 5-second hold? Do nothing.
5246
if (elapsed < kTick) return;
5347

5448
// How many *full* ticks have passed since lastChange_?
5549
auto ticks = std::chrono::duration_cast<std::chrono::seconds>(elapsed).count() / kTick.count();
56-
if (ticks == 0) return; // safety net (shouldn’t hit)
50+
if (ticks == 0) return; // safety net (shouldn’t hit)
5751

5852
int decayed = val_ - static_cast<int>(ticks);
5953
if (decayed < 0) decayed = 0;
6054

6155
// Commit the decay and anchor lastChange_ on the most recent tick boundary
6256
if (decayed != val_) {
63-
val_ = decayed;
57+
val_ = decayed;
6458
lastChange_ += kTick * ticks;
6559
}
6660
}
6761

68-
int val_ {0};
69-
Clock::time_point lastChange_ {Clock::now()};
70-
std::mutex mx_;
62+
int val_{0};
63+
Clock::time_point lastChange_{Clock::now()};
64+
std::mutex mx_;
7165
bool mEnabled = false;
7266
};
73-

app/wfbngrtl8812/src/main/cpp/WfbngLink.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@
3333
#undef TAG
3434
#define TAG "pixelpilot"
3535

36-
#define CRASH() do{ int* i=0; *i = 42; }while(0)
36+
#define CRASH() \
37+
do { \
38+
int *i = 0; \
39+
*i = 42; \
40+
} while (0)
3741

3842
std::string generate_random_string(size_t length) {
3943
const std::string characters = "abcdefghijklmnopqrstuvwxyz";
@@ -470,16 +474,11 @@ void WfbngLink::start_link_quality_thread(int fd) {
470474
if (quality.lost_last_second > 2)
471475
fec.bump(5);
472476
else {
473-
if(quality.recovered_last_second > 30)
474-
fec.bump(5);
475-
if (quality.recovered_last_second > 24)
476-
fec.bump(3);
477-
if (quality.recovered_last_second > 22)
478-
fec.bump(2);
479-
if (quality.recovered_last_second > 18)
480-
fec.bump(1);
481-
if (quality.recovered_last_second < 18)
482-
fec.bump(0);
477+
if (quality.recovered_last_second > 30) fec.bump(5);
478+
if (quality.recovered_last_second > 24) fec.bump(3);
479+
if (quality.recovered_last_second > 22) fec.bump(2);
480+
if (quality.recovered_last_second > 18) fec.bump(1);
481+
if (quality.recovered_last_second < 18) fec.bump(0);
483482
}
484483

485484
snprintf(message + sizeof(len),
@@ -560,7 +559,7 @@ extern "C" JNIEXPORT void JNICALL Java_com_openipc_wfbngrtl8812_WfbNgLink_native
560559
}
561560

562561
extern "C" JNIEXPORT void JNICALL Java_com_openipc_wfbngrtl8812_WfbNgLink_nativeSetUseFec(JNIEnv *env,
563-
jclass clazz,
562+
jclass clazz,
564563
jlong wfbngLinkN,
565564
jint use) {
566565
WfbngLink *link = native(wfbngLinkN);

app/wfbngrtl8812/src/main/cpp/WfbngLink.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#define FPV_VR_WFBNG_LINK_H
33

44
#include "FecChangeController.h"
5-
#include "TxFrame.h"
65
#include "SignalQualityCalculator.h"
6+
#include "TxFrame.h"
77

88
extern "C" {
99
#include "wfb-ng/src/fec.h"

0 commit comments

Comments
 (0)