Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
ffc4fd3c
Commit
ffc4fd3c
authored
Aug 27, 2021
by
James Almer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
alsa: convert to new channel layout API
Signed-off-by:
James Almer
<
jamrial@gmail.com
>
parent
00c5526f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
10 deletions
+13
-10
alsa.c
libavdevice/alsa.c
+11
-8
alsa_dec.c
libavdevice/alsa_dec.c
+1
-1
alsa_enc.c
libavdevice/alsa_enc.c
+1
-1
No files found.
libavdevice/alsa.c
View file @
ffc4fd3c
...
...
@@ -124,7 +124,7 @@ switch(format) {\
case FORMAT_F32: s->reorder_func = alsa_reorder_f32_out_ ##layout; break;\
}
static
av_cold
int
find_reorder_func
(
AlsaData
*
s
,
int
codec_id
,
uint64_t
layout
,
int
out
)
static
av_cold
int
find_reorder_func
(
AlsaData
*
s
,
int
codec_id
,
AVChannelLayout
*
layout
,
int
out
)
{
int
format
;
...
...
@@ -133,7 +133,8 @@ static av_cold int find_reorder_func(AlsaData *s, int codec_id, uint64_t layout,
return
AVERROR
(
ENOSYS
);
/* reordering is not needed for QUAD or 2_2 layout */
if
(
layout
==
AV_CH_LAYOUT_QUAD
||
layout
==
AV_CH_LAYOUT_2_2
)
if
(
!
av_channel_layout_compare
(
layout
,
&
(
AVChannelLayout
)
AV_CHANNEL_LAYOUT_QUAD
)
||
!
av_channel_layout_compare
(
layout
,
&
(
AVChannelLayout
)
AV_CHANNEL_LAYOUT_2_2
))
return
0
;
switch
(
codec_id
)
{
...
...
@@ -154,11 +155,13 @@ static av_cold int find_reorder_func(AlsaData *s, int codec_id, uint64_t layout,
default
:
return
AVERROR
(
ENOSYS
);
}
if
(
layout
==
AV_CH_LAYOUT_5POINT0_BACK
||
layout
==
AV_CH_LAYOUT_5POINT0
)
if
(
!
av_channel_layout_compare
(
layout
,
&
(
AVChannelLayout
)
AV_CHANNEL_LAYOUT_5POINT0_BACK
)
||
!
av_channel_layout_compare
(
layout
,
&
(
AVChannelLayout
)
AV_CHANNEL_LAYOUT_5POINT0
))
PICK_REORDER
(
50
)
else
if
(
layout
==
AV_CH_LAYOUT_5POINT1_BACK
||
layout
==
AV_CH_LAYOUT_5POINT1
)
else
if
(
!
av_channel_layout_compare
(
layout
,
&
(
AVChannelLayout
)
AV_CHANNEL_LAYOUT_5POINT1_BACK
)
||
!
av_channel_layout_compare
(
layout
,
&
(
AVChannelLayout
)
AV_CHANNEL_LAYOUT_5POINT1
))
PICK_REORDER
(
51
)
else
if
(
layout
==
AV_CH_LAYOUT_7POINT1
)
else
if
(
!
av_channel_layout_compare
(
layout
,
&
(
AVChannelLayout
)
AV_CHANNEL_LAYOUT_7POINT1
)
)
PICK_REORDER
(
71
)
return
s
->
reorder_func
?
0
:
AVERROR
(
ENOSYS
);
...
...
@@ -169,13 +172,13 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode,
int
channels
,
enum
AVCodecID
*
codec_id
)
{
AlsaData
*
s
=
ctx
->
priv_data
;
AVChannelLayout
*
layout
=
&
ctx
->
streams
[
0
]
->
codecpar
->
ch_layout
;
const
char
*
audio_device
;
int
res
,
flags
=
0
;
snd_pcm_format_t
format
;
snd_pcm_t
*
h
;
snd_pcm_hw_params_t
*
hw_params
;
snd_pcm_uframes_t
buffer_size
,
period_size
;
uint64_t
layout
=
ctx
->
streams
[
0
]
->
codecpar
->
channel_layout
;
if
(
ctx
->
url
[
0
]
==
0
)
audio_device
=
"default"
;
else
audio_device
=
ctx
->
url
;
...
...
@@ -271,10 +274,10 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode,
snd_pcm_hw_params_free
(
hw_params
);
if
(
channels
>
2
&&
layout
)
{
if
(
channels
>
2
&&
layout
->
order
!=
AV_CHANNEL_ORDER_UNSPEC
)
{
if
(
find_reorder_func
(
s
,
*
codec_id
,
layout
,
mode
==
SND_PCM_STREAM_PLAYBACK
)
<
0
)
{
char
name
[
128
];
av_
get_channel_layout_string
(
name
,
sizeof
(
name
),
channels
,
layout
);
av_
channel_layout_describe
(
layout
,
name
,
sizeof
(
name
)
);
av_log
(
ctx
,
AV_LOG_WARNING
,
"ALSA channel layout unknown or unimplemented for %s %s.
\n
"
,
name
,
mode
==
SND_PCM_STREAM_PLAYBACK
?
"playback"
:
"capture"
);
}
...
...
libavdevice/alsa_dec.c
View file @
ffc4fd3c
...
...
@@ -82,7 +82,7 @@ static av_cold int audio_read_header(AVFormatContext *s1)
st
->
codecpar
->
codec_type
=
AVMEDIA_TYPE_AUDIO
;
st
->
codecpar
->
codec_id
=
codec_id
;
st
->
codecpar
->
sample_rate
=
s
->
sample_rate
;
st
->
codecpar
->
ch
annels
=
s
->
channels
;
st
->
codecpar
->
ch
_layout
.
nb_channels
=
s
->
channels
;
st
->
codecpar
->
frame_size
=
s
->
frame_size
;
avpriv_set_pts_info
(
st
,
64
,
1
,
1000000
);
/* 64 bits pts in us */
/* microseconds instead of seconds, MHz instead of Hz */
...
...
libavdevice/alsa_enc.c
View file @
ffc4fd3c
...
...
@@ -64,7 +64,7 @@ static av_cold int audio_write_header(AVFormatContext *s1)
sample_rate
=
st
->
codecpar
->
sample_rate
;
codec_id
=
st
->
codecpar
->
codec_id
;
res
=
ff_alsa_open
(
s1
,
SND_PCM_STREAM_PLAYBACK
,
&
sample_rate
,
st
->
codecpar
->
channels
,
&
codec_id
);
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
,
&
codec_id
);
if
(
sample_rate
!=
st
->
codecpar
->
sample_rate
)
{
av_log
(
s1
,
AV_LOG_ERROR
,
"sample rate %d not available, nearest is %d
\n
"
,
...
...
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