Skip to content

Commit

Permalink
Android: Implement enable audio option (#652)
Browse files Browse the repository at this point in the history
* AlberDriver: add static void to enable audio

* implement enable audio option

* Typo
  • Loading branch information
Ishan09811 authored Nov 30, 2024
1 parent 286ec8a commit e1f830c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class AlberDriver {

public static native void setShaderJitEnabled(boolean enable);
public static native void setAccurateShaderMulEnable(boolean enable);
public static native void setAudioEnabled(boolean enable);

public static int openDocument(String path, String mode) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable S
setItemClick("performanceMonitor", pref -> GlobalConfig.set(GlobalConfig.KEY_SHOW_PERFORMANCE_OVERLAY, ((SwitchPreferenceCompat) pref).isChecked()));
setItemClick("shaderJit", pref -> GlobalConfig.set(GlobalConfig.KEY_SHADER_JIT, ((SwitchPreferenceCompat) pref).isChecked()));
setItemClick("accurateShaderMul", pref -> GlobalConfig.set(GlobalConfig.KEY_ACCURATE_SHADER_MULTIPLY, ((SwitchPreferenceCompat) pref).isChecked()));
setItemClick("enableAudio", pref -> GlobalConfig.set(GlobalConfig.KEY_ENABLE_AUDIO, ((SwitchPreferenceCompat) pref).isChecked()));
setItemClick("loggerService", pref -> {
boolean checked = ((SwitchPreferenceCompat) pref).isChecked();
Context ctx = PandroidApplication.getAppContext();
Expand All @@ -48,5 +49,6 @@ private void refresh() {
((SwitchPreferenceCompat) findPreference("loggerService")).setChecked(GlobalConfig.get(GlobalConfig.KEY_LOGGER_SERVICE));
((SwitchPreferenceCompat) findPreference("shaderJit")).setChecked(GlobalConfig.get(GlobalConfig.KEY_SHADER_JIT));
((SwitchPreferenceCompat) findPreference("accurateShaderMul")).setChecked(GlobalConfig.get(GlobalConfig.KEY_ACCURATE_SHADER_MULTIPLY));
((SwitchPreferenceCompat) findPreference("enableAudio")).setChecked(GlobalConfig.get(GlobalConfig.KEY_ENABLE_AUDIO));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class GlobalConfig {

public static final Key<Boolean> KEY_SHADER_JIT = new Key<>("emu.shader_jit", true);
public static final Key<Boolean> KEY_ACCURATE_SHADER_MULTIPLY = new Key<>("emu.accurate_shader_mul", false);
public static final Key<Boolean> KEY_ENABLE_AUDIO = new Key<>("emu.enable_audio", true);
public static final Key<Boolean> KEY_PICTURE_IN_PICTURE = new Key<>("app.behavior.pictureInPicture", false);
public static final Key<Boolean> KEY_SHOW_PERFORMANCE_OVERLAY = new Key<>("dev.performanceOverlay", false);
public static final Key<Boolean> KEY_LOGGER_SERVICE = new Key<>("dev.loggerService", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public void onSurfaceCreated(GL10 unused, EGLConfig config) {
AlberDriver.Initialize();
AlberDriver.setShaderJitEnabled(GlobalConfig.get(GlobalConfig.KEY_SHADER_JIT));
AlberDriver.setAccurateShaderMulEnable(GlobalConfig.get(GlobalConfig.KEY_ACCURATE_SHADER_MULTIPLY));
AlberDriver.setAudioEnabled(GlobalConfig.get(GlobalConfig.KEY_ENABLE_AUDIO));

// If loading the ROM failed, display an error message and early exit
if (!AlberDriver.LoadRom(romPath)) {
Expand Down
3 changes: 3 additions & 0 deletions src/pandroid/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
<string name="graphics">Graphics</string>
<string name="pref_shader_jit_title">Shader JIT</string>
<string name="pref_shader_jit_summary">Use shader recompiler.</string>
<string name="audio">Audio</string>
<string name="pref_enable_audio_title">Enable Audio</string>
<string name="pref_enable_audio_desc">Audio will be enabled</string>
<string name="tools">Tools</string>
<string name="pref_logger_service_title">Logger</string>
<string name="pref_logger_service_summary">Store application logs to file.</string>
Expand Down
14 changes: 13 additions & 1 deletion src/pandroid/app/src/main/res/xml/advanced_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,16 @@
app:iconSpaceReserved="false"/>

</PreferenceCategory>
</PreferenceScreen>

<PreferenceCategory
app:iconSpaceReserved="false"
app:title="@string/audio" >

<SwitchPreferenceCompat
app:key="enableAudio"
app:title="@string/pref_enable_audio_title"
app:summary="@string/pref_enable_audio_desc"
app:iconSpaceReserved="false" />

</PreferenceCategory>
</PreferenceScreen>

0 comments on commit e1f830c

Please sign in to comment.