Skip to content

Commit

Permalink
Limit 50 items per page in sndboard. Maybe solves oom (#2263)
Browse files Browse the repository at this point in the history
  • Loading branch information
htotoo authored Sep 28, 2024
1 parent a21e9ca commit b3a0ad0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions firmware/application/apps/soundboard_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ using namespace portapack;

namespace ui {

#define FILE_PER_PAGE 50

bool SoundBoardView::is_active() const {
return (bool)replay_thread;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit b3a0ad0

Please sign in to comment.