Beispiel #1
0
EAPI int
ecore_audio_init(void)
{

   if (++_ecore_audio_init_count != 1)
     return _ecore_audio_init_count;

   if (!ecore_init())
     return --_ecore_audio_init_count;

   if (!efl_object_init()) {
     ecore_shutdown();
     return --_ecore_audio_init_count;
   }

   _ecore_audio_log_dom = eina_log_domain_register("ecore_audio", ECORE_AUDIO_DEFAULT_LOG_COLOR);
   if (_ecore_audio_log_dom < 0)
     {
        EINA_LOG_ERR("Impossible to create a log domain for the ecore audio module.");
        return --_ecore_audio_init_count;
     }

   DBG("Ecore_Audio init");
   ecore_audio_modules = NULL;


   eina_log_timing(_ecore_audio_log_dom,
		   EINA_LOG_STATE_STOP,
		   EINA_LOG_STATE_INIT);

   return _ecore_audio_init_count;
}
Beispiel #2
0
EAPI int
ecore_audio_shutdown(void)
{
   DBG("Ecore_Audio shutdown");
   if (--_ecore_audio_init_count != 0)
     return _ecore_audio_init_count;

#ifdef HAVE_SNDFILE
   ecore_audio_sndfile_lib_unload();
#endif /* HAVE_SNDFILE */
#ifdef HAVE_PULSE
   ecore_audio_pulse_lib_unload();
#endif /* HAVE_PULSE */

   /* FIXME: Shutdown all the inputs and outputs first */
   eina_log_timing(_ecore_audio_log_dom,
		   EINA_LOG_STATE_START,
		   EINA_LOG_STATE_SHUTDOWN);


   eina_list_free(ecore_audio_modules);

   eina_log_domain_unregister(_ecore_audio_log_dom);
   _ecore_audio_log_dom = -1;

   efl_object_shutdown();
   ecore_shutdown();

   return _ecore_audio_init_count;
}
Beispiel #3
0
EAPI int
eina_shutdown(void)
{
   if (_eina_main_count <= 0)
     {
        ERR("Init count not greater than 0 in shutdown.");
        return 0;
     }
   _eina_main_count--;
   if (EINA_UNLIKELY(_eina_main_count == 0))
     {
        eina_log_timing(_eina_log_dom,
                        EINA_LOG_STATE_START,
                        EINA_LOG_STATE_SHUTDOWN);

        _eina_shutdown_from_desc(_eina_desc_setup + _eina_desc_setup_len);

#ifdef EINA_HAVE_DEBUG_THREADS
	pthread_mutex_destroy(&_eina_tracking_lock);
#endif
#ifdef MT
        if (_mt_enabled)
          {
             muntrace();
             _mt_enabled = 0;
          }
#endif
     }

   return _eina_main_count;
}
Beispiel #4
0
EAPI int eolian_shutdown(void)
{
   if (_eolian_init_counter <= 0)
     {
        EINA_LOG_ERR("Init count not greater than 0 in shutdown.");
        return 0;
     }
   _eolian_init_counter--;

   if (_eolian_init_counter == 0)
     {
        INF("Shutdown");
        eina_log_timing(_eolian_log_dom,
              EINA_LOG_STATE_START,
              EINA_LOG_STATE_SHUTDOWN);

        eo_lexer_shutdown();
        database_shutdown();
        eina_prefix_free(_eolian_prefix);
        _eolian_prefix = NULL;

        eina_log_domain_unregister(_eolian_log_dom);
        _eolian_log_dom = -1;
        eina_shutdown();
     }

   return _eolian_init_counter;
}
Beispiel #5
0
EAPI int eolian_init(void)
{
   const char *log_dom = "eolian";
   if (_eolian_init_counter > 0) return ++_eolian_init_counter;

   eina_init();
   _eolian_log_dom = eina_log_domain_register(log_dom, EINA_COLOR_LIGHTBLUE);
   if (_eolian_log_dom < 0)
     {
        EINA_LOG_ERR("Could not register log domain: %s", log_dom);
        return EINA_FALSE;
     }

   eina_log_timing(_eolian_log_dom,
                   EINA_LOG_STATE_STOP,
                   EINA_LOG_STATE_INIT);

   INF("Init");

   _eolian_prefix = eina_prefix_new(NULL, eolian_init, "EOLIAN", "eolian",
                                    NULL, "", "", PACKAGE_DATA_DIR, "");
   if (!_eolian_prefix)
     {
        ERR("Could not initialize the Eolian prefix.");
        return EINA_FALSE;
     }

   database_init();
   eo_lexer_init();
   return ++_eolian_init_counter;
}
Beispiel #6
0
EAPI int
eio_init(void)
{
    if (++_eio_init_count != 1)
        return _eio_init_count;

    if (!eina_init())
    {
        fprintf(stderr, "Eio can not initialize Eina\n");
        return --_eio_init_count;
    }

    _eio_log_dom_global = eina_log_domain_register("eio", EIO_DEFAULT_LOG_COLOR);
    if (_eio_log_dom_global < 0)
    {
        EINA_LOG_ERR("Eio can not create a general log domain.");
        goto shutdown_eina;
    }

    if (!ecore_init())
    {
        ERR("Can not initialize Ecore\n");
        goto unregister_log_domain;
    }

    memset(&progress_pool, 0, sizeof(progress_pool));
    memset(&direct_info_pool, 0, sizeof(direct_info_pool));
    memset(&char_pool, 0, sizeof(char_pool));
    memset(&associate_pool, 0, sizeof(associate_pool));

    eina_lock_new(&(progress_pool.lock));
    progress_pool.mem_size = sizeof (Eio_Progress);
    eina_lock_new(&(direct_info_pool.lock));
    direct_info_pool.mem_size = sizeof (Eio_File_Direct_Info);
    eina_lock_new(&(char_pool.lock));
    char_pool.mem_size = sizeof (Eio_File_Char);
    eina_lock_new(&(associate_pool.lock));
    associate_pool.mem_size = sizeof (Eio_File_Associate);

    eina_spinlock_new(&(memory_pool_lock));
    eina_lock_new(&(memory_pool_mutex));
    eina_condition_new(&(memory_pool_cond), &(memory_pool_mutex));

    eio_monitor_init();

    eina_log_timing(_eio_log_dom_global,
                    EINA_LOG_STATE_STOP,
                    EINA_LOG_STATE_INIT);

    return _eio_init_count;

unregister_log_domain:
    eina_log_domain_unregister(_eio_log_dom_global);
    _eio_log_dom_global = -1;
shutdown_eina:
    eina_shutdown();
    return --_eio_init_count;
}
Beispiel #7
0
EAPI int
eio_shutdown(void)
{
   Eio_File_Direct_Info *info;
   Eio_File_Char *cin;
   Eio_Progress *pg;
   Eio_File_Associate *asso;

   if (_eio_init_count <= 0)
     {
        ERR("Init count not greater than 0 in shutdown.");
        return 0;
     }
   if (--_eio_init_count != 0)
     return _eio_init_count;

   eina_log_timing(_eio_log_dom_global,
		   EINA_LOG_STATE_START,
		   EINA_LOG_STATE_SHUTDOWN);

   eio_monitor_shutdown();

   eina_condition_free(&(memory_pool_cond));
   eina_lock_free(&(memory_pool_mutex));
   eina_spinlock_free(&(memory_pool_lock));

   eina_lock_free(&(direct_info_pool.lock));
   eina_lock_free(&(progress_pool.lock));
   eina_lock_free(&(char_pool.lock));
   eina_lock_free(&(associate_pool.lock));

   /* Cleanup pool */
   EINA_TRASH_CLEAN(&progress_pool.trash, pg)
     free(pg);
   progress_pool.count = 0;

   EINA_TRASH_CLEAN(&direct_info_pool.trash, info)
     free(info);
   direct_info_pool.count = 0;

   EINA_TRASH_CLEAN(&char_pool.trash, cin)
     free(cin);
   char_pool.count = 0;

   EINA_TRASH_CLEAN(&associate_pool.trash, asso)
     free(asso);
   associate_pool.count = 0;

   ecore_shutdown();
   eina_log_domain_unregister(_eio_log_dom_global);
   _eio_log_dom_global = -1;
   eina_shutdown();

   return _eio_init_count;
}
Beispiel #8
0
EAPI int
eio_shutdown(void)
{
   Eio_File_Direct_Info *info;
   Eio_File_Char *cin;
   Eio_Progress *pg;
   Eio_File_Associate *asso;
   Eio_File *f;
   Eina_List *l;

   if (_eio_init_count <= 0)
     {
        ERR("Init count not greater than 0 in shutdown.");
        return 0;
     }
   if (--_eio_init_count != 0)
     return _eio_init_count;

   eina_log_timing(_eio_log_dom_global,
                   EINA_LOG_STATE_START,
                   EINA_LOG_STATE_SHUTDOWN);

   efl_del(io_manager);
   io_manager = NULL;

   EINA_LIST_FOREACH(tracked_thread, l, f)
     ecore_thread_cancel(f->thread);

   EINA_LIST_FREE(tracked_thread, f)
     {
        if (!ecore_thread_wait(f->thread, 0.5))
          CRI("We couldn't terminate in less than 30s some pending IO. This can led to some crash.");
     }

   efreet_mime_shutdown();

   eio_monitor_shutdown();

   eina_condition_free(&(memory_pool_cond));
   eina_lock_free(&(memory_pool_mutex));
   eina_spinlock_free(&(memory_pool_lock));

   eina_lock_free(&(direct_info_pool.lock));
   eina_lock_free(&(progress_pool.lock));
   eina_lock_free(&(char_pool.lock));
   eina_lock_free(&(associate_pool.lock));

   /* Cleanup pool */
   EINA_TRASH_CLEAN(&progress_pool.trash, pg)
     free(pg);
   progress_pool.count = 0;

   EINA_TRASH_CLEAN(&direct_info_pool.trash, info)
     free(info);
   direct_info_pool.count = 0;

   EINA_TRASH_CLEAN(&char_pool.trash, cin)
     free(cin);
   char_pool.count = 0;

   EINA_TRASH_CLEAN(&associate_pool.trash, asso)
     free(asso);
   associate_pool.count = 0;

   ecore_shutdown();
   eina_log_domain_unregister(_eio_log_dom_global);
   _eio_log_dom_global = -1;
   eina_shutdown();

   return _eio_init_count;
}
Beispiel #9
0
EAPI int
eina_init(void)
{
   const struct eina_desc_setup *itr, *itr_end;

   if (EINA_LIKELY(_eina_main_count > 0))
      return ++_eina_main_count;

   srand(time(NULL));
   while (eina_seed == 0)
     eina_seed = rand();

#ifdef MT
   if ((getenv("EINA_MTRACE")) && (getenv("MALLOC_TRACE")))
     {
        _mt_enabled = 1;
        mtrace();
     }
#endif

   if (!eina_log_init())
     {
        fprintf(stderr, "Could not initialize eina logging system.\n");
        return 0;
     }

   _eina_log_dom = eina_log_domain_register("eina", EINA_LOG_COLOR_DEFAULT);
   if (_eina_log_dom < 0)
     {
        EINA_LOG_ERR("Could not register log domain: eina");
        eina_log_shutdown();
        return 0;
     }

   EINA_ERROR_NOT_MAIN_LOOP = eina_error_msg_static_register(
         EINA_ERROR_NOT_MAIN_LOOP_STR);

#ifdef EFL_HAVE_THREADS
# ifdef _WIN32
   _eina_main_loop = GetCurrentThreadId();
# else
   _eina_main_loop = pthread_self();
# endif
   _eina_pid = getpid();
#endif

#ifdef EINA_HAVE_DEBUG_THREADS
   pthread_mutex_init(&_eina_tracking_lock, NULL);

   if (getenv("EINA_DEBUG_THREADS"))
     _eina_threads_debug = atoi(getenv("EINA_DEBUG_THREADS"));
#endif

   itr = _eina_desc_setup;
   itr_end = itr + _eina_desc_setup_len;
   for (; itr < itr_end; itr++)
     {
        if (!itr->init())
          {
             ERR("Could not initialize eina module '%s'.", itr->name);
             _eina_shutdown_from_desc(itr);
             return 0;
          }
     }

   eina_cpu_count_internal();

   eina_log_timing(_eina_log_dom, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT);

   _eina_main_count = 1;
   return 1;
}