mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 19:55:32 +00:00
tests: improve the example
This commit is contained in:
parent
d2c5ea9a40
commit
e9bcae7377
2 changed files with 37 additions and 19 deletions
|
@ -21,6 +21,17 @@ event_loop (GstBus * bus, GstElement * pipe)
|
||||||
gst_message_unref (message);
|
gst_message_unref (message);
|
||||||
return;
|
return;
|
||||||
case GST_MESSAGE_WARNING:
|
case GST_MESSAGE_WARNING:
|
||||||
|
{
|
||||||
|
GError *gerror;
|
||||||
|
gchar *debug;
|
||||||
|
|
||||||
|
gst_message_parse_warning (message, &gerror, &debug);
|
||||||
|
gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
|
||||||
|
gst_message_unref (message);
|
||||||
|
g_error_free (gerror);
|
||||||
|
g_free (debug);
|
||||||
|
return;
|
||||||
|
}
|
||||||
case GST_MESSAGE_ERROR:{
|
case GST_MESSAGE_ERROR:{
|
||||||
GError *gerror;
|
GError *gerror;
|
||||||
gchar *debug;
|
gchar *debug;
|
||||||
|
@ -79,10 +90,6 @@ sync_bus_handler (GstBus * bus, GstMessage * message, GstElement * bin)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GST_STREAM_STATUS_TYPE_ENTER:
|
case GST_STREAM_STATUS_TYPE_ENTER:
|
||||||
if (task) {
|
|
||||||
g_message ("raising task priority for %p", task);
|
|
||||||
gst_task_set_priority (task, G_THREAD_PRIORITY_HIGH);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case GST_STREAM_STATUS_TYPE_LEAVE:
|
case GST_STREAM_STATUS_TYPE_LEAVE:
|
||||||
break;
|
break;
|
||||||
|
@ -101,7 +108,7 @@ sync_bus_handler (GstBus * bus, GstMessage * message, GstElement * bin)
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
GstElement *bin, *fakesrc, *fakesink;
|
GstElement *bin, *alsasrc, *alsasink;
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
GstStateChangeReturn ret;
|
GstStateChangeReturn ret;
|
||||||
|
|
||||||
|
@ -115,19 +122,22 @@ main (int argc, char *argv[])
|
||||||
g_assert (bin);
|
g_assert (bin);
|
||||||
|
|
||||||
/* create a source */
|
/* create a source */
|
||||||
fakesrc = gst_element_factory_make ("fakesrc", "fakesrc");
|
alsasrc = gst_element_factory_make ("alsasrc", "alsasrc");
|
||||||
g_assert (fakesrc);
|
g_assert (alsasrc);
|
||||||
g_object_set (fakesrc, "num-buffers", 50, NULL);
|
g_object_set (alsasrc, "device", "hw:0", NULL);
|
||||||
|
g_object_set (alsasrc, "slave-method", 2, NULL);
|
||||||
|
|
||||||
/* and a sink */
|
/* and a sink */
|
||||||
fakesink = gst_element_factory_make ("fakesink", "fakesink");
|
alsasink = gst_element_factory_make ("alsasink", "alsasink");
|
||||||
g_assert (fakesink);
|
g_assert (alsasink);
|
||||||
|
g_object_set (alsasink, "device", "hw:0", NULL);
|
||||||
|
g_object_set (alsasink, "buffer-time", (gint64) 10000, NULL);
|
||||||
|
|
||||||
/* add objects to the main pipeline */
|
/* add objects to the main pipeline */
|
||||||
gst_bin_add_many (GST_BIN (bin), fakesrc, fakesink, NULL);
|
gst_bin_add_many (GST_BIN (bin), alsasrc, alsasink, NULL);
|
||||||
|
|
||||||
/* link the elements */
|
/* link the elements */
|
||||||
gst_element_link (fakesrc, fakesink);
|
gst_element_link (alsasrc, alsasink);
|
||||||
|
|
||||||
/* get the bus, we need to install a sync handler */
|
/* get the bus, we need to install a sync handler */
|
||||||
bus = gst_pipeline_get_bus (GST_PIPELINE (bin));
|
bus = gst_pipeline_get_bus (GST_PIPELINE (bin));
|
||||||
|
|
|
@ -53,22 +53,30 @@ default_push (GstTaskPool * pool, GstTaskPoolFunction func, gpointer data,
|
||||||
TestRTId *tid;
|
TestRTId *tid;
|
||||||
gint res;
|
gint res;
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
//struct sched_param param;
|
struct sched_param param;
|
||||||
|
|
||||||
g_message ("pushing Realtime pool %p, %p", pool, func);
|
g_message ("pushing Realtime pool %p, %p", pool, func);
|
||||||
|
|
||||||
tid = g_slice_new0 (TestRTId);
|
tid = g_slice_new0 (TestRTId);
|
||||||
|
|
||||||
|
g_message ("set policy");
|
||||||
pthread_attr_init (&attr);
|
pthread_attr_init (&attr);
|
||||||
/*
|
if ((res = pthread_attr_setschedpolicy (&attr, SCHED_RR)) != 0)
|
||||||
pthread_attr_setschedpolicy (&attr, SCHED_RR);
|
g_warning ("setschedpolicy: failure: %p", g_strerror (res));
|
||||||
param.sched_priority = 50;
|
|
||||||
pthread_attr_setschedparam (&attr, ¶m);
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
g_message ("set prio");
|
||||||
|
param.sched_priority = 50;
|
||||||
|
if ((res = pthread_attr_setschedparam (&attr, ¶m)) != 0)
|
||||||
|
g_warning ("setschedparam: failure: %p", g_strerror (res));
|
||||||
|
|
||||||
|
g_message ("set inherit");
|
||||||
|
if ((res = pthread_attr_setinheritsched (&attr, PTHREAD_EXPLICIT_SCHED)) != 0)
|
||||||
|
g_warning ("setinheritsched: failure: %p", g_strerror (res));
|
||||||
|
|
||||||
|
g_message ("create thread");
|
||||||
res = pthread_create (&tid->thread, &attr, (void *(*)(void *)) func, data);
|
res = pthread_create (&tid->thread, &attr, (void *(*)(void *)) func, data);
|
||||||
|
|
||||||
if (res < 0) {
|
if (res != 0) {
|
||||||
g_set_error (error, G_THREAD_ERROR, G_THREAD_ERROR_AGAIN,
|
g_set_error (error, G_THREAD_ERROR, G_THREAD_ERROR_AGAIN,
|
||||||
"Error creating thread: %s", g_strerror (res));
|
"Error creating thread: %s", g_strerror (res));
|
||||||
g_slice_free (TestRTId, tid);
|
g_slice_free (TestRTId, tid);
|
||||||
|
|
Loading…
Reference in a new issue