audiorate: Account for in buffer samples if fill samples are added
If fill buffers are added to compensate for missing samples the input buffer is pushed as well and has to be added to output samples count. This ensure that add - drop == out - in. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8358>
This commit is contained in:
parent
345eae97d4
commit
73c61784d4
@ -623,6 +623,7 @@ gst_audio_rate_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||
if (!audiorate->silent)
|
||||
gst_audio_rate_notify_add (audiorate);
|
||||
}
|
||||
audiorate->out += in_samples;
|
||||
|
||||
} else if (in_offset < audiorate->next_offset) {
|
||||
/* need to remove samples */
|
||||
|
@ -173,6 +173,16 @@ got_buf (GstElement * fakesink, GstBuffer * buf, GstPad * pad, GList ** p_bufs)
|
||||
*p_bufs = g_list_append (*p_bufs, gst_buffer_ref (buf));
|
||||
}
|
||||
|
||||
static void
|
||||
statistics_check (GstElement * audiorate)
|
||||
{
|
||||
guint64 in, out, add, drop;
|
||||
|
||||
g_object_get (audiorate, "in", &in, "out", &out, "add", &add,
|
||||
"drop", &drop, NULL);
|
||||
fail_unless_equals_uint64 (out - in, add - drop);
|
||||
}
|
||||
|
||||
static void
|
||||
do_perfect_stream_test (guint rate, const gchar * format,
|
||||
gdouble drop_probability, gdouble inject_probability)
|
||||
@ -286,6 +296,7 @@ do_perfect_stream_test (guint rate, const gchar * format,
|
||||
next_time = GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf);
|
||||
next_offset = GST_BUFFER_OFFSET_END (buf);
|
||||
}
|
||||
statistics_check (audiorate);
|
||||
|
||||
gst_message_unref (msg);
|
||||
gst_element_set_state (pipe, GST_STATE_NULL);
|
||||
@ -440,6 +451,8 @@ GST_START_TEST (test_large_discont)
|
||||
* buffers, because the gap is > 1 second (but less than 2 seconds) */
|
||||
fail_unless_equals_int (g_list_length (buffers), 4);
|
||||
|
||||
statistics_check (audiorate);
|
||||
|
||||
gst_element_set_state (audiorate, GST_STATE_NULL);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
@ -499,7 +512,7 @@ GST_START_TEST (test_rate_change_down)
|
||||
GstElement *audiorate;
|
||||
GstCaps *caps1, *caps2;
|
||||
int i = 0;
|
||||
gint64 drop, in, out;
|
||||
gint64 drop;
|
||||
GstBus *bus;
|
||||
|
||||
caps1 = gst_caps_from_string (FIRST_CAPS);
|
||||
@ -547,7 +560,7 @@ GST_START_TEST (test_rate_change_down)
|
||||
gst_object_unref (bus);
|
||||
|
||||
audiorate = gst_bin_get_by_name (GST_BIN (pipeline), "audiorate");
|
||||
g_object_get (audiorate, "drop", &drop, "out", &out, "in", &in, NULL);
|
||||
g_object_get (audiorate, "drop", &drop, NULL);
|
||||
gst_object_unref (audiorate);
|
||||
|
||||
fail_unless_equals_int64 (drop, 0);
|
||||
@ -555,6 +568,8 @@ GST_START_TEST (test_rate_change_down)
|
||||
g_list_foreach (rbufs, (GFunc) gst_mini_object_unref, NULL);
|
||||
g_list_free (rbufs);
|
||||
|
||||
statistics_check (audiorate);
|
||||
|
||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||
gst_object_unref (pipeline);
|
||||
|
||||
@ -647,6 +662,8 @@ GST_START_TEST (test_segment_update)
|
||||
fail_unless_equals_int64 (GST_BUFFER_PTS (buffers->data), pts);
|
||||
gst_check_drop_buffers ();
|
||||
|
||||
statistics_check (audiorate);
|
||||
|
||||
gst_element_set_state (audiorate, GST_STATE_NULL);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user