From b3a0ad018c1e25f7df68ccb1b3629d73a38a35db Mon Sep 17 00:00:00 2001 From: Totoo Date: Sat, 28 Sep 2024 14:48:32 +0200 Subject: [PATCH] Limit 50 items per page in sndboard. Maybe solves oom (#2263) --- firmware/application/apps/soundboard_app.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/firmware/application/apps/soundboard_app.cpp b/firmware/application/apps/soundboard_app.cpp index 9a00b98c..b8af1d0f 100644 --- a/firmware/application/apps/soundboard_app.cpp +++ b/firmware/application/apps/soundboard_app.cpp @@ -35,6 +35,8 @@ using namespace portapack; namespace ui { +#define FILE_PER_PAGE 50 + bool SoundBoardView::is_active() const { return (bool)replay_thread; } @@ -178,9 +180,9 @@ void SoundBoardView::refresh_list() { if ((reader->channels() == 1) && ((reader->bits_per_sample() == 8) || (reader->bits_per_sample() == 16))) { // sounds[c].ms_duration = reader->ms_duration(); // sounds[c].path = u"WAV/" + entry.path().native(); - if (count >= (page - 1) * 100 && count < page * 100) { + if (count >= (page - 1) * FILE_PER_PAGE && count < page * FILE_PER_PAGE) { file_list.push_back(entry.path()); - if (file_list.size() == 100) { + if (file_list.size() == FILE_PER_PAGE) { page++; break; } @@ -225,7 +227,7 @@ void SoundBoardView::refresh_list() { menu_view.set_highlighted(0); // Refresh } - if (file_list.size() < 100) { + if (file_list.size() < FILE_PER_PAGE) { page = 1; } }