[Android] Add aaudio option

Thomas Guillem git at videolan.org
Fri Nov 18 12:29:45 UTC 2022


vlc-android | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Oct  4 17:12:04 2022 +0200| [6eb30a92b89938f15add502d3074655251a4b67e] | committer: Nicolas Pomepuy

Add aaudio option

AAudio need to be the new default: 0 (and replace the previous audiotrack default choice)

> https://code.videolan.org/videolan/vlc-android/commit/6eb30a92b89938f15add502d3074655251a4b67e
---

 .../org/videolan/vlc/gui/preferences/PreferencesAudioUITest.kt     | 5 +++--
 .../resources/src/main/java/org/videolan/resources/VLCOptions.kt   | 7 ++++---
 application/resources/src/main/res/values/arrays.xml               | 4 +++-
 application/resources/src/main/res/values/strings.xml              | 1 +
 .../org/videolan/television/ui/preferences/PreferencesAudio.kt     | 6 +++---
 .../src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt      | 2 +-
 .../src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt       | 6 +++---
 7 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/application/app/src/androidTest/java/org/videolan/vlc/gui/preferences/PreferencesAudioUITest.kt b/application/app/src/androidTest/java/org/videolan/vlc/gui/preferences/PreferencesAudioUITest.kt
index 96e342d542..06a6640981 100644
--- a/application/app/src/androidTest/java/org/videolan/vlc/gui/preferences/PreferencesAudioUITest.kt
+++ b/application/app/src/androidTest/java/org/videolan/vlc/gui/preferences/PreferencesAudioUITest.kt
@@ -81,9 +81,10 @@ class PreferencesAudioUITest: BasePreferenceUITest() {
 
         checkModeChanged(key, "0", "0", MAP_AOUT)
         checkModeChanged(key, "1", "0", MAP_AOUT)
+        checkModeChanged(key, "2", "0", MAP_AOUT)
     }
 
     companion object {
-        val MAP_AOUT = mapOf("0" to R.string.aout_audiotrack, "1" to R.string.aout_opensles)
+        val MAP_AOUT = mapOf("0" to R.string.aout_aaudio, "1" to R.string.aout_audiotrack, "2" to R.string.aout_opensles)
     }
-}
\ No newline at end of file
+}
diff --git a/application/resources/src/main/java/org/videolan/resources/VLCOptions.kt b/application/resources/src/main/java/org/videolan/resources/VLCOptions.kt
index 3d49e7572a..d1b7659905 100644
--- a/application/resources/src/main/java/org/videolan/resources/VLCOptions.kt
+++ b/application/resources/src/main/java/org/videolan/resources/VLCOptions.kt
@@ -45,8 +45,9 @@ import java.util.*
 object VLCOptions {
     private const val TAG = "VLC/VLCConfig"
 
-    private const val AOUT_AUDIOTRACK = 0
-    private const val AOUT_OPENSLES = 1
+    private const val AOUT_AAUDIO = 0
+    private const val AOUT_AUDIOTRACK = 1
+    private const val AOUT_OPENSLES = 2
 
     private const val HW_ACCELERATION_AUTOMATIC = -1
     private const val HW_ACCELERATION_DISABLED = 0
@@ -208,7 +209,7 @@ object VLCOptions {
         if (hwaout == HWDecoderUtil.AudioOutput.OPENSLES)
             aout = AOUT_OPENSLES
 
-        return if (aout == AOUT_OPENSLES) "opensles" else null /* audiotrack is the default */
+        return if (aout == AOUT_OPENSLES) "opensles" else if (aout == AOUT_AUDIOTRACK) "audiotrack" else null /* aaudio is the default */
     }
 
     private fun getDeblocking(deblocking: Int): Int {
diff --git a/application/resources/src/main/res/values/arrays.xml b/application/resources/src/main/res/values/arrays.xml
index 424968c73d..2b248f3e00 100644
--- a/application/resources/src/main/res/values/arrays.xml
+++ b/application/resources/src/main/res/values/arrays.xml
@@ -375,12 +375,14 @@
     </string-array>
 
     <string-array name="aouts">
+        <item>@string/aout_aaudio</item>
         <item>@string/aout_audiotrack</item>
         <item>@string/aout_opensles</item>
     </string-array>
     <string-array name="aouts_values" translatable="false">
         <item>0</item>
         <item>1</item>
+        <item>2</item>
     </string-array>
 
     <string-array name="casting_quality">
@@ -477,4 +479,4 @@
         <item>2</item>
     </string-array>
 
-</resources>
\ No newline at end of file
+</resources>
diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 60fcc361c4..bb94294b39 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -425,6 +425,7 @@
     <string name="replaygain_album">Album</string>
     <string name="aout">Audio output</string>
     <string name="aout_summary">Change the method that VLC uses to output audio</string>
+    <string name="aout_aaudio" translatable="false">AAudio</string>
     <string name="aout_audiotrack" translatable="false">AudioTrack</string>
     <string name="aout_opensles" translatable="false">OpenSL ES</string>
     <string name="audio_ducking_title">Lower VLC volume on notifications</string>
diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt
index 77cc183e20..0dc51a01e9 100644
--- a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt
@@ -83,7 +83,7 @@ class PreferencesAudio : BasePreferenceFragment(), SharedPreferences.OnSharedPre
             findPreference<Preference>("aout")?.isVisible = false
         }
         updatePassThroughSummary()
-        val opensles = "1" == preferenceManager.sharedPreferences.getString("aout", "0")
+        val opensles = "2" == preferenceManager.sharedPreferences.getString("aout", "0")
         if (opensles) findPreference<Preference>("audio_digital_output")?.isVisible = false
         preferredAudioTrack = findPreference("audio_preferred_language")!!
         updatePreferredAudioTrack()
@@ -127,7 +127,7 @@ class PreferencesAudio : BasePreferenceFragment(), SharedPreferences.OnSharedPre
         when (key) {
             "aout" -> {
                 launch { restartLibVLC() }
-                val opensles = "1" == preferenceManager.sharedPreferences.getString("aout", "0")
+                val opensles = "2" == preferenceManager.sharedPreferences.getString("aout", "0")
                 if (opensles) findPreference<CheckBoxPreference>("audio_digital_output")?.isChecked = false
                 findPreference<Preference>("audio_digital_output")?.isVisible = !opensles
             }
@@ -165,4 +165,4 @@ class PreferencesAudio : BasePreferenceFragment(), SharedPreferences.OnSharedPre
         preferredAudioTrack.entries = localePair.localeEntries
         preferredAudioTrack.entryValues = localePair.localeEntryValues
     }
-}
\ No newline at end of file
+}
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt
index 05ebc84138..c653f0d182 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt
@@ -110,7 +110,7 @@ class PlayerOptionsDelegate(val activity: FragmentActivity, val service: Playbac
         if (::bookmarkClickedListener.isInitialized) options.add(PlayerOption(ID_BOOKMARK, R.drawable.ic_bookmark, res.getString(R.string.bookmarks)))
         if (showABReapeat) options.add(PlayerOption(ID_ABREPEAT, R.drawable.ic_abrepeat, res.getString(R.string.ab_repeat)))
         options.add(PlayerOption(ID_SAVE_PLAYLIST, R.drawable.ic_addtoplaylist, res.getString(R.string.playlist_save)))
-        if (service.playlistManager.player.canDoPassthrough() && settings.getString("aout", "0") == "0")
+        if (service.playlistManager.player.canDoPassthrough() && settings.getString("aout", "0") != "2")
             options.add(PlayerOption(ID_PASSTHROUGH, R.drawable.ic_passthrough, res.getString(R.string.audio_digital_title)))
         if (video)
             options.add(PlayerOption(ID_VIDEO_CONTROLS_SETTING, R.drawable.ic_video_controls, res.getString(R.string.controls_setting)))
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt
index 541908f73b..0727c534cc 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt
@@ -76,7 +76,7 @@ class PreferencesAudio : BasePreferenceFragment(), SharedPreferences.OnSharedPre
             findPreference<Preference>("aout")?.isVisible = false
         }
         updatePassThroughSummary()
-        val opensles = "1" == preferenceManager.sharedPreferences.getString("aout", "0")
+        val opensles = "2" == preferenceManager.sharedPreferences.getString("aout", "0")
         if (opensles) findPreference<Preference>("audio_digital_output")?.isVisible = false
         for (key in arrayOf("audio-replay-gain-default", "audio-replay-gain-preamp")) {
             findPreference<EditTextPreference>(key)?.setOnBindEditTextListener {
@@ -148,7 +148,7 @@ class PreferencesAudio : BasePreferenceFragment(), SharedPreferences.OnSharedPre
         when (key) {
             "aout" -> {
                 lifecycleScope.launch { restartLibVLC() }
-                val opensles = "1" == preferenceManager.sharedPreferences.getString("aout", "0")
+                val opensles = "2" == preferenceManager.sharedPreferences.getString("aout", "0")
                 if (opensles) findPreference<CheckBoxPreference>("audio_digital_output")?.isChecked = false
                 findPreference<Preference>("audio_digital_output")?.isVisible = !opensles
             }
@@ -186,4 +186,4 @@ class PreferencesAudio : BasePreferenceFragment(), SharedPreferences.OnSharedPre
         preferredAudioTrack.entries = localePair.localeEntries
         preferredAudioTrack.entryValues = localePair.localeEntryValues
     }
-}
\ No newline at end of file
+}



More information about the Android mailing list