mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-02 00:32:43 +00:00
tests: multiqueue: Replace large test macro with function
Just a bit of cleanup. https://bugzilla.gnome.org/show_bug.cgi?id=756867
This commit is contained in:
parent
67a9ec6878
commit
1b02b76137
1 changed files with 28 additions and 24 deletions
|
@ -881,21 +881,25 @@ block_probe (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
|
||||||
return GST_PAD_PROBE_OK;
|
return GST_PAD_PROBE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_FOR_BUFFERING_MSG(PIPELINE, EXPECTED_PERC) \
|
static void
|
||||||
G_STMT_START { \
|
check_for_buffering_msg (GstElement * pipeline, gint expected_perc)
|
||||||
gint buf_perc; \
|
{
|
||||||
GstMessage *msg; \
|
gint buf_perc;
|
||||||
GST_LOG ("waiting for %d%% buffering message", (EXPECTED_PERC)); \
|
GstMessage *msg;
|
||||||
msg = gst_bus_poll (GST_ELEMENT_BUS (PIPELINE), \
|
|
||||||
GST_MESSAGE_BUFFERING | GST_MESSAGE_ERROR, -1); \
|
GST_LOG ("waiting for %d%% buffering message", expected_perc);
|
||||||
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR, \
|
|
||||||
"Expected BUFFERING message, got ERROR message"); \
|
msg = gst_bus_poll (GST_ELEMENT_BUS (pipeline),
|
||||||
gst_message_parse_buffering (msg, &buf_perc); \
|
GST_MESSAGE_BUFFERING | GST_MESSAGE_ERROR, -1);
|
||||||
gst_message_unref (msg); \
|
fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR,
|
||||||
fail_unless (buf_perc == (EXPECTED_PERC), \
|
"Expected BUFFERING message, got ERROR message");
|
||||||
"Got incorrect percentage: %d%% expected: %d%%", buf_perc, \
|
|
||||||
(EXPECTED_PERC)); \
|
gst_message_parse_buffering (msg, &buf_perc);
|
||||||
} G_STMT_END
|
fail_unless (buf_perc == expected_perc,
|
||||||
|
"Got incorrect percentage: %d%% expected: %d%%", buf_perc, expected_perc);
|
||||||
|
|
||||||
|
gst_message_unref (msg);
|
||||||
|
}
|
||||||
|
|
||||||
GST_START_TEST (test_initial_fill_above_high_threshold)
|
GST_START_TEST (test_initial_fill_above_high_threshold)
|
||||||
{
|
{
|
||||||
|
@ -968,7 +972,7 @@ GST_START_TEST (test_initial_fill_above_high_threshold)
|
||||||
* produce a 100% buffering message. */
|
* produce a 100% buffering message. */
|
||||||
thread = g_thread_new ("push1", pad_push_datablock_thread, inputpad);
|
thread = g_thread_new ("push1", pad_push_datablock_thread, inputpad);
|
||||||
g_thread_join (thread);
|
g_thread_join (thread);
|
||||||
CHECK_FOR_BUFFERING_MSG (pipe, 100);
|
check_for_buffering_msg (pipe, 100);
|
||||||
|
|
||||||
gst_element_set_state (pipe, GST_STATE_NULL);
|
gst_element_set_state (pipe, GST_STATE_NULL);
|
||||||
gst_object_unref (inputpad);
|
gst_object_unref (inputpad);
|
||||||
|
@ -1058,7 +1062,7 @@ GST_START_TEST (test_watermark_and_fill_level)
|
||||||
|
|
||||||
/* Check for the buffering message; it should indicate 80% fill level
|
/* Check for the buffering message; it should indicate 80% fill level
|
||||||
* (Note that the percentage from the message is normalized) */
|
* (Note that the percentage from the message is normalized) */
|
||||||
CHECK_FOR_BUFFERING_MSG (pipe, 80);
|
check_for_buffering_msg (pipe, 80);
|
||||||
|
|
||||||
/* Increase the buffer size and lower the watermarks to test
|
/* Increase the buffer size and lower the watermarks to test
|
||||||
* if <1% watermarks are supported. */
|
* if <1% watermarks are supported. */
|
||||||
|
@ -1071,11 +1075,11 @@ GST_START_TEST (test_watermark_and_fill_level)
|
||||||
* multiqueue contains 80000 bytes, and the high watermark still is
|
* multiqueue contains 80000 bytes, and the high watermark still is
|
||||||
* 0.1 at this point, and the buffer level 80000 / 20000000 = 0.004 is
|
* 0.1 at this point, and the buffer level 80000 / 20000000 = 0.004 is
|
||||||
* normalized by 0.1: 0.004 / 0.1 => buffering percentage 4%. */
|
* normalized by 0.1: 0.004 / 0.1 => buffering percentage 4%. */
|
||||||
CHECK_FOR_BUFFERING_MSG (pipe, 4);
|
check_for_buffering_msg (pipe, 4);
|
||||||
/* Second buffering message is posted after the high-watermark limit
|
/* Second buffering message is posted after the high-watermark limit
|
||||||
* is set to 0.005. This time, the buffer level is normalized this way:
|
* is set to 0.005. This time, the buffer level is normalized this way:
|
||||||
* 0.004 / 0.005 => buffering percentage 80%. */
|
* 0.004 / 0.005 => buffering percentage 80%. */
|
||||||
CHECK_FOR_BUFFERING_MSG (pipe, 80);
|
check_for_buffering_msg (pipe, 80);
|
||||||
|
|
||||||
|
|
||||||
gst_element_set_state (pipe, GST_STATE_NULL);
|
gst_element_set_state (pipe, GST_STATE_NULL);
|
||||||
|
@ -1157,19 +1161,19 @@ GST_START_TEST (test_high_threshold_change)
|
||||||
/* Check for the buffering message; it should indicate 8% fill level
|
/* Check for the buffering message; it should indicate 8% fill level
|
||||||
* (Note that the percentage from the message is normalized, but since
|
* (Note that the percentage from the message is normalized, but since
|
||||||
* the high threshold is at 99%, it should still apply) */
|
* the high threshold is at 99%, it should still apply) */
|
||||||
CHECK_FOR_BUFFERING_MSG (pipe, 8);
|
check_for_buffering_msg (pipe, 8);
|
||||||
|
|
||||||
/* Set high threshold to half of what it was before. This means that the
|
/* Set high threshold to half of what it was before. This means that the
|
||||||
* relative fill level doubles. As a result, this should trigger a buffering
|
* relative fill level doubles. As a result, this should trigger a buffering
|
||||||
* message with a percentage of 16%. */
|
* message with a percentage of 16%. */
|
||||||
g_object_set (mq, "high-percent", (gint) 50, NULL);
|
g_object_set (mq, "high-percent", (gint) 50, NULL);
|
||||||
CHECK_FOR_BUFFERING_MSG (pipe, 16);
|
check_for_buffering_msg (pipe, 16);
|
||||||
|
|
||||||
/* Set high threshold to a value that lies below the current fill level.
|
/* Set high threshold to a value that lies below the current fill level.
|
||||||
* This should trigger a 100% buffering message immediately, even without
|
* This should trigger a 100% buffering message immediately, even without
|
||||||
* pushing in extra data. */
|
* pushing in extra data. */
|
||||||
g_object_set (mq, "high-percent", (gint) 5, NULL);
|
g_object_set (mq, "high-percent", (gint) 5, NULL);
|
||||||
CHECK_FOR_BUFFERING_MSG (pipe, 100);
|
check_for_buffering_msg (pipe, 100);
|
||||||
|
|
||||||
gst_element_set_state (pipe, GST_STATE_NULL);
|
gst_element_set_state (pipe, GST_STATE_NULL);
|
||||||
gst_object_unref (inputpad);
|
gst_object_unref (inputpad);
|
||||||
|
@ -1252,14 +1256,14 @@ GST_START_TEST (test_low_threshold_change)
|
||||||
|
|
||||||
/* Check for the buffering message; it should indicate 100% relative fill
|
/* Check for the buffering message; it should indicate 100% relative fill
|
||||||
* level (Note that the percentage from the message is normalized) */
|
* level (Note that the percentage from the message is normalized) */
|
||||||
CHECK_FOR_BUFFERING_MSG (pipe, 100);
|
check_for_buffering_msg (pipe, 100);
|
||||||
|
|
||||||
/* Set low threshold to a 10%, which is above the current fill level of 8%.
|
/* Set low threshold to a 10%, which is above the current fill level of 8%.
|
||||||
* As a result, the queue must re-enable its buffering mode, and post the
|
* As a result, the queue must re-enable its buffering mode, and post the
|
||||||
* current relative fill level of 40% (since high-percent is also set to 20%
|
* current relative fill level of 40% (since high-percent is also set to 20%
|
||||||
* and 8%/20% = 40%). */
|
* and 8%/20% = 40%). */
|
||||||
g_object_set (mq, "high-percent", (gint) 20, "low-percent", (gint) 10, NULL);
|
g_object_set (mq, "high-percent", (gint) 20, "low-percent", (gint) 10, NULL);
|
||||||
CHECK_FOR_BUFFERING_MSG (pipe, 40);
|
check_for_buffering_msg (pipe, 40);
|
||||||
|
|
||||||
gst_element_set_state (pipe, GST_STATE_NULL);
|
gst_element_set_state (pipe, GST_STATE_NULL);
|
||||||
gst_object_unref (inputpad);
|
gst_object_unref (inputpad);
|
||||||
|
|
Loading…
Reference in a new issue