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
bb9c9396
Commit
bb9c9396
authored
May 12, 2011
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
access/alsa.c: Cleanup
No functional changes.
parent
fb46b4a1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
13 deletions
+21
-13
modules/access/alsa.c
modules/access/alsa.c
+21
-13
No files found.
modules/access/alsa.c
View file @
bb9c9396
/*****************************************************************************
/*****************************************************************************
* alsa.c : Alsa input module for vlc
* alsa.c : Alsa input module for vlc
*****************************************************************************
*****************************************************************************
* Copyright (C) 2002-20
09
the VideoLAN team
* Copyright (C) 2002-20
11
the VideoLAN team
* $Id$
* $Id$
*
*
* Authors: Benjamin Pracht <bigben at videolan dot org>
* Authors: Benjamin Pracht <bigben at videolan dot org>
...
@@ -369,7 +369,6 @@ static int Demux( demux_t *p_demux )
...
@@ -369,7 +369,6 @@ static int Demux( demux_t *p_demux )
return
1
;
return
1
;
}
}
/*****************************************************************************
/*****************************************************************************
* GrabAudio: Grab an audio frame
* GrabAudio: Grab an audio frame
*****************************************************************************/
*****************************************************************************/
...
@@ -391,7 +390,8 @@ static block_t* GrabAudio( demux_t *p_demux )
...
@@ -391,7 +390,8 @@ static block_t* GrabAudio( demux_t *p_demux )
p_sys
->
p_block
=
p_block
;
p_sys
->
p_block
=
p_block
;
/* ALSA */
/* ALSA */
i_read
=
snd_pcm_readi
(
p_sys
->
p_alsa_pcm
,
p_block
->
p_buffer
,
p_sys
->
i_alsa_chunk_size
);
i_read
=
snd_pcm_readi
(
p_sys
->
p_alsa_pcm
,
p_block
->
p_buffer
,
p_sys
->
i_alsa_chunk_size
);
if
(
i_read
==
-
EAGAIN
)
if
(
i_read
==
-
EAGAIN
)
{
{
snd_pcm_wait
(
p_sys
->
p_alsa_pcm
,
10
);
/* See poll() comment in oss.c */
snd_pcm_wait
(
p_sys
->
p_alsa_pcm
,
10
);
/* See poll() comment in oss.c */
...
@@ -410,11 +410,13 @@ static block_t* GrabAudio( demux_t *p_demux )
...
@@ -410,11 +410,13 @@ static block_t* GrabAudio( demux_t *p_demux )
{
{
/* suspend */
/* suspend */
int
i_resume
=
snd_pcm_resume
(
p_sys
->
p_alsa_pcm
);
int
i_resume
=
snd_pcm_resume
(
p_sys
->
p_alsa_pcm
);
if
(
i_resume
<
0
&&
i_resume
!=
-
EAGAIN
)
snd_pcm_prepare
(
p_sys
->
p_alsa_pcm
);
if
(
i_resume
<
0
&&
i_resume
!=
-
EAGAIN
)
snd_pcm_prepare
(
p_sys
->
p_alsa_pcm
);
break
;
break
;
}
}
default:
default:
msg_Err
(
p_demux
,
"Failed to read alsa frame (%s)"
,
snd_strerror
(
i_read
)
);
msg_Err
(
p_demux
,
"Failed to read alsa frame (%s)"
,
snd_strerror
(
i_read
)
);
return
NULL
;
return
NULL
;
}
}
}
}
...
@@ -549,7 +551,8 @@ static int OpenAudioDevAlsa( demux_t *p_demux, const char *psz_device )
...
@@ -549,7 +551,8 @@ static int OpenAudioDevAlsa( demux_t *p_demux, const char *psz_device )
}
}
/* Set Interleaved access */
/* Set Interleaved access */
if
(
(
i_err
=
snd_pcm_hw_params_set_access
(
p_sys
->
p_alsa_pcm
,
p_hw_params
,
SND_PCM_ACCESS_RW_INTERLEAVED
)
)
<
0
)
if
(
(
i_err
=
snd_pcm_hw_params_set_access
(
p_sys
->
p_alsa_pcm
,
p_hw_params
,
SND_PCM_ACCESS_RW_INTERLEAVED
)
)
<
0
)
{
{
msg_Err
(
p_demux
,
"ALSA: cannot set access type (%s)"
,
msg_Err
(
p_demux
,
"ALSA: cannot set access type (%s)"
,
snd_strerror
(
i_err
)
);
snd_strerror
(
i_err
)
);
...
@@ -558,7 +561,8 @@ static int OpenAudioDevAlsa( demux_t *p_demux, const char *psz_device )
...
@@ -558,7 +561,8 @@ static int OpenAudioDevAlsa( demux_t *p_demux, const char *psz_device )
/* Set capture format, default is signed 16 bit little endian */
/* Set capture format, default is signed 16 bit little endian */
i_alsa_pcm_format
=
GetAlsaPCMFormat
(
p_demux
,
p_sys
->
i_format
);
i_alsa_pcm_format
=
GetAlsaPCMFormat
(
p_demux
,
p_sys
->
i_format
);
if
(
(
i_err
=
snd_pcm_hw_params_set_format
(
p_sys
->
p_alsa_pcm
,
p_hw_params
,
i_alsa_pcm_format
)
)
<
0
)
if
(
(
i_err
=
snd_pcm_hw_params_set_format
(
p_sys
->
p_alsa_pcm
,
p_hw_params
,
i_alsa_pcm_format
)
)
<
0
)
{
{
msg_Err
(
p_demux
,
"ALSA: cannot set sample format (%s)"
,
msg_Err
(
p_demux
,
"ALSA: cannot set sample format (%s)"
,
snd_strerror
(
i_err
)
);
snd_strerror
(
i_err
)
);
...
@@ -566,7 +570,8 @@ static int OpenAudioDevAlsa( demux_t *p_demux, const char *psz_device )
...
@@ -566,7 +570,8 @@ static int OpenAudioDevAlsa( demux_t *p_demux, const char *psz_device )
}
}
/* Set sample rate */
/* Set sample rate */
i_err
=
snd_pcm_hw_params_set_rate_near
(
p_sys
->
p_alsa_pcm
,
p_hw_params
,
&
p_sys
->
i_sample_rate
,
NULL
);
i_err
=
snd_pcm_hw_params_set_rate_near
(
p_sys
->
p_alsa_pcm
,
p_hw_params
,
&
p_sys
->
i_sample_rate
,
NULL
);
if
(
i_err
<
0
)
if
(
i_err
<
0
)
{
{
msg_Err
(
p_demux
,
"ALSA: cannot set sample rate (%s)"
,
msg_Err
(
p_demux
,
"ALSA: cannot set sample rate (%s)"
,
...
@@ -576,14 +581,16 @@ static int OpenAudioDevAlsa( demux_t *p_demux, const char *psz_device )
...
@@ -576,14 +581,16 @@ static int OpenAudioDevAlsa( demux_t *p_demux, const char *psz_device )
/* Set channels */
/* Set channels */
unsigned
int
channels
=
p_sys
->
b_stereo
?
2
:
1
;
unsigned
int
channels
=
p_sys
->
b_stereo
?
2
:
1
;
if
(
(
i_err
=
snd_pcm_hw_params_set_channels
(
p_sys
->
p_alsa_pcm
,
p_hw_params
,
channels
)
)
<
0
)
if
(
(
i_err
=
snd_pcm_hw_params_set_channels
(
p_sys
->
p_alsa_pcm
,
p_hw_params
,
channels
)
)
<
0
)
{
{
channels
=
(
channels
==
1
)
?
2
:
1
;
channels
=
(
channels
==
1
)
?
2
:
1
;
msg_Warn
(
p_demux
,
"ALSA: cannot set channel count (%s). "
msg_Warn
(
p_demux
,
"ALSA: cannot set channel count (%s). "
"Trying with channels=%d"
,
"Trying with channels=%d"
,
snd_strerror
(
i_err
),
snd_strerror
(
i_err
),
channels
);
channels
);
if
(
(
i_err
=
snd_pcm_hw_params_set_channels
(
p_sys
->
p_alsa_pcm
,
p_hw_params
,
channels
)
)
<
0
)
if
(
(
i_err
=
snd_pcm_hw_params_set_channels
(
p_sys
->
p_alsa_pcm
,
p_hw_params
,
channels
)
)
<
0
)
{
{
msg_Err
(
p_demux
,
"ALSA: cannot set channel count (%s)"
,
msg_Err
(
p_demux
,
"ALSA: cannot set channel count (%s)"
,
snd_strerror
(
i_err
)
);
snd_strerror
(
i_err
)
);
...
@@ -604,7 +611,8 @@ static int OpenAudioDevAlsa( demux_t *p_demux, const char *psz_device )
...
@@ -604,7 +611,8 @@ static int OpenAudioDevAlsa( demux_t *p_demux, const char *psz_device )
/* Set period time */
/* Set period time */
unsigned
int
period_time
=
buffer_time
/
4
;
unsigned
int
period_time
=
buffer_time
/
4
;
i_err
=
snd_pcm_hw_params_set_period_time_near
(
p_sys
->
p_alsa_pcm
,
p_hw_params
,
&
period_time
,
0
);
i_err
=
snd_pcm_hw_params_set_period_time_near
(
p_sys
->
p_alsa_pcm
,
p_hw_params
,
&
period_time
,
0
);
if
(
i_err
<
0
)
if
(
i_err
<
0
)
{
{
msg_Err
(
p_demux
,
"ALSA: cannot set period time (%s)"
,
msg_Err
(
p_demux
,
"ALSA: cannot set period time (%s)"
,
...
@@ -613,7 +621,8 @@ static int OpenAudioDevAlsa( demux_t *p_demux, const char *psz_device )
...
@@ -613,7 +621,8 @@ static int OpenAudioDevAlsa( demux_t *p_demux, const char *psz_device )
}
}
/* Set buffer time */
/* Set buffer time */
i_err
=
snd_pcm_hw_params_set_buffer_time_near
(
p_sys
->
p_alsa_pcm
,
p_hw_params
,
&
buffer_time
,
0
);
i_err
=
snd_pcm_hw_params_set_buffer_time_near
(
p_sys
->
p_alsa_pcm
,
p_hw_params
,
&
buffer_time
,
0
);
if
(
i_err
<
0
)
if
(
i_err
<
0
)
{
{
msg_Err
(
p_demux
,
"ALSA: cannot set buffer time (%s)"
,
msg_Err
(
p_demux
,
"ALSA: cannot set buffer time (%s)"
,
...
@@ -670,7 +679,6 @@ static int OpenAudioDevAlsa( demux_t *p_demux, const char *psz_device )
...
@@ -670,7 +679,6 @@ static int OpenAudioDevAlsa( demux_t *p_demux, const char *psz_device )
p_sys
->
p_alsa_pcm
=
NULL
;
p_sys
->
p_alsa_pcm
=
NULL
;
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
static
int
OpenAudioDev
(
demux_t
*
p_demux
,
const
char
*
psz_device
)
static
int
OpenAudioDev
(
demux_t
*
p_demux
,
const
char
*
psz_device
)
...
...
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