From db492eeddf785bf0ba7ac38b6f77a6e351981d8c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com>
Date: Fri, 3 Mar 2023 23:35:50 +0000
Subject: [PATCH] feat: audio and video API for enable and disable Will allow
 performance update when not using audio. Done for benchmark purposes.

---
 frontends/web/ts/gb.ts | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/frontends/web/ts/gb.ts b/frontends/web/ts/gb.ts
index da6cdb78..ff789a00 100644
--- a/frontends/web/ts/gb.ts
+++ b/frontends/web/ts/gb.ts
@@ -653,6 +653,30 @@ export class GameboyEmulator extends EmulatorBase implements Emulator {
         this.gameBoy?.key_lift(keyCode);
     }
 
+    pauseVideo() {
+        this.gameBoy?.set_ppu_enabled(false);
+    }
+
+    resumeVideo() {
+        this.gameBoy?.set_ppu_enabled(true);
+    }
+
+    getVideoState(): boolean {
+        return this.gameBoy?.get_ppu_enabled() ?? false;
+    }
+
+    pauseAudio() {
+        this.gameBoy?.set_apu_enabled(false);
+    }
+
+    resumeAudio() {
+        this.gameBoy?.set_apu_enabled(true);
+    }
+
+    getAudioState(): boolean {
+        return this.gameBoy?.get_apu_enabled() ?? false;
+    }
+
     getTile(index: number): Uint8Array {
         return this.gameBoy?.get_tile_buffer(index) ?? new Uint8Array();
     }
-- 
GitLab