Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Steve Lhomme
VLC
Commits
38d91b7f
Commit
38d91b7f
authored
Nov 03, 2012
by
Rémi Denis-Courmont
Browse files
ALSA: get PCM delay and state in a single system call
parent
f6c755c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
modules/audio_output/alsa.c
View file @
38d91b7f
...
...
@@ -553,15 +553,20 @@ static void Play (audio_output_t *aout, block_t *block,
sys
->
format
.
i_bitspersample
/
8
);
snd_pcm_t
*
pcm
=
sys
->
pcm
;
snd_pcm_s
frames_t
frame
s
;
snd_pcm_state_t
state
=
snd_pcm_state
(
pcm
)
;
snd_pcm_s
tatus_t
*
statu
s
;
int
val
;
if
(
snd_pcm_delay
(
pcm
,
&
frames
)
==
0
)
snd_pcm_status_alloca
(
&
status
);
val
=
snd_pcm_status
(
pcm
,
status
);
if
(
val
<
0
)
msg_Err
(
aout
,
"cannot get status: %s"
,
snd_strerror
(
val
));
else
{
snd_pcm_sframes_t
frames
=
snd_pcm_status_get_delay
(
status
);
mtime_t
delay
=
frames
*
CLOCK_FREQ
/
sys
->
format
.
i_rate
;
delay
+=
mdate
()
-
block
->
i_pts
;
if
(
s
tate
!=
SND_PCM_STATE_RUNNING
)
if
(
s
nd_pcm_status_get_state
(
status
)
!=
SND_PCM_STATE_RUNNING
)
{
if
(
delay
<
0
)
{
...
...
@@ -597,6 +602,8 @@ static void Play (audio_output_t *aout, block_t *block,
while
(
block
->
i_nb_samples
>
0
)
{
snd_pcm_sframes_t
frames
;
frames
=
snd_pcm_writei
(
pcm
,
block
->
p_buffer
,
block
->
i_nb_samples
);
if
(
frames
>=
0
)
{
...
...
Write
Preview
Supports
Markdown
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