return GST_PAD_PROBE_OK;
}
-#define CHECK_FOR_BUFFERING_MSG(PIPELINE, EXPECTED_PERC) \
- G_STMT_START { \
- gint buf_perc; \
- GstMessage *msg; \
- GST_LOG ("waiting for %d%% buffering message", (EXPECTED_PERC)); \
- msg = gst_bus_poll (GST_ELEMENT_BUS (PIPELINE), \
- GST_MESSAGE_BUFFERING | GST_MESSAGE_ERROR, -1); \
- fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR, \
- "Expected BUFFERING message, got ERROR message"); \
- gst_message_parse_buffering (msg, &buf_perc); \
- gst_message_unref (msg); \
- fail_unless (buf_perc == (EXPECTED_PERC), \
- "Got incorrect percentage: %d%% expected: %d%%", buf_perc, \
- (EXPECTED_PERC)); \
- } G_STMT_END
+static void
+check_for_buffering_msg (GstElement * pipeline, gint expected_perc)
+{
+ gint buf_perc;
+ GstMessage *msg;
+
+ GST_LOG ("waiting for %d%% buffering message", expected_perc);
+
+ msg = gst_bus_poll (GST_ELEMENT_BUS (pipeline),
+ GST_MESSAGE_BUFFERING | GST_MESSAGE_ERROR, -1);
+ fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR,
+ "Expected BUFFERING message, got ERROR message");
+
+ gst_message_parse_buffering (msg, &buf_perc);
+ 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)
{
* produce a 100% buffering message. */
thread = g_thread_new ("push1", pad_push_datablock_thread, inputpad);
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_object_unref (inputpad);
/* Check for the buffering message; it should indicate 80% fill level
* (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
* if <1% watermarks are supported. */
* multiqueue contains 80000 bytes, and the high watermark still 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%. */
- CHECK_FOR_BUFFERING_MSG (pipe, 4);
+ check_for_buffering_msg (pipe, 4);
/* Second buffering message is posted after the high-watermark limit
* is set to 0.005. This time, the buffer level is normalized this way:
* 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);
/* Check for the buffering message; it should indicate 8% fill level
* (Note that the percentage from the message is normalized, but since
* 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
* relative fill level doubles. As a result, this should trigger a buffering
* message with a percentage of 16%. */
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.
* This should trigger a 100% buffering message immediately, even without
* pushing in extra data. */
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_object_unref (inputpad);
/* Check for the buffering message; it should indicate 100% relative fill
* 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%.
* 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%
* and 8%/20% = 40%). */
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_object_unref (inputpad);