return ret;
}
+static gpointer __mmplayer_launch_glib_murphy_loop(void *user_data)
+{
+ LOGI("Run mrp_loop");
+ MMPlayerResourceManager *resource_manager= (MMPlayerResourceManager *)user_data;
+ g_main_loop_run(resource_manager->mrp_loop);
+ LOGI("Murphy glib loop exit");
+ return NULL;
+}
+
int _mmplayer_resource_manager_init(MMPlayerResourceManager *resource_manager, void *user_data)
{
MMPLAYER_FENTER();
MMPLAYER_CHECK_RESOURCE_MANAGER_INSTANCE(resource_manager);
- resource_manager->mloop = mrp_mainloop_glib_get(g_main_loop_new(NULL, TRUE));
+ GMainContext *mrp_ctx = g_main_context_new();
+ resource_manager->mrp_loop = g_main_loop_new(mrp_ctx, TRUE);
+ resource_manager->mloop = mrp_mainloop_glib_get(resource_manager->mrp_loop);
+ resource_manager->starter = g_thread_new(NULL, (GThreadFunc)__mmplayer_launch_glib_murphy_loop, resource_manager);
+ g_main_context_unref(mrp_ctx);
if (resource_manager->mloop) {
resource_manager->context = mrp_res_create(resource_manager->mloop, mrp_state_callback, user_data);
if (resource_manager->context == NULL) {
mrp_res_destroy(resource_manager->context);
resource_manager->context = NULL;
}
+ if (resource_manager->mrp_loop) {
+ g_main_loop_quit(resource_manager->mrp_loop);
+ resource_manager->mrp_loop = NULL;
+ }
+ g_thread_join(resource_manager->starter);
+
if (resource_manager->mloop) {
mrp_mainloop_destroy(resource_manager->mloop);
resource_manager->mloop = NULL;