static int _ecore_exe_win32_pipes_set(Ecore_Exe *exe) { SECURITY_ATTRIBUTES sa; HANDLE child_pipe; HANDLE child_pipe_x; sa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.bInheritHandle = EINA_TRUE; sa.lpSecurityDescriptor = NULL; if (!CreatePipe(&child_pipe, &child_pipe_x, &sa, 0)) return 0; if (exe->flags & ECORE_EXE_PIPE_WRITE) { if (!SetHandleInformation(child_pipe_x, HANDLE_FLAG_INHERIT, 0)) goto close_pipe; } else { if (!SetHandleInformation(child_pipe, HANDLE_FLAG_INHERIT, 0)) goto close_pipe; } if (exe->flags & ECORE_EXE_PIPE_READ) { exe->pipe_read.child_pipe = child_pipe; exe->pipe_read.child_pipe_x = child_pipe_x; exe->pipe_read.p = ecore_pipe_add(_ecore_exe_pipe_read_cb, exe); exe->pipe_read.thread = CreateThread(NULL, 0, _ecore_exe_win32_pipe_thread_read_cb, exe, 0, NULL); } else if (exe->flags & ECORE_EXE_PIPE_WRITE) { exe->pipe_write.child_pipe = child_pipe; exe->pipe_write.child_pipe_x = child_pipe_x; /* exe->pipe_write.thread = CreateThread(NULL, 0, */ /* _ecore_exe_win32_pipe_thread_cb, */ /* exe, 0, NULL); */ } else { exe->pipe_error.child_pipe = child_pipe; exe->pipe_error.child_pipe_x = child_pipe_x; exe->pipe_error.p = ecore_pipe_add(_ecore_exe_pipe_error_cb, exe); exe->pipe_error.thread = CreateThread(NULL, 0, _ecore_exe_win32_pipe_thread_error_cb, exe, 0, NULL); } return 1; close_pipe: CloseHandle(child_pipe); CloseHandle(child_pipe_x); return 0; }
int main (int argc, char *argv[]) { Ecore_Pipe *pipe; pid_t child_pid; ecore_init(); pipe = ecore_pipe_add(handler, NULL); child_pid = fork(); if(!child_pid) { ecore_pipe_read_close(pipe); do_lengthy_task(pipe); } else { ecore_pipe_write_close(pipe); ecore_main_loop_begin(); } ecore_pipe_del(pipe); ecore_shutdown(); return 0; }
RunLoop::RunLoop() : m_initEfl(false) , m_wakeUpEventRequested(false) { m_pipe = adoptPtr(ecore_pipe_add(wakeUpEvent, this)); m_initEfl = true; }
int main(int argc, char *argv[]) { GstElement *pipeline; char *filename; Ecore_Pipe *pipe; gst_init(&argc, &argv); if (!ecore_init()) { gst_deinit(); return 0; } pipe = ecore_pipe_add(handler); if (!pipe) { ecore_shutdown(); gst_deinit(); return 0; } if (argc < 2) { g_print("usage: %s file.avi\n", argv[0]); ecore_pipe_del(pipe); ecore_shutdown(); gst_deinit(); return 0; } filename = argv[1]; pipeline = _buid_pipeline(filename, pipe); if (!pipeline) { g_print("Error during the pipeline building\n"); ecore_pipe_del(pipe); ecore_shutdown(); gst_deinit(); return -1; } gst_element_set_state(pipeline, GST_STATE_PLAYING); ecore_main_loop_begin(); ecore_pipe_del(pipe); ecore_shutdown(); gst_deinit(); return 0; }
int mp_app_inotify_init(void *data) { struct appdata *ad = data; mp_inotify_t *handle = NULL; handle = _mp_app_inotify_handle_init(); mp_retvm_if(handle == NULL, -1, "fail to _mp_app_inotify_handle_init()"); handle->fd = inotify_init(); if (handle->fd < 0) { switch (errno) { case EMFILE: ERROR_TRACE("The user limit on the total number of inotify instances has been reached.\n"); break; case ENFILE: ERROR_TRACE("The system limit on the total number of file descriptors has been reached.\n"); break; case ENOMEM: ERROR_TRACE("Insufficient kernel memory is available.\n"); break; default: ERROR_TRACE("Fail to inotify_init(), Unknown error.\n"); break; } return -1; } pthread_create(&handle->monitor, NULL, _mp_app_inotify_watch_thread, handle); _mp_app_inotify_add_recursive_watch(MP_MMC_ROOT_PATH, ad); _mp_app_inotify_add_recursive_watch(MP_PHONE_ROOT_PATH, ad); ad->inotify_pipe = ecore_pipe_add(_mp_app_pipe_cb, (const void *)ad); return 0; }
EAPI void ecore_fork_reset(void) { Eina_List *l, *ln; Ecore_Fork_Cb *fcb; eina_lock_take(&_thread_safety); ecore_pipe_del(_thread_call); _thread_call = ecore_pipe_add(_thread_callback, NULL); /* If there was something in the pipe, trigger a wakeup again */ if (_thread_cb) ecore_pipe_write(_thread_call, &wakeup, sizeof (int)); eina_lock_release(&_thread_safety); // should this be done withing the eina lock stuff? fork_cbs_walking++; EINA_LIST_FOREACH(fork_cbs, l, fcb) { fcb->func(fcb->data); }
RunLoop::RunLoop() : m_initEfl(false) , m_wakeUpEventRequested(false) { if (!ecore_init()) { LOG_ERROR("could not init ecore."); return; } if (!ecore_evas_init()) { LOG_ERROR("could not init ecore_evas."); goto errorEcoreEvas; } if (!ecore_file_init()) { LOG_ERROR("could not init ecore_file."); goto errorEcoreFile; } if (!edje_init()) { LOG_ERROR("could not init edje."); goto errorEdje; } m_pipe = adoptPtr(ecore_pipe_add(wakeUpEvent, this)); m_initEfl = true; return; errorEdje: ecore_file_shutdown(); errorEcoreFile: ecore_evas_shutdown(); errorEcoreEvas: ecore_shutdown(); }
/** * Set up connections, signal handlers, sockets etc. * @return 1 or greater on success, 0 otherwise * * This function sets up all singal handlers and the basic event loop. If it * succeeds, 1 will be returned, otherwise 0 will be returned. * * @code * #include <Ecore.h> * * int main(int argc, char **argv) * { * if (!ecore_init()) * { * printf("ERROR: Cannot init Ecore!\n"); * return -1; * } * ecore_main_loop_begin(); * ecore_shutdown(); * } * @endcode */ EAPI int ecore_init(void) { if (++_ecore_init_count != 1) return _ecore_init_count; #ifdef HAVE_LOCALE_H setlocale(LC_CTYPE, ""); #endif /* if (strcmp(nl_langinfo(CODESET), "UTF-8")) { WRN("Not a utf8 locale!"); } */ #ifdef HAVE_EVIL if (!evil_init()) return --_ecore_init_count; #endif if (!eina_init()) goto shutdown_evil; _ecore_log_dom = eina_log_domain_register("ecore", ECORE_DEFAULT_LOG_COLOR); if (_ecore_log_dom < 0) { EINA_LOG_ERR("Ecore was unable to create a log domain."); goto shutdown_log_dom; } if (getenv("ECORE_FPS_DEBUG")) _ecore_fps_debug = 1; if (_ecore_fps_debug) _ecore_fps_debug_init(); if (!ecore_mempool_init()) goto shutdown_mempool; _ecore_main_loop_init(); _ecore_signal_init(); _ecore_thread_init(); _ecore_exe_init(); _ecore_glib_init(); _ecore_job_init(); _ecore_time_init(); eina_lock_new(&_thread_safety); eina_lock_new(&_thread_mutex); eina_condition_new(&_thread_cond, &_thread_mutex); eina_lock_new(&_thread_feedback_mutex); eina_condition_new(&_thread_feedback_cond, &_thread_feedback_mutex); _thread_call = ecore_pipe_add(_thread_callback, NULL); eina_lock_new(&_thread_id_lock); eina_lock_new(&_ecore_main_loop_lock); #if HAVE_MALLINFO if (getenv("ECORE_MEM_STAT")) { _ecore_memory_pid = getpid(); ecore_animator_add(_ecore_memory_statistic, NULL); } #endif #if defined(GLIB_INTEGRATION_ALWAYS) if (_ecore_glib_always_integrate) ecore_main_loop_glib_integrate(); #endif return _ecore_init_count; shutdown_mempool: ecore_mempool_shutdown(); shutdown_log_dom: eina_shutdown(); shutdown_evil: #ifdef HAVE_EVIL evil_shutdown(); #endif return --_ecore_init_count; }
bool mp_app_noti_init(void *data) { startfunc; struct appdata *ad = data; bool res = TRUE; if (vconf_notify_key_changed(VCONFKEY_FILEMANAGER_DB_STATUS, _mp_app_noti_changed_cb, ad) < 0) { ERROR_TRACE("Error when register callback\n"); res = FALSE; } if (vconf_notify_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, _mp_app_noti_changed_cb, ad) < 0) { ERROR_TRACE("Fail to register VCONFKEY_MUSIC_MENU_CHANGE key callback"); res = FALSE; } if (vconf_notify_key_changed(MP_VCONFKEY_PLAYING_PID, _mp_app_noti_changed_cb, ad) < 0) { ERROR_TRACE("Fail to register MP_VCONFKEY_PLAYING_PID key callback"); res = FALSE; } #if 1 //Minjin if (vconf_notify_key_changed(MP_LIVE_PLAY_STATE, _mp_app_noti_changed_cb, ad) < 0) { ERROR_TRACE("Fail to register MP_LIVE_PLAY_STATE key callback"); res = FALSE; } #endif gNotiPipe = ecore_pipe_add(_mp_app_noti_pipe_handler, ad); #ifdef MP_FEATURE_AVRCP_13 if(!mp_avrcp_target_initialize(_mp_avrcp_connection_state_changed_cb, ad)) { _mp_app_set_avrcp_mode(ad); if(ad->current_track_info) { mp_track_info_t *info = ad->current_track_info; mp_avrcp_noti_track(info->title, info->artist, info->album, info->genre, info->duration); } } mp_avrcp_set_mode_change_cb(_mp_app_avrcp_shuffle_changed_cb, _mp_app_repeat_changed_cb, _mp_app_avrcp_eq_changed_cb, ad); #endif DEBUG_TRACE("Enter sound_manager_set_available_route_changed_cb"); int ret = sound_manager_set_available_route_changed_cb(_mp_add_available_route_changed_cb, ad); if (ret != SOUND_MANAGER_ERROR_NONE) { ERROR_TRACE("sound_manager_set_available_route_changed_cb().. [0x%x]", ret); res = FALSE; } DEBUG_TRACE("Leave sound_manager_set_available_route_changed_cb"); DEBUG_TRACE("Enter sound_manager_set_active_device_changed_cb"); ret = sound_manager_set_active_device_changed_cb(_mp_app_active_device_chaged_cb, ad); if (ret != SOUND_MANAGER_ERROR_NONE) { ERROR_TRACE("sound_manager_set_active_device_changed_cb().. [0x%x]", ret); res = FALSE; } DEBUG_TRACE("Leave sound_manager_set_active_device_changed_cb"); return res; }