Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
22188d37
Commit
22188d37
authored
Dec 16, 2012
by
Rafaël Carré
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
opensles: implement mute/volume set
link with libm, and also with libdl which is needed
parent
86074bb4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
5 deletions
+39
-5
modules/audio_output/Modules.am
modules/audio_output/Modules.am
+6
-2
modules/audio_output/opensles_android.c
modules/audio_output/opensles_android.c
+33
-3
No files found.
modules/audio_output/Modules.am
View file @
22188d37
SOURCES_waveout = waveout.c windows_audio_common.h packet.c
SOURCES_auhal = TPCircularBuffer.h TPCircularBuffer.c auhal.c packet.c
SOURCES_audioqueue = audioqueue.c packet.c
SOURCES_opensles_android = opensles_android.c
libopensles_android_plugin_la_SOURCES = opensles_android.c
libopensles_android_plugin_la_CFLAGS = $(AM_CFLAGS)
libopensles_android_plugin_la_LIBADD = $(AM_LIBADD) -ldl -lm
libandroid_audiotrack_plugin_la_SOURCES = audiotrack.c
libandroid_audiotrack_plugin_la_CFLAGS = $(AM_CFLAGS)
libandroid_audiotrack_plugin_la_LIBADD = $(AM_LIBADD) -ldl
if HAVE_ANDROID
libvlc_LTLIBRARIES += libandroid_audiotrack_plugin.la
libvlc_LTLIBRARIES += libandroid_audiotrack_plugin.la
libopensles_android_plugin.la
endif
libadummy_plugin_la_SOURCES = adummy.c
...
...
modules/audio_output/opensles_android.c
View file @
22188d37
...
...
@@ -35,6 +35,7 @@
#include <vlc_aout.h>
#include <assert.h>
#include <dlfcn.h>
#include <math.h>
// For native audio
#include <SLES/OpenSLES.h>
...
...
@@ -52,6 +53,8 @@
#define Clear(a) (*a)->Clear(a)
#define GetState(a, b) (*a)->GetState(a, b)
#define SetPositionUpdatePeriod(a, b) (*a)->SetPositionUpdatePeriod(a, b)
#define SetVolumeLevel(a, b) (*a)->SetVolumeLevel(a, b)
#define SetMute(a, b) (*a)->SetMute(a, b)
/*****************************************************************************
* aout_sys_t: audio output method descriptor
...
...
@@ -65,6 +68,7 @@ struct aout_sys_t
SLObjectItf
outputMixObject
;
SLAndroidSimpleBufferQueueItf
playerBufferQueue
;
SLObjectItf
playerObject
;
SLVolumeItf
volumeItf
;
SLPlayItf
playerPlay
;
...
...
@@ -155,6 +159,28 @@ static void Flush(audio_output_t *p_aout, bool drain)
}
}
static
int
VolumeSet
(
audio_output_t
*
aout
,
float
vol
)
{
/* Convert UI volume to linear factor (cube) */
vol
=
vol
*
vol
*
vol
;
/* millibels from linear amplification */
int
mb
=
lroundf
(
2000
.
f
*
log10f
(
vol
));
if
(
mb
<
SL_MILLIBEL_MIN
)
mb
=
SL_MILLIBEL_MIN
;
else
if
(
mb
>
0
)
mb
=
0
;
/* maximum supported level could be higher: GetMaxVolumeLevel */
SLresult
r
=
SetVolumeLevel
(
aout
->
sys
->
volumeItf
,
mb
);
return
(
r
==
SL_RESULT_SUCCESS
)
?
0
:
-
1
;
}
static
int
MuteSet
(
audio_output_t
*
aout
,
bool
mute
)
{
SLresult
r
=
SetMute
(
aout
->
sys
->
volumeItf
,
mute
);
return
(
r
==
SL_RESULT_SUCCESS
)
?
0
:
-
1
;
}
static
void
Pause
(
audio_output_t
*
p_aout
,
bool
pause
,
mtime_t
date
)
{
(
void
)
date
;
...
...
@@ -388,8 +414,8 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
SLDataSink
audioSnk
=
{
&
loc_outmix
,
NULL
};
//create audio player
const
SLInterfaceID
ids2
[]
=
{
*
SL_IID_ANDROIDSIMPLEBUFFERQUEUE
};
static
const
SLboolean
req2
[]
=
{
SL_BOOLEAN_TRUE
};
const
SLInterfaceID
ids2
[]
=
{
*
SL_IID_ANDROIDSIMPLEBUFFERQUEUE
,
*
SL_IID_VOLUME
};
static
const
SLboolean
req2
[]
=
{
SL_BOOLEAN_TRUE
,
SL_BOOLEAN_TRUE
};
result
=
CreateAudioPlayer
(
engineEngine
,
&
p_sys
->
playerObject
,
&
audioSrc
,
&
audioSnk
,
sizeof
(
ids2
)
/
sizeof
(
*
ids2
),
ids2
,
req2
);
...
...
@@ -401,6 +427,9 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
result
=
GetInterface
(
p_sys
->
playerObject
,
*
SL_IID_PLAY
,
&
p_sys
->
playerPlay
);
CHECK_OPENSL_ERROR
(
"Failed to get player interface."
);
result
=
GetInterface
(
p_sys
->
playerObject
,
*
SL_IID_VOLUME
,
&
p_sys
->
volumeItf
);
CHECK_OPENSL_ERROR
(
"failed to get volume interface."
);
result
=
GetInterface
(
p_sys
->
playerObject
,
*
SL_IID_ANDROIDSIMPLEBUFFERQUEUE
,
&
p_sys
->
playerBufferQueue
);
CHECK_OPENSL_ERROR
(
"Failed to get buff queue interface"
);
...
...
@@ -409,7 +438,6 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
(
void
*
)
p_aout
);
CHECK_OPENSL_ERROR
(
"Failed to register buff queue callback."
);
// set the player's state to playing
result
=
SetPlayState
(
p_sys
->
playerPlay
,
SL_PLAYSTATE_PLAYING
);
CHECK_OPENSL_ERROR
(
"Failed to switch to playing state"
);
...
...
@@ -426,6 +454,8 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
p_aout
->
play
=
Play
;
p_aout
->
pause
=
Pause
;
p_aout
->
flush
=
Flush
;
p_aout
->
mute_set
=
MuteSet
;
p_aout
->
volume_set
=
VolumeSet
;
SetPositionUpdatePeriod
(
p_sys
->
playerPlay
,
AOUT_MIN_PREPARE_TIME
*
1000
/
CLOCK_FREQ
);
...
...
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