diff mbox series

[FFmpeg-devel,5/7] fftools/ffplay: use AV_BUFFERSINK_FLAG_PARAMS

Message ID 20240923150146.31693-5-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,1/7] lavfi/buffersink: set AVFrame.time_base | expand

Checks

Context Check Description
yinshiyou/configure_loongarch64 warning Failed to apply patch
andriy/configure_x86 warning Failed to apply patch

Commit Message

Anton Khirnov Sept. 23, 2024, 3:01 p.m. UTC
---
 fftools/ffplay.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

Comments

Nicolas George Sept. 23, 2024, 5:04 p.m. UTC | #1
Anton Khirnov (12024-09-23):
> ---
>  fftools/ffplay.c | 20 +++++++++++++++++---
>  1 file changed, 17 insertions(+), 3 deletions(-)

What an enhancement!
diff mbox series

Patch

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 4ea48e11bb..ef45f12906 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -2702,6 +2702,7 @@  static int stream_component_open(VideoState *is, int stream_index)
     case AVMEDIA_TYPE_AUDIO:
         {
             AVFilterContext *sink;
+            AVFrame *params = NULL;
 
             is->audio_filter_src.freq           = avctx->sample_rate;
             ret = av_channel_layout_copy(&is->audio_filter_src.ch_layout, &avctx->ch_layout);
@@ -2711,10 +2712,23 @@  static int stream_component_open(VideoState *is, int stream_index)
             if ((ret = configure_audio_filters(is, afilters, 0)) < 0)
                 goto fail;
             sink = is->out_audio_filter;
-            sample_rate    = av_buffersink_get_sample_rate(sink);
-            ret = av_buffersink_get_ch_layout(sink, &ch_layout);
-            if (ret < 0)
+
+            params = av_frame_alloc();
+            if (!params) {
+                ret = AVERROR(ENOMEM);
                 goto fail;
+            }
+
+            ret = av_buffersink_get_frame_flags(sink, params, AV_BUFFERSINK_FLAG_PARAMS);
+            if (ret < 0) {
+                av_frame_free(&params);
+                goto fail;
+            }
+
+            sample_rate = params->sample_rate;
+            FFSWAP(AVChannelLayout, ch_layout, params->ch_layout);
+
+            av_frame_free(&params);
         }
 
         /* prepare audio output */