Skip to content

Commit

Permalink
StMovieActivity - configure path ALSOFT_CONF to /sdcard/Android/data/…
Browse files Browse the repository at this point in the history
…com.sview/shared_prefs/alsoft.conf
  • Loading branch information
gkv311 committed Feb 17, 2025
1 parent 3b27f12 commit 859c1f6
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion sview/src/com/sview/StMovieActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package com.sview;

import android.os.Bundle;
import android.system.Os;

/**
* Customize StActivity
Expand Down Expand Up @@ -37,9 +38,40 @@ public String getCurrentTitle() {
*/
@Override
public void onCreate(Bundle theSavedInstanceState) {
if(android.os.Build.VERSION.SDK_INT >= 21) {
// configure OpenAL Soft environment variables before loading native libraries
//setenv("ALSOFT_LOGLEVEL", "3", true);

String aRootInt = "/data/data/";
String aRootExt = "/sdcard/Android/data/";
java.io.File aRootExtF = new java.io.File(aRootExt);
String aRoot = aRootExtF.isDirectory() ? aRootExt : aRootInt;

String aPackageName = getApplicationContext().getPackageName();
String aConfDirs = aRoot + aPackageName + "/shared_prefs";
// $XDG_CONFIG_DIRS/alsoft.conf
setenv("XDG_CONFIG_DIRS", aConfDirs, true);

//String anAlConf = aConfDirs + "/alsoft.conf";
//setenv("ALSOFT_CONF", anAlConf, true);

// $XDG_DATA_DIRS/openal/hrtf
//setenv("XDG_DATA_DIRS", aConfDirs, true);
}

super.onCreate(theSavedInstanceState);
}

/** Setup environment variable. */
private static boolean setenv(String theName, String theVal) {
try {
android.system.Os.setenv(theName, theVal, true);
return true;
} catch(android.system.ErrnoException theError) {
return false;
}
}

/**
* Keep CPU on.
*/
Expand All @@ -59,7 +91,7 @@ public void setPartialWakeLockOn(String theTitle, boolean theToLock) {
final StMovieActivity aThis = this;
this.runOnUiThread(new Runnable() { public void run() {
// start a dummy foreground service, which actually does nothing but shows a system notification;
// this service (but the very existance) prevents system closing/suspending sView working threads playing audio in background
// this service (but the very existence) prevents system closing/suspending sView working threads playing audio in background
myCurrentTitle = aTitle;
android.content.Intent anIntent = new android.content.Intent(aThis, StMovieService.class);
if(toLock) {
Expand Down

0 comments on commit 859c1f6

Please sign in to comment.