g_main_loop_run() freeze the window

doon don-prog at mail.ru
Fri Dec 25 19:26:49 PST 2015


Sebastian Dröge-3 wrote
> 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
> 
> 
> _______________________________________________
> gstreamer-devel mailing list

> gstreamer-devel at .freedesktop

> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> 
> 
> signature.asc (968 bytes)
> <http://gstreamer-devel.966125.n4.nabble.com/attachment/4674991/0/signature.asc>

Thanks, the problem was due to join()!



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/g-main-loop-run-freeze-the-window-tp4674922p4675031.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list