GST_STATIC_CAPS_ANY);
GMainLoop *loop;
-gint ready = 0;
+static gint ready = 0;
+
+static GCond cond;
static guint bytes_received;
-guint data_size;
+static guint data_size;
+
static gboolean
count_bytes (GstBuffer ** buffer, guint idx, gpointer data)
{
gsize size = gst_buffer_get_size (*buffer);
- GST_DEBUG ("received %" G_GSIZE_FORMAT " bytes", size);
+ g_debug ("received %" G_GSIZE_FORMAT " bytes", size);
+ g_mutex_lock(&mutex);
bytes_received += size;
+ g_cond_signal (&cond);
+ g_mutex_unlock (&mutex);
return TRUE;
}
{
gst_buffer_list_foreach (list, count_bytes, NULL);
- if (data_size <= bytes_received) {
- GST_DEBUG ("We received expected data size");
- g_main_loop_quit (loop);
- }
-
gst_buffer_list_unref (list);
return GST_FLOW_OK;
{
gsize size = gst_buffer_get_size (buffer);
- GST_DEBUG ("received %" G_GSIZE_FORMAT " bytes", size);
+ g_debug ("received %" G_GSIZE_FORMAT " bytes", size);
+ g_mutex_lock(&mutex);
bytes_received += size;
-
- if (data_size <= bytes_received) {
- GST_DEBUG ("We received expected data size");
- g_main_loop_quit (loop);
- }
+ g_cond_signal (&cond);
+ g_mutex_unlock (&mutex);
gst_buffer_unref (buffer);
fail_unless_equals_int (gst_pad_push_list (srcpad, list), GST_FLOW_OK);
- GST_DEBUG ("Waiting for buffers");
- g_main_loop_run (loop);
+ g_debug ("Waiting for buffers");
+
+ g_mutex_lock (&mutex);
+ while (bytes_received < data_size) {
+ g_cond_wait (&cond, &mutex);
+ }
+ g_mutex_unlock (&mutex);
+
+ g_assert_cmpuint (bytes_received, ==, data_size);
+ g_debug ("We received expected data size");
fail_unless_equals_int (data_size, bytes_received);