-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #443 from 4ms/cpu-overload-restart
Audio overload causes a retry before stopping audio
- Loading branch information
Showing
19 changed files
with
386 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#pragma once | ||
#include "console/pr_dbg.hh" | ||
#include "drivers/stm32xx.h" | ||
#include <atomic> | ||
#include <cstdint> | ||
|
||
namespace MetaModule | ||
{ | ||
|
||
struct AudioOverrunHandler { | ||
void start_retrying() { | ||
retrying = true; | ||
} | ||
|
||
bool is_retrying() const { | ||
return retrying; | ||
} | ||
|
||
void reset() { | ||
retrying = false; | ||
} | ||
|
||
void set_max_retry(uint32_t max_times) { | ||
max_retries = max_times; | ||
} | ||
|
||
bool handle() { | ||
// if we've gone 1 sec without overrunning, then consider this a new overrun | ||
uint64_t tm = PL1_GetCurrentPhysicalValue(); | ||
if (tm - last_overrun < 2'400'000) { | ||
overrun_count++; | ||
} else { | ||
last_overrun = tm; | ||
pr_dbg("Reset count from %u\n", overrun_count); | ||
overrun_count = 0; | ||
} | ||
|
||
return (overrun_count < max_retries); | ||
} | ||
|
||
private: | ||
uint32_t overrun_count = 0; | ||
uint64_t last_overrun = 0; | ||
unsigned max_retries = 0; | ||
|
||
// bool retrying = false; | ||
std::atomic<bool> retrying = false; | ||
}; | ||
} // namespace MetaModule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
#include "delay.hh" | ||
#include "gui/helpers/lv_helpers.hh" | ||
#include "lvgl.h" | ||
#include "metaparams.hh" | ||
|
||
namespace MetaModule | ||
{ | ||
|
||
inline void update_load_text(MetaParams const &metaparams, lv_obj_t *meter) { | ||
if (metaparams.audio_overruns > 0) { | ||
lv_obj_set_style_bg_color(meter, lv_color_hex(0xFF0000), LV_PART_MAIN); | ||
lv_obj_set_style_bg_opa(meter, LV_OPA_100, LV_PART_MAIN); | ||
|
||
lv_obj_set_style_text_color(meter, lv_color_white(), LV_PART_MAIN); | ||
|
||
lv_label_set_text(meter, "OVER"); | ||
|
||
} else { | ||
lv_label_set_text_fmt(meter, "%d%%", metaparams.audio_load); | ||
lv_obj_set_style_text_color(meter, lv_color_hex(0xFD8B18), LV_PART_MAIN); | ||
lv_obj_set_style_outline_opa(meter, LV_OPA_0, LV_PART_MAIN); | ||
lv_obj_set_style_bg_opa(meter, LV_OPA_0, LV_PART_MAIN); | ||
} | ||
lv_show(meter); | ||
} | ||
|
||
} // namespace MetaModule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.