avauddec: Ensure drain even if codec has not delay capabilities
authorYeongjin Jeong <yeongjin.jeong@navercorp.com>
Mon, 29 Apr 2019 06:22:52 +0000 (15:22 +0900)
committerYeongjin Jeong <yeongjin.jeong@navercorp.com>
Mon, 29 Apr 2019 06:40:08 +0000 (15:40 +0900)
There are decoders that need to be drained if they work on multi-threads,
even if AV_CODEC_CAP_DELAY is not set.

ext/libav/gstavauddec.c

index f400d86..45eda1c 100644 (file)
@@ -597,29 +597,20 @@ no_codec:
 static void
 gst_ffmpegauddec_drain (GstFFMpegAudDec * ffmpegdec)
 {
-  GstFFMpegAudDecClass *oclass;
   gboolean got_any_frames = FALSE;
+  gboolean got_frame;
 
-  oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
-
-  if (oclass->in_plugin->capabilities & AV_CODEC_CAP_DELAY) {
-    gboolean got_frame;
-
-    GST_LOG_OBJECT (ffmpegdec,
-        "codec has delay capabilities, calling until libav has drained everything");
-
-    if (avcodec_send_packet (ffmpegdec->context, NULL))
-      goto send_packet_failed;
+  if (avcodec_send_packet (ffmpegdec->context, NULL))
+    goto send_packet_failed;
 
-    do {
-      GstFlowReturn ret;
+  do {
+    GstFlowReturn ret;
 
-      got_frame = gst_ffmpegauddec_frame (ffmpegdec, &ret);
-      if (got_frame)
-        got_any_frames = TRUE;
-    } while (got_frame);
-    avcodec_flush_buffers (ffmpegdec->context);
-  }
+    got_frame = gst_ffmpegauddec_frame (ffmpegdec, &ret);
+    if (got_frame)
+      got_any_frames = TRUE;
+  } while (got_frame);
+  avcodec_flush_buffers (ffmpegdec->context);
 
   if (got_any_frames)
     gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (ffmpegdec), NULL, 1);