fix: fix performance issue in Music app

This commit is contained in:
2026-03-20 22:23:22 +01:00
parent cc5c28581c
commit eb0e3ad6d5
4 changed files with 9 additions and 8 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
+9 -8
View File
@@ -1031,18 +1031,17 @@ extern "C" void _start() {
while (true) { while (true) {
Montauk::WinEvent ev; Montauk::WinEvent ev;
int r = montauk::win_poll(win_id, &ev);
if (r < 0) break;
bool redraw = false; bool redraw = false;
bool quit = false;
int r;
if (r > 0) { // Drain all pending events before rendering
if (ev.type == 3) break; // close while ((r = montauk::win_poll(win_id, &ev)) > 0) {
if (ev.type == 3) { quit = true; break; }
// Keyboard // Keyboard
if (ev.type == 0 && ev.key.pressed) { if (ev.type == 0 && ev.key.pressed) {
if (ev.key.scancode == 0x01) break; // Escape if (ev.key.scancode == 0x01) { quit = true; break; }
if (ev.key.ascii == ' ') { if (ev.key.ascii == ' ') {
if (g.play_state == PlayState::Stopped && g.file_count > 0) if (g.play_state == PlayState::Stopped && g.file_count > 0)
start_track(g.current_track >= 0 ? g.current_track : 0); start_track(g.current_track >= 0 ? g.current_track : 0);
@@ -1064,7 +1063,7 @@ extern "C" void _start() {
} }
} }
// Mouse click // Mouse
if (ev.type == 1) { if (ev.type == 1) {
bool clicked = (ev.mouse.buttons & 1) && !(ev.mouse.prev_buttons & 1); bool clicked = (ev.mouse.buttons & 1) && !(ev.mouse.prev_buttons & 1);
bool released = !(ev.mouse.buttons & 1) && (ev.mouse.prev_buttons & 1); bool released = !(ev.mouse.buttons & 1) && (ev.mouse.prev_buttons & 1);
@@ -1136,6 +1135,8 @@ extern "C" void _start() {
} }
} }
if (quit || r < 0) break;
// Feed audio data to the device // Feed audio data to the device
feed_audio(); feed_audio();