aboutsummaryrefslogtreecommitdiffstats
path: root/libavdevice
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2021-08-27 14:30:45 -0300
committerJames Almer <jamrial@gmail.com>2022-03-15 09:42:30 -0300
commitffc4fd3cc2ccb2cadb71f19849842b18ca1281c6 (patch)
treebb2ed0afa829d44db52b93d1fe3316de6bcacdd8 /libavdevice
parent00c5526fc8bbfcd210f685c49bcd345fa2160b60 (diff)
downloadffmpeg-ffc4fd3cc2ccb2cadb71f19849842b18ca1281c6.tar.gz
alsa: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavdevice')
-rw-r--r--libavdevice/alsa.c19
-rw-r--r--libavdevice/alsa_dec.c2
-rw-r--r--libavdevice/alsa_enc.c2
3 files changed, 13 insertions, 10 deletions
diff --git a/libavdevice/alsa.c b/libavdevice/alsa.c
index ee282fac16..5396858427 100644
--- a/libavdevice/alsa.c
+++ b/libavdevice/alsa.c
@@ -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");
}
diff --git a/libavdevice/alsa_dec.c b/libavdevice/alsa_dec.c
index e93f31b146..b518bbdac6 100644
--- a/libavdevice/alsa_dec.c
+++ b/libavdevice/alsa_dec.c
@@ -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->channels = 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 */
diff --git a/libavdevice/alsa_enc.c b/libavdevice/alsa_enc.c
index a783d8eca1..fc5e5d9c94 100644
--- a/libavdevice/alsa_enc.c
+++ b/libavdevice/alsa_enc.c
@@ -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_channels, &codec_id);
if (sample_rate != st->codecpar->sample_rate) {
av_log(s1, AV_LOG_ERROR,
"sample rate %d not available, nearest is %d\n",