Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
acf5a05a
Commit
acf5a05a
authored
Jul 07, 2015
by
Thomas Guillem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
audiotrack: add hdmi or stereo device selection
remove audiotrack-audio-channels option.
parent
8d6d383a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
9 deletions
+69
-9
modules/audio_output/audiotrack.c
modules/audio_output/audiotrack.c
+69
-9
No files found.
modules/audio_output/audiotrack.c
View file @
acf5a05a
...
...
@@ -48,11 +48,37 @@ static void Close( vlc_object_t * );
static
void
Stop
(
audio_output_t
*
);
static
int
Start
(
audio_output_t
*
,
audio_sample_format_t
*
);
/* There is an undefined behavior when configuring AudioTrack with SPDIF or
* more than 2 channels when there is no HDMI out. It may succeed and the
* Android ressampler will be used to downmix to stereo. It may fails cleanly,
* and this module will be able to recover and fallback to stereo. Finally, in
* some rare cases, it may crash during init or while ressampling. Because of
* the last case we don't try up to 8 channels and we use AT_DEV_STEREO device
* per default */
enum
at_dev
{
AT_DEV_STEREO
=
0
,
AT_DEV_HDMI
,
};
#define AT_DEV_DEFAULT AT_DEV_STEREO
#define AT_DEV_MAX_CHANNELS 8
static
const
struct
{
const
char
*
id
;
const
char
*
name
;
enum
at_dev
at_dev
;
}
at_devs
[]
=
{
{
"stereo"
,
"Up to 2 channels (compat mode)."
,
AT_DEV_STEREO
},
{
"hdmi"
,
"Up to 8 channels, SPDIF if available."
,
AT_DEV_HDMI
},
{
NULL
,
NULL
,
AT_DEV_DEFAULT
},
};
struct
aout_sys_t
{
/* sw gain */
float
soft_gain
;
bool
soft_mute
;
enum
at_dev
at_dev
;
jobject
p_audiotrack
;
/* AudioTrack ref */
jbyteArray
p_bytearray
;
/* ByteArray ref (for Write) */
size_t
i_bytearray_size
;
/* size of the ByteArray */
...
...
@@ -119,11 +145,6 @@ struct aout_sys_t {
* will be done by VLC */
#define AUDIOTRACK_NATIVE_SAMPLERATE
#define AUDIO_CHAN_TEXT N_("Audio output channels")
#define AUDIO_CHAN_LONGTEXT N_("Channels available for audio output. " \
"If the input has more channels than the output, it will be down-mixed. " \
"This parameter is ignored when digital pass-through is active.")
vlc_module_begin
()
set_shortname
(
"AudioTrack"
)
set_description
(
N_
(
"Android AudioTrack audio output"
)
)
...
...
@@ -132,8 +153,6 @@ vlc_module_begin ()
set_subcategory
(
SUBCAT_AUDIO_AOUT
)
add_sw_gain
()
add_shortcut
(
"audiotrack"
)
add_integer
(
"audiotrack-audio-channels"
,
2
,
AUDIO_CHAN_TEXT
,
AUDIO_CHAN_LONGTEXT
,
true
)
set_callbacks
(
Open
,
Close
)
vlc_module_end
()
...
...
@@ -876,8 +895,16 @@ Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt )
unsigned
int
i_rate
;
bool
b_spdif
;
if
(
p_sys
->
at_dev
==
AT_DEV_HDMI
)
{
b_spdif
=
true
;
i_max_channels
=
AT_DEV_MAX_CHANNELS
;
}
else
{
b_spdif
=
var_InheritBool
(
p_aout
,
"spdif"
);
i_max_channels
=
var_InheritInteger
(
p_aout
,
"audiotrack-audio-channels"
);
i_max_channels
=
2
;
}
if
(
!
(
env
=
GET_ENV
()
)
)
return
VLC_EGENERIC
;
...
...
@@ -1465,6 +1492,33 @@ Flush( audio_output_t *p_aout, bool b_wait )
CHECK_AT_EXCEPTION
(
"play"
);
}
static
int
DeviceSelect
(
audio_output_t
*
p_aout
,
const
char
*
p_id
)
{
aout_sys_t
*
p_sys
=
p_aout
->
sys
;
enum
at_dev
at_dev
=
AT_DEV_DEFAULT
;
if
(
p_id
)
{
for
(
unsigned
int
i
=
0
;
at_devs
[
i
].
id
;
++
i
)
{
if
(
!
strcmp
(
p_id
,
at_devs
[
i
].
id
)
)
{
at_dev
=
at_devs
[
i
].
at_dev
;
break
;
}
}
}
if
(
at_dev
!=
p_sys
->
at_dev
)
{
p_sys
->
at_dev
=
at_dev
;
aout_RestartRequest
(
p_aout
,
AOUT_RESTART_OUTPUT
);
msg_Dbg
(
p_aout
,
"selected audiotrack device: %s"
,
p_id
);
}
aout_DeviceReport
(
p_aout
,
p_id
);
return
VLC_SUCCESS
;
}
static
int
Open
(
vlc_object_t
*
obj
)
{
...
...
@@ -1480,6 +1534,8 @@ Open( vlc_object_t *obj )
if
(
unlikely
(
p_sys
==
NULL
)
)
return
VLC_ENOMEM
;
p_sys
->
at_dev
=
AT_DEV_DEFAULT
;
p_aout
->
sys
=
p_sys
;
p_aout
->
start
=
Start
;
p_aout
->
stop
=
Stop
;
...
...
@@ -1487,6 +1543,10 @@ Open( vlc_object_t *obj )
p_aout
->
pause
=
Pause
;
p_aout
->
flush
=
Flush
;
p_aout
->
time_get
=
TimeGet
;
p_aout
->
device_select
=
DeviceSelect
;
for
(
unsigned
int
i
=
0
;
at_devs
[
i
].
id
;
++
i
)
aout_HotplugReport
(
p_aout
,
at_devs
[
i
].
id
,
at_devs
[
i
].
name
);
aout_SoftVolumeInit
(
p_aout
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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