AW: Loop callback problem (help me pleeeeease. extremely critical!)

Thornton, Keith keith.thornton at zeiss.com
Wed Jun 21 12:11:03 UTC 2017


Hi, your callbackFunction should be returning GST_BUS_PASS or one of the elements of GstBusSyncReply 

-----Ursprüngliche Nachricht-----
Von: gstreamer-devel [mailto:gstreamer-devel-bounces at lists.freedesktop.org] Im Auftrag von Mikl
Gesendet: Mittwoch, 21. Juni 2017 13:12
An: gstreamer-devel at lists.freedesktop.org
Betreff: Loop callback problem (help me pleeeeease. extremely critical!)

Hello,

Sometimes, app stuck in loop.
Meaning, i starting loop, waiting for messages, but not always have control back after all messages processed.

My code (with some simplification):

//-----------------------------
class GStreamer
{

protected:
GMainLoop* _loop;
};

//-----------------------
GStreamer::GStreamer()
{
	//init gstreamer library
	if (GStreamerInitialized == false)
	{
		gst_init(nullptr, nullptr);

		GStreamerInitialized = true;
	}

	_loop = g_main_loop_new(NULL, FALSE);
}

GStreamer::~GStreamer()
{
	g_main_loop_unref(_loop);
}

//-----------------------------
void GStreamer::StartWaitgLoop(GstElement* pipeline)
{	
	//get pipeline bus
	_bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));

	//register call back function for bus monitoring
	gst_bus_add_watch(_bus, CallBackFunction, NULL);

Logger::Trace("GStreamer", "g_main_loop_run start");

	//run loop: _loop is class 
	g_main_loop_run(_loop);

Logger::Trace("GStreamer", "g_main_loop_run stop");

	//not necessary
	gst_bus_remove_watch(_bus);

	//free recources
	gst_object_unref(_bus);
}

//-----------------------------
int CallBackFunction(GstBus* bus, GstMessage* message, void* data) {
	switch (GST_MESSAGE_TYPE(message))
	{
	case GST_MESSAGE_WARNING:
	case GST_MESSAGE_ERROR:

Logger::Trace("GStreamer", "CallBackFunction GST_MESSAGE_ERROR");

		g_main_loop_quit(_loop);

		return false;

		break;

	case GST_MESSAGE_ASYNC_DONE:

Logger::Trace("GStreamer", "CallBackFunction GST_MESSAGE_ASYNC_DONE");

		g_main_loop_quit(_loop);

		return false;

		break;

	default:
		break;
	}

	//return true to be notified next time
	return true;
}

In log file GStreamer ii have to be like this for every call:
/g_main_loop_run start
CallBackFunction GST_MESSAGE_ASYNC_DONE or CallBackFunction GST_MESSAGE_ERROR g_main_loop_run stop/

But sometimes i see this:
/g_main_loop_run start
CallBackFunction GST_MESSAGE_ASYNC_DONE or CallBackFunction GST_MESSAGE_ERROR/

*with no logging about stop.*

And app is stuck of course.

It is happening, when i need to process 2000 files in function, calling StartWaitgLoop.
And even worse if other instance of the GStreamer class in running.

It is nothing special in gstreamer debug file.
https://cloud.mail.ru/public/LPW1/Gruwezfca

Full code is here. With some garbage, because i am trying to solve this problem already one week.
https://cloud.mail.ru/public/8Xhe/DZ4BSwLh7

What i am doing wrong?
Do you need more info?

*HELP ME PLEASE!!!!!*

Thanks in advance.
Mikl



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Loop-callback-problem-help-me-pleeeeease-extremely-critical-tp4683473.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


More information about the gstreamer-devel mailing list