g_main_loop_run() freeze the window

Sebastian Dröge sebastian at centricular.com
Wed Dec 23 00:39:24 PST 2015


On Di, 2015-12-22 at 17:59 -0800, doon wrote:
> I added new thread but still have freeze problem, here is my code:
> 
> GstElement *pipeline;
> 
> 	void func() {
> 		GMainLoop *loop = g_main_loop_new(NULL, FALSE);
> 		g_main_loop_run(loop);
> 	}
> 	void start(char* path, void* hwnd_ptr) {
> 		gst_init(NULL, NULL);
> 		HWND hwnd = (HWND)hwnd_ptr;
> 
> 		pipeline = gst_element_factory_make("playbin",
> "player");
> 		g_object_set(G_OBJECT(pipeline), "uri", path, NULL);
> 
> 		gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(p
> ipeline),
> (guintptr)hwnd);
> 
> 		gst_element_set_state(pipeline, GST_STATE_PLAYING);
> 
> 		GThread* thread = g_thread_new(NULL, (GThreadFunc)func,
> NULL);
> 		g_thread_join(thread);
> 	}
> 
> How can I fix it? Any help will be useful.

Why do you join() the thread? This will block your main thread until
the thread has finished. Try removing that line.

Also if you want to have a playback application and nothing more
complicated with GStreamer, take a look at GstPlayer:
https://github.com/sdroege/gst-player

That one can be used directly from your main thread as nothing is
blocking and all event handling is done in the background.

-- 
Sebastian Dröge, Centricular Ltd · http://www.centricular.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 949 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20151223/1d58cfa4/attachment-0001.sig>


More information about the gstreamer-devel mailing list