Commit 94ed689e authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Store the AOUT preference as an Integer and not a string

This solve a crash and an issue when changing language or updating the
strings between versions...
parent d7a52b8b
......@@ -168,4 +168,14 @@
<item>@string/aout_audiotrack</item>
<item>@string/aout_opensles</item>
</string-array>
</resources>
<string-array name="aouts_values_froyo">
<item>0</item>
<item>1</item>
</string-array>
<string-array name="aouts_values">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
</resources>
\ No newline at end of file
......@@ -26,7 +26,6 @@ import org.videolan.vlc.gui.video.VideoPlayerActivity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Build;
import android.preference.PreferenceManager;
import android.util.Log;
......@@ -34,13 +33,13 @@ import android.view.Surface;
public class LibVLC {
private static final String TAG = "VLC/LibVLC";
private static final int AOUT_AUDIOTRACK = 0;
private static final int AOUT_AUDIOTRACK_JAVA = 1;
private static final int AOUT_AUDIOTRACK = 1;
private static final int AOUT_AUDIOTRACK_JAVA = 0;
private static final int AOUT_OPENSLES = 2;
private static LibVLC sInstance;
private static boolean sUseIomx = false;
private static int sAout = AOUT_AUDIOTRACK;
private static int sAout = AOUT_AUDIOTRACK_JAVA;
/** libVLC instance C pointer */
private long mLibVlcInstance = 0; // Read-only, reserved for JNI
......@@ -157,14 +156,14 @@ public class LibVLC {
public static synchronized void useIOMX(Context context) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
sUseIomx = pref.getBoolean("enable_iomx", false);
setAout(context, pref.getString("aout", "error"), false);
sAout = pref.getInt("aout", AOUT_AUDIOTRACK_JAVA);
}
public static synchronized void setAout(Context context, String aoutPref, boolean reset) {
Resources res = context.getResources();
if (aoutPref.equals(res.getString(R.string.aout_audiotrack)))
public static synchronized void setAout(Context context, Integer aoutPref,
boolean reset) {
if (aoutPref == AOUT_AUDIOTRACK)
sAout = AOUT_AUDIOTRACK;
else if (aoutPref.equals(res.getString(R.string.aout_opensles)) && Util.isGingerbreadOrLater())
else if (aoutPref == AOUT_OPENSLES && Util.isGingerbreadOrLater())
sAout = AOUT_OPENSLES;
else
sAout = AOUT_AUDIOTRACK_JAVA;
......
......@@ -151,12 +151,13 @@ public class PreferencesActivity extends PreferenceActivity {
// Audio output
ListPreference aoutPref = (ListPreference) findPreference("aout");
int aoutEntriesId = Util.isGingerbreadOrLater() ? R.array.aouts : R.array.aouts_froyo;
int aoutEntriesIdValues = Util.isGingerbreadOrLater() ? R.array.aouts_values : R.array.aouts_values_froyo;
aoutPref.setEntries(aoutEntriesId);
aoutPref.setEntryValues(aoutEntriesId);
aoutPref.setEntryValues(aoutEntriesIdValues);
aoutPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
LibVLC.setAout(PreferencesActivity.this, (String) newValue, true);
LibVLC.setAout(PreferencesActivity.this, (Integer) newValue, true);
return true;
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment