changeset 10792:fc02cf9fe634

8186859: Improve chained audio decoders Reviewed-by: ddehaven, kcr
author almatvee
date Thu, 14 Sep 2017 15:11:56 -0700
parents 0f9bfa68845a
children 65a4d1aeeba6
files modules/javafx.media/src/main/native/gstreamer/plugins/av/audiodecoder.c
diffstat 1 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.media/src/main/native/gstreamer/plugins/av/audiodecoder.c	Fri Jul 07 11:34:54 2017 +0530
+++ b/modules/javafx.media/src/main/native/gstreamer/plugins/av/audiodecoder.c	Thu Sep 14 15:11:56 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -773,11 +773,26 @@
 #if DECODE_AUDIO4
     if (base->frame->format == AV_SAMPLE_FMT_S16P || base->frame->format == AV_SAMPLE_FMT_FLTP)
     {
+        // Make sure we received expected data
+        int cc = decoder->num_channels;
+        for (ci = 0; ci < cc && ci < AUDIODECODER_OUT_NUM_CHANNELS; ci++)
+        {
+            if (base->frame->data[ci] == NULL)
+            {
+                gst_buffer_unmap(outbuf, &info2);
+                // INLINE - gst_buffer_unref()
+                gst_buffer_unref(outbuf);
+                gst_element_message_full(GST_ELEMENT(decoder), GST_MESSAGE_ERROR, GST_STREAM_ERROR, GST_STREAM_ERROR_DECODE,
+                                     g_strdup("Audio decoding failed"), NULL, ("audiodecoder.c"), ("audiodecoder_chain"), 0);
+                ret = GST_FLOW_ERROR;
+                goto _exit;
+            }
+        }
+
         // Reformat the output frame into single buffer.
         int16_t *buffer = (int16_t*)info2.data;
         for (sample = 0; sample < base->frame->nb_samples; sample++)
         {
-            int cc = decoder->num_channels;
             for (ci = 0; ci < cc && ci < AUDIODECODER_OUT_NUM_CHANNELS; ci++)
             {
                 switch (base->frame->format)