Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ewout ter Hoeven
VLC-Android
Commits
4471bcc9
Commit
4471bcc9
authored
Mar 26, 2018
by
Thomas Guillem
Committed by
Geoffrey Métais
Mar 27, 2018
Browse files
Audio passthrough setting
parent
d68b95d3
Changes
7
Hide whitespace changes
Inline
Side-by-side
vlc-android/res/values/strings.xml
View file @
4471bcc9
...
...
@@ -597,4 +597,8 @@
<string
name=
"sdcard_permission_dialog_message"
>
VLC cannot delete this file without write access permission.\nPlease go to your SD Card and click on \"Select\".\nYou may have to click on \"Show SD card\" first in the top-right menu
</string>
<string
name=
"dialog_sd_wizard"
>
Show me
</string>
<string
name=
"renderers_disconnect"
>
Disconnect
</string>
<string
name=
"audio_digital_failed"
>
Failed to change Audio Digital Output state
</string>
<string
name=
"audio_digital_output_enabled"
>
Audio Digital Output enabled
</string>
<string
name=
"audio_digital_output_disabled"
>
Audio Digital Output disabled
</string>
<string
name=
"audio_digital_title"
>
Digital audio output (passthrough)
</string>
</resources>
vlc-android/res/xml/preferences_audio.xml
View file @
4471bcc9
...
...
@@ -4,7 +4,10 @@
android:key=
"audio_category"
android:title=
"@string/audio_prefs_category"
>
<CheckBoxPreference
android:defaultValue=
"false"
android:key=
"audio_digital_output"
android:title=
"@string/audio_digital_title"
/>
<CheckBoxPreference
android:defaultValue=
"false"
android:key=
"artists_show_all"
...
...
vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
View file @
4471bcc9
...
...
@@ -61,6 +61,7 @@ import org.videolan.vlc.interfaces.IPlaybackSettingsController;
import
org.videolan.vlc.util.AndroidDevices
;
import
org.videolan.vlc.util.Constants
;
import
org.videolan.vlc.util.Strings
;
import
org.videolan.vlc.util.VLCOptions
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
...
...
@@ -92,6 +93,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
private
static
final
int
ID_POPUP_VIDEO
=
9
;
private
static
final
int
ID_REPEAT
=
10
;
private
static
final
int
ID_SHUFFLE
=
11
;
private
static
final
int
ID_PASSTHROUGH
=
12
;
private
Activity
mActivity
;
private
int
mMode
=
-
1
;
...
...
@@ -102,6 +104,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
private
TextView
mPlaybackSpeed
;
private
TextView
mSleep
;
private
TextView
mPassThrough
;
private
TextView
mJumpTitle
;
...
...
@@ -466,14 +469,26 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
mService
.
shuffle
();
initShuffle
();
break
;
case
ID_PASSTHROUGH:
{
togglePassthrough
();
break
;
}
}
}
private
void
togglePassthrough
()
{
final
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
AdvOptionsDialog
.
this
.
getContext
());
boolean
enabled
=
!
VLCOptions
.
isAudioDigitalOutputEnabled
(
prefs
);
if
(
mService
.
setAudioDigitalOutputEnabled
(
enabled
))
{
VLCOptions
.
setAudioDigitalOutputEnabled
(
prefs
,
enabled
);
mToast
.
setText
(
enabled
?
getString
(
R
.
string
.
audio_digital_output_enabled
)
:
getString
(
R
.
string
.
audio_digital_output_disabled
));
}
else
mToast
.
setText
(
R
.
string
.
audio_digital_failed
);
mToast
.
show
();
}
@Override
public
void
onFocusChange
(
View
v
,
boolean
hasFocus
)
{
if
(
v
instanceof
TextView
)
((
TextView
)
v
).
setTextColor
(
v
.
hasFocus
()
?
UiTools
.
Resources
.
ITEM_FOCUS_ON
:
mTextColor
);
if
(
v
instanceof
TextView
)
((
TextView
)
v
).
setTextColor
(
v
.
hasFocus
()
?
UiTools
.
Resources
.
ITEM_FOCUS_ON
:
mTextColor
);
mToast
.
setText
(
mAdapter
.
getSelectedAdvOptionHelp
());
mToast
.
show
();
}
...
...
@@ -511,6 +526,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
mService
=
service
;
boolean
tvUi
=
VLCApplication
.
showTvUi
();
int
large_items
=
0
;
final
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
AdvOptionsDialog
.
this
.
getContext
());
mAdapter
.
addOption
(
new
Option
(
ID_SLEEP
,
R
.
attr
.
ic_sleep_normal_style
,
getString
(
R
.
string
.
sleep_title
)));
mAdapter
.
addOption
(
new
Option
(
ID_PLAYBACK_SPEED
,
R
.
attr
.
ic_speed_normal_style
,
getString
(
R
.
string
.
playback_speed
)));
...
...
@@ -537,6 +553,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
}
else
{
mAdapter
.
addOption
(
new
Option
(
ID_SAVE_PLAYLIST
,
R
.
attr
.
ic_save
,
getString
(
R
.
string
.
playlist_save
)));
}
if
(
"0"
.
equals
(
prefs
.
getString
(
"aout"
,
"0"
)))
mAdapter
.
addOption
(
new
Option
(
ID_PASSTHROUGH
,
R
.
attr
.
ic_popup_dim
,
getString
(
R
.
string
.
audio_digital_title
)));
setDialogDimensions
(
large_items
);
}
...
...
@@ -619,8 +636,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
public
void
onBindViewHolder
(
ViewHolder
holder
,
int
position
)
{
final
Option
option
=
mList
.
get
(
position
);
final
TextView
tv
=
(
TextView
)
holder
.
itemView
;
if
(
mSelection
==
position
)
tv
.
requestFocus
();
if
(
mSelection
==
position
)
tv
.
requestFocus
();
tv
.
setId
(
option
.
id
);
final
int
icon
=
UiTools
.
getResourceFromAttribute
(
mActivity
,
option
.
icon
);
if
(
option
.
id
==
ID_CHAPTER_TITLE
)
...
...
vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.java
View file @
4471bcc9
...
...
@@ -25,6 +25,7 @@ package org.videolan.vlc.gui.preferences;
import
android.app.Activity
;
import
android.content.SharedPreferences
;
import
android.os.Bundle
;
import
android.support.v7.preference.CheckBoxPreference
;
import
android.support.v7.preference.Preference
;
import
android.support.v7.preference.TwoStatePreference
;
...
...
@@ -47,12 +48,6 @@ public class PreferencesAudio extends BasePreferenceFragment implements SharedPr
return
R
.
string
.
audio_prefs_category
;
}
@Override
public
void
onStart
()
{
super
.
onStart
();
getPreferenceScreen
().
getSharedPreferences
().
registerOnSharedPreferenceChangeListener
(
this
);
}
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
@@ -62,6 +57,20 @@ public class PreferencesAudio extends BasePreferenceFragment implements SharedPr
/* no AudioOutput choice */
findPreference
(
"aout"
).
setVisible
(
false
);
}
updatePassThroughSummary
();
final
boolean
opensles
=
"1"
.
equals
(
getPreferenceManager
().
getSharedPreferences
().
getString
(
"aout"
,
"0"
));
if
(
opensles
)
findPreference
(
"audio_digital_output"
).
setVisible
(
false
);
}
private
void
updatePassThroughSummary
()
{
final
boolean
pt
=
getPreferenceManager
().
getSharedPreferences
().
getBoolean
(
"audio_digital_output"
,
false
);
findPreference
(
"audio_digital_output"
).
setSummary
(
pt
?
R
.
string
.
audio_digital_output_enabled
:
R
.
string
.
audio_digital_output_disabled
);
}
@Override
public
void
onStart
()
{
super
.
onStart
();
getPreferenceScreen
().
getSharedPreferences
().
registerOnSharedPreferenceChangeListener
(
this
);
}
@Override
...
...
@@ -86,10 +95,16 @@ public class PreferencesAudio extends BasePreferenceFragment implements SharedPr
case
"aout"
:
VLCInstance
.
restart
();
((
PreferencesActivity
)
activity
).
restartMediaPlayer
();
final
boolean
opensles
=
"1"
.
equals
(
getPreferenceManager
().
getSharedPreferences
().
getString
(
"aout"
,
"0"
));
if
(
opensles
)
((
CheckBoxPreference
)
findPreference
(
"audio_digital_output"
)).
setChecked
(
false
);
findPreference
(
"audio_digital_output"
).
setVisible
(!
opensles
);
break
;
case
Constants
.
KEY_ARTISTS_SHOW_ALL
:
((
PreferencesActivity
)
activity
).
updateArtists
();
break
;
case
"audio_digital_output"
:
updatePassThroughSummary
();
break
;
}
}
}
\ No newline at end of file
vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesAudio.java
View file @
4471bcc9
...
...
@@ -21,10 +21,12 @@
*/
package
org.videolan.vlc.gui.tv.preferences
;
import
android.annotation.TargetApi
;
import
android.content.SharedPreferences
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.support.v7.preference.CheckBoxPreference
;
import
org.videolan.libvlc.util.AndroidUtil
;
import
org.videolan.libvlc.util.HWDecoderUtil
;
...
...
@@ -61,6 +63,14 @@ public class PreferencesAudio extends BasePreferenceFragment implements SharedPr
/* no AudioOutput choice */
findPreference
(
"aout"
).
setVisible
(
false
);
}
updatePassThroughSummary
();
final
boolean
opensles
=
"1"
.
equals
(
getPreferenceManager
().
getSharedPreferences
().
getString
(
"aout"
,
"0"
));
if
(
opensles
)
findPreference
(
"audio_digital_output"
).
setVisible
(
false
);
}
private
void
updatePassThroughSummary
()
{
final
boolean
pt
=
getPreferenceManager
().
getSharedPreferences
().
getBoolean
(
"audio_digital_output"
,
false
);
findPreference
(
"audio_digital_output"
).
setSummary
(
pt
?
R
.
string
.
audio_digital_output_enabled
:
R
.
string
.
audio_digital_output_disabled
);
}
@Override
...
...
@@ -75,8 +85,10 @@ public class PreferencesAudio extends BasePreferenceFragment implements SharedPr
switch
(
key
){
case
"aout"
:
VLCInstance
.
restart
();
if
(
getActivity
()
!=
null
)
((
PreferencesActivity
)
getActivity
()).
restartMediaPlayer
();
if
(
getActivity
()
!=
null
)
((
PreferencesActivity
)
getActivity
()).
restartMediaPlayer
();
final
boolean
opensles
=
"1"
.
equals
(
getPreferenceManager
().
getSharedPreferences
().
getString
(
"aout"
,
"0"
));
if
(
opensles
)
((
CheckBoxPreference
)
findPreference
(
"audio_digital_output"
)).
setChecked
(
false
);
findPreference
(
"audio_digital_output"
).
setVisible
(!
opensles
);
}
}
}
\ No newline at end of file
vlc-android/src/org/videolan/vlc/media/PlayerController.kt
View file @
4471bcc9
...
...
@@ -187,6 +187,7 @@ class PlayerController : IVLCVout.Callback, MediaPlayer.EventListener {
private
fun
newMediaPlayer
()
:
MediaPlayer
{
return
MediaPlayer
(
VLCInstance
.
get
()).
apply
{
setAudioDigitalOutputEnabled
(
VLCOptions
.
isAudioDigitalOutputEnabled
(
VLCApplication
.
getSettings
()));
VLCOptions
.
getAout
(
VLCApplication
.
getSettings
())
?.
let
{
setAudioOutput
(
it
)
}
setRenderer
(
RendererDelegate
.
selectedRenderer
)
this
.
vlcVout
.
addCallback
(
this
@PlayerController
)
...
...
vlc-android/src/org/videolan/vlc/util/VLCOptions.java
View file @
4471bcc9
...
...
@@ -147,6 +147,16 @@ public class VLCOptions {
return
options
;
}
public
static
boolean
isAudioDigitalOutputEnabled
(
SharedPreferences
pref
)
{
return
pref
.
getBoolean
(
"audio_digital_output"
,
false
);
}
public
static
void
setAudioDigitalOutputEnabled
(
SharedPreferences
pref
,
boolean
enabled
)
{
SharedPreferences
.
Editor
editor
=
pref
.
edit
();
editor
.
putBoolean
(
"audio_digital_output"
,
enabled
);
editor
.
apply
();
}
public
static
String
getAout
(
SharedPreferences
pref
)
{
int
aout
=
-
1
;
try
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment