Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions app/src/main/java/com/winlator/xenvironment/XEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,6 @@ public class XEnvironment implements Iterable<EnvironmentComponent> {

private boolean winetricksRunning = false;

private final AudioManager audioManager;
private boolean audioCallbackRegistered = false;
private final AudioDeviceCallback audioDeviceCallback = new AudioDeviceCallback() {
@Override
public void onAudioDevicesAdded(AudioDeviceInfo[] addedDevices) {
// Handle newly added audio devices (e.g., headphones connected)
for (AudioDeviceInfo device : addedDevices) {
if (device.isSink()) {
restartAudioComponent();
}
}
}

@Override
public void onAudioDevicesRemoved(AudioDeviceInfo[] removedDevices) {
// Handle removed audio devices (e.g., headphones disconnected)
for (AudioDeviceInfo device : removedDevices) {
if (device.isSink()) {
restartAudioComponent();
}
}
}
};

public synchronized boolean isWinetricksRunning() {
return winetricksRunning;
}
Expand All @@ -61,9 +37,6 @@ public synchronized void setWinetricksRunning(boolean running) {
public XEnvironment(Context context, ImageFs imageFs) {
this.context = context;
this.imageFs = imageFs;
this.audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
this.audioManager.registerAudioDeviceCallback(audioDeviceCallback, null);
this.audioCallbackRegistered = true;
}

public Context getContext() {
Expand Down Expand Up @@ -126,18 +99,4 @@ public void onResume() {
BionicProgramLauncherComponent bionicProgramLauncherComponent = getComponent(BionicProgramLauncherComponent.class);
if (bionicProgramLauncherComponent != null) bionicProgramLauncherComponent.resumeProcess();
}

private void restartAudioComponent() {
final ALSAServerComponent alsaServerComponent = getComponent(ALSAServerComponent.class);
if (alsaServerComponent != null) {
alsaServerComponent.stop();
alsaServerComponent.start();
}

final PulseAudioComponent pulseAudioComponent = getComponent(PulseAudioComponent.class);
if (pulseAudioComponent != null) {
//pulseAudioComponent.stop(); stop is already called inside start function
pulseAudioComponent.start();
}
}
}
Loading