Skip to content

Commit

Permalink
LLE audio: allow to mute the audio.
Browse files Browse the repository at this point in the history
  • Loading branch information
gid15 committed Dec 7, 2018
1 parent 1e4223b commit 05d67ab
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/jpcsp/memory/mmio/MMIOHandlerAudio.java
Expand Up @@ -24,6 +24,7 @@

import jpcsp.Allegrex.compiler.RuntimeContextLLE;
import jpcsp.HLE.modules.sceAudio;
import jpcsp.hardware.Audio;
import jpcsp.memory.mmio.audio.AudioLine;
import jpcsp.state.StateInputStream;
import jpcsp.state.StateOutputStream;
Expand Down Expand Up @@ -135,6 +136,11 @@ private int sendAudioData(int value, int line, int index, int[] data, int interr
if (log.isTraceEnabled()) {
log.trace(String.format("sendAudioData value=0x%08X, line=%d, index=0x%X, interrupt=%d", value, line, index, interrupt));
}

if (Audio.isMuted()) {
value = 0;
}

data[index++] = value;

if (index >= data.length) {
Expand Down
15 changes: 15 additions & 0 deletions src/jpcsp/memory/mmio/audio/AudioLine.java
Expand Up @@ -23,6 +23,8 @@
import java.nio.ByteOrder;

import org.apache.log4j.Logger;
import org.lwjgl.LWJGLException;
import org.lwjgl.openal.AL;
import org.lwjgl.openal.AL10;

import jpcsp.memory.mmio.MMIOHandlerAudio;
Expand All @@ -39,11 +41,24 @@ public class AudioLine implements IState {
private int frequency = 44100;

public AudioLine() {
initOpenAL();

soundBufferManager = SoundBufferManager.getInstance();
alSource = AL10.alGenSources();
AL10.alSourcei(alSource, AL10.AL_LOOPING, AL10.AL_FALSE);
}

private static void initOpenAL() {
// Initialize OpenAL
if (!AL.isCreated()) {
try {
AL.create();
} catch (LWJGLException e) {
log.error(e);
}
}
}

private void alSourcePlay() {
int state = AL10.alGetSourcei(alSource, AL10.AL_SOURCE_STATE);
if (state != AL10.AL_PLAYING) {
Expand Down

0 comments on commit 05d67ab

Please sign in to comment.