예제 #1
0
static int
set_timer(duk_context *duk, int repeat)
{
  es_context_t *ec = es_get(duk);

  es_timer_t *et = es_resource_create(ec, &es_resource_timer, 1);
  int val = duk_require_int(duk, 1);

  es_root_register(duk, 0, et);

  et->et_interval = val * repeat;

  int64_t now = arch_get_ts();
  et->et_expire = now + val * 1000LL;

  hts_mutex_lock(&timer_mutex);

  if(thread_running == 0) {
    thread_running = 1;
    hts_thread_create_detached("estimer", timer_thread, NULL,
                               THREAD_PRIO_MODEL);
  } else {
    hts_cond_signal(&timer_cond);
  }

  LIST_INSERT_SORTED(&timers, et, et_link, estimercmp, es_timer_t);

  hts_mutex_unlock(&timer_mutex);

  es_resource_push(duk, &et->super);
  return 1;
}
예제 #2
0
파일: connman.c 프로젝트: Ezio-PS/movian
void
connman_init(void)
{
  TAILQ_INIT(&connman_services);

  netconf_model = prop_create_root(NULL);
  prop_concat_t *pc = prop_concat_create(prop_create(netconf_model, "nodes"));

  net_state     = prop_create(netconf_model, "status");
  prop_set(netconf_model, "type", PROP_SET_STRING, "directory");

  prop_t *m = prop_create(netconf_model, "metadata");
  prop_set(m, "title", PROP_SET_RSTRING, _("Network connections"));


  // service_nodes contains list of items we receive from connman
  service_nodes = prop_create_root(NULL);
  prop_concat_add_source(pc, service_nodes, NULL);

  // settings
  connman_settings = prop_create_root(NULL);

  prop_t *delim = prop_create_root(NULL);
  prop_set_string(prop_create(delim, "type"), "separator");
  prop_concat_add_source(pc, prop_create(connman_settings, "nodes"), delim);

  settings_add_url(gconf.settings_network,
		   _p("Network connections"), NULL, NULL, NULL, MYURL,
		   SETTINGS_FIRST);

  hts_thread_create_detached("connman", connman_thread, NULL,
			     THREAD_PRIO_BGTASK);
}
예제 #3
0
static int
library_open(prop_t *page, const char *url, int sync)
{
    const char *q;
    bmdb_t *b;
    prop_t *model = prop_create(page, "model");

    url += strlen("library:");

    if((q = mystrbegins(url, "albums:")) != NULL) {
        b = bmdb_query_create(q, LIBRARY_QUERY_ALBUMS, model);
    } else if((q = mystrbegins(url, "album:")) != NULL) {
        b = bmdb_query_create(q, LIBRARY_QUERY_ALBUM, model);
        prop_set(model, "contents", PROP_SET_STRING, "album");
    } else if((q = mystrbegins(url, "artists:")) != NULL) {
        b = bmdb_query_create(q, LIBRARY_QUERY_ARTISTS, model);
    } else if((q = mystrbegins(url, "artist:")) != NULL) {
        b = bmdb_query_create(q, LIBRARY_QUERY_ARTIST, model);
        prop_set(model, "contents", PROP_SET_STRING, "artist");
    } else {
        nav_open_error(page, "Invalid browse URL");
        return 0;
    }

    hts_thread_create_detached("bmdbquery", bmdb_thread, b, THREAD_PRIO_LOW);
    return 0;
}
예제 #4
0
파일: usage.c 프로젝트: Ralbarker/showtime
void
usage_report_send(int stored)
{
  if(gconf.device_id[0] == 0)
    return;

  htsmsg_t *m;
  if(stored) {
    m = htsmsg_store_load("usage");
    if(m == NULL)
      return;

    htsmsg_store_remove("usage");

    // Legacy cleanup, remove some day
    htsmsg_store_remove("usagecounters");
    htsmsg_store_remove("plugincounters");

  } else {

    hts_mutex_lock(&usage_mutex);
    m = make_usage_report();
    hts_mutex_unlock(&usage_mutex);
  }

  hts_thread_create_detached("report", send_report, m, THREAD_PRIO_BGTASK);
}
예제 #5
0
파일: js.c 프로젝트: Daisho/showtime
void
js_load(const char *url)
{
  char *u = strdup(url);
  
  hts_thread_create_detached("rawjs", js_load_thread, u, THREAD_PRIO_LOW);
}
예제 #6
0
파일: ssdp.c 프로젝트: kshostak/showtime
void
ssdp_init(const char *uuid)
{
  shutdown_hook_add(ssdp_shutdown, NULL, 1);
  ssdp_uuid = strdup(uuid);
  hts_thread_create_detached("ssdp", ssdp_thread, NULL,
			     THREAD_PRIO_BGTASK);
}
예제 #7
0
void
app_shutdown(int retcode)
{
  TRACE(TRACE_DEBUG, "core", "Shutdown requested, returncode = %d", retcode);

  if(gconf.exit_code != 1) {
    // Force exit
    gconf.exit_code = retcode;
    arch_exit();
  }

  gconf.exit_code = retcode;

  hts_thread_create_detached("eject", shutdown_eject, NULL, THREAD_PRIO_BGTASK);
  hts_thread_create_detached("shutdown", do_shutdown, NULL, THREAD_PRIO_BGTASK);

}
예제 #8
0
파일: lirc.c 프로젝트: dev-life/showtime
static void
lirc_open(void)
{
  int fd;

  fd = lirc_open_socket("/var/run/lirc/lircd");
  if(fd == -1)
    fd = lirc_open_socket("/dev/lircd"); // Old path

  if(fd == -1)
    return;

  lirc_fd = fd;
  hts_thread_create_detached("lirc", lirc_thread, NULL,
			     THREAD_PRIO_UI_WORKER_HIGH);
}
예제 #9
0
static void
locatedb_search(prop_t *model, const char *query)
{
  if (!locatedb_enabled)
    return;

  fa_search_t *fas = calloc(1, sizeof(*fas));
  char *s;

  /* Convery query to lower-case to provide case-insensitive search. */
  fas->fas_query = s = strdup(query);
  do {
    *s = tolower((int)*s);
  } while (*++s);

  fas->fas_run = 1;
  fas->fas_nodes = prop_ref_inc(prop_create(model, "nodes"));

  hts_thread_create_detached("fa search", fa_searcher, fas,
			     THREAD_PRIO_NORMAL);
}
예제 #10
0
void
showtime_shutdown(int retcode)
{
    TRACE(TRACE_DEBUG, "core", "Shutdown requested, returncode = %d", retcode);

    if(showtime_retcode != 1) {
        // Force exit
        arch_exit(retcode);
    }

    showtime_retcode = retcode;

    // run early shutdown hooks (those must be fast)
    shutdown_hook_run(1);

    htsmsg_store_flush();

    if(ui_shutdown() == -1) {
        // Primary UI has no shutdown method, launch a new thread to stop
        hts_thread_create_detached("shutdown", showtime_shutdown0, NULL,
                                   THREAD_PRIO_NORMAL);
    }
}
예제 #11
0
파일: libcec.c 프로젝트: Ezio-PS/movian
static void
libcec_init(void)
{
  hts_thread_create_detached("cec", libcec_init_thread, NULL,
                             THREAD_PRIO_BGTASK);
}
예제 #12
0
void
background_init(prop_t *ui, prop_t *nav,
		void (*set_image)(rstr_t *url, const char **vpaths, 
				  void *opaque),
		void (*set_alpha)(float alpha, void *opaque),
		void *opaque)
{
  bg_helper_t *bgh = calloc(1, sizeof(bg_helper_t));
  bgh->pc = prop_courier_create_waitable();
  bgh->set_image = set_image;
  bgh->set_alpha = set_alpha;

  prop_subscribe(0,
		 PROP_TAG_NAME("ui","fullwindow"),
		 PROP_TAG_CALLBACK_INT, set_in_fullwindow, bgh,
		 PROP_TAG_ROOT, ui,
		 PROP_TAG_COURIER, bgh->pc,
		 NULL);

  prop_subscribe(0,
		 PROP_TAG_NAME("ui","screensaverActive"),
		 PROP_TAG_CALLBACK_INT, set_in_screensaver, bgh,
		 PROP_TAG_ROOT, ui,
		 PROP_TAG_COURIER, bgh->pc,
		 NULL);

  prop_subscribe(0,
		 PROP_TAG_NAME("ui","skin", "path"),
		 PROP_TAG_CALLBACK_RSTR, set_skin_path, bgh,
		 PROP_TAG_ROOT, ui,
		 PROP_TAG_COURIER, bgh->pc,
		 NULL);

  prop_subscribe(0,
		 PROP_TAG_NAME("ui","background"),
		 PROP_TAG_CALLBACK_RSTR, set_bg2, bgh,
		 PROP_TAG_ROOT, ui,
		 PROP_TAG_COURIER, bgh->pc,
		 NULL);

  prop_subscribe(0,
		 PROP_TAG_NAME("nav","currentpage","glw", "background"),
		 PROP_TAG_CALLBACK_RSTR, set_bg1, bgh,
		 PROP_TAG_ROOT, nav,
		 PROP_TAG_COURIER, bgh->pc,
		 NULL);

  prop_subscribe(0,
		 PROP_TAG_NAME("nav","currentpage", "model", "metadata",
			       "background"),
		 PROP_TAG_CALLBACK_RSTR, set_bg0, bgh,
		 PROP_TAG_ROOT, nav,
		 PROP_TAG_COURIER, bgh->pc,
		 NULL);

  prop_subscribe(0,
		 PROP_TAG_NAME("nav","currentpage","glw", "backgroundAlpha"),
		 PROP_TAG_CALLBACK_FLOAT, set_alpha1, bgh,
		 PROP_TAG_ROOT, nav,
		 PROP_TAG_COURIER, bgh->pc,
		 NULL);

  prop_subscribe(0,
		 PROP_TAG_NAME("nav","currentpage", "model", "metadata",
			       "backgroundAlpha"),
		 PROP_TAG_CALLBACK_FLOAT, set_alpha0, bgh,
		 PROP_TAG_ROOT, nav,
		 PROP_TAG_COURIER, bgh->pc,
		 NULL);

  hts_thread_create_detached("bgloader", bgloader_thread, bgh, 
			     THREAD_PRIO_UI_WORKER_LOW);
}
예제 #13
0
void
showtime_init(void)
{
  int r;

  hts_mutex_init(&gconf.state_mutex);
  hts_cond_init(&gconf.state_cond, &gconf.state_mutex);

  gconf.exit_code = 1;

  unicode_init();

  /* Initialize property tree */
  prop_init();
  init_global_info();

  /* Initiailize logging */
  trace_init();

  /* Callout framework */
  callout_init();

  /* Initialize htsmsg_store() */
  htsmsg_store_init();

  /* Notification framework */
  notifications_init();

  /* Initialize settings */
  settings_init();

  TRACE(TRACE_DEBUG, "core", "Loading resources from %s", showtime_dataroot());

  /* Try to create cache path */
  if(gconf.cache_path != NULL &&
     (r = makedirs(gconf.cache_path)) != 0) {
    TRACE(TRACE_ERROR, "cache", "Unable to create cache path %s -- %s",
	  gconf.cache_path, strerror(r));
    gconf.cache_path = NULL;
  }

  /* Initialize sqlite3 */
  db_init();

  /* Initializte blob cache */
  blobcache_init();

  /* Try to create settings path */
  if(gconf.persistent_path != NULL &&
     (r = makedirs(gconf.persistent_path)) != 0) {
    TRACE(TRACE_ERROR, "settings",
	  "Unable to create path for persistent storage %s -- %s",
	  gconf.persistent_path, strerror(r));
    gconf.persistent_path = NULL;
  }

  /* Metadata init */
  metadata_init();
  metadb_init();
  kvstore_init();

  /* Metadata decoration init */
  decoration_init();

  /* Initialize keyring */
  keyring_init();

#if ENABLE_LIBAV
  /* Initialize libavcodec & libavformat */
  av_lockmgr_register(fflockmgr);
  av_log_set_callback(fflog);
  av_register_all();

  TRACE(TRACE_INFO, "libav", LIBAVFORMAT_IDENT", "LIBAVCODEC_IDENT", "LIBAVUTIL_IDENT);
#endif

  /* Freetype */
#if ENABLE_LIBFREETYPE
  freetype_init();
  rasterizer_ft_init();
#endif

#if ENABLE_GLW
  glw_settings_init();
#endif

  fontstash_init();

  /* Global keymapper */
  keymapper_init();

  /* Initialize media subsystem */
  media_init();

  /* Service handling */
  service_init();

  /* Initialize backend content handlers */
  backend_init();

  /* Initialize navigator */
  nav_init();

  /* Initialize audio subsystem */
  audio_init();

  /* Initialize plugin manager */
  plugins_init(gconf.devplugin);

  /* Start software installer thread (plugins, upgrade, etc) */
  hts_thread_create_detached("swinst", swthread, NULL, THREAD_PRIO_LOW);

  /* Internationalization */
  i18n_init();

  /* Video settings */
  video_settings_init();

  if(gconf.load_jsfile)
    js_load(gconf.load_jsfile);

  /* Various interprocess communication stuff (D-Bus on Linux, etc) */
  init_group(INIT_GROUP_IPC);

  /* Service discovery. Must be after ipc_init() (d-bus and threads, etc) */
  if(!gconf.disable_sd)
    sd_init();

  /* Initialize various external APIs */
  init_group(INIT_GROUP_API);

  /* HTTP server and UPNP */
#if ENABLE_HTTPSERVER
  http_server_init();
  if(!gconf.disable_upnp)
    upnp_init();
#endif

  runcontrol_init();
}
예제 #14
0
void
main_init(void)
{
  char errbuf[512];

  hts_mutex_init(&gconf.state_mutex);
  hts_cond_init(&gconf.state_cond, &gconf.state_mutex);

  gconf.exit_code = 1;

  asyncio_init_early();
  init_group(INIT_GROUP_NET);

  unicode_init();


  /* Initialize property tree */
  prop_init();
  init_global_info();

  /* Initiailize logging */
  trace_init();

  /* Callout framework */
  callout_init();
  prop_init_late();

  /* Initialize htsmsg_store() */
  htsmsg_store_init();

  /* Notification framework */
  notifications_init();

  /* Initialize settings */
  settings_init();

  TRACE(TRACE_DEBUG, "core", "Loading resources from %s", app_dataroot());

  TRACE(TRACE_DEBUG, "core", "Cache path: %s", gconf.cache_path);

  /* Try to create cache path */
  if(gconf.cache_path != NULL &&
     fa_makedirs(gconf.cache_path, errbuf, sizeof(errbuf))) {
    TRACE(TRACE_ERROR, "core", "Unable to create cache path %s -- %s",
	  gconf.cache_path, errbuf);
    gconf.cache_path = NULL;
  }

  /* Initialize sqlite3 */
#if ENABLE_SQLITE
  db_init();
#endif

  /* Initializte blob cache */
  blobcache_init();


  TRACE(TRACE_DEBUG, "core", "Persistent path: %s", gconf.persistent_path);

  /* Try to create settings path */
  if(gconf.persistent_path != NULL &&
     fa_makedirs(gconf.persistent_path, errbuf, sizeof(errbuf))) {
    TRACE(TRACE_ERROR, "core",
	  "Unable to create path for persistent storage %s -- %s",
	  gconf.persistent_path, errbuf);
    gconf.persistent_path = NULL;
  }

  /* Per-item key/value store */
  kvstore_init();

  /* Metadata init */
#if ENABLE_METADATA
  metadata_init();
  metadb_init();
  decoration_init();
#endif

  subtitles_init();

  /* Initialize keyring */
  keyring_init();

#if ENABLE_LIBAV
  /* Initialize libavcodec & libavformat */
  av_lockmgr_register(fflockmgr);
  av_log_set_callback(fflog);
  av_register_all();

  TRACE(TRACE_INFO, "libav", LIBAVFORMAT_IDENT", "LIBAVCODEC_IDENT", "LIBAVUTIL_IDENT" cpuflags:0x%x", av_get_cpu_flags());
#endif

  init_group(INIT_GROUP_GRAPHICS);

#if ENABLE_GLW
  glw_settings_init();
#endif

  /* Global keymapper */
  keymapper_init();

  /* Initialize media subsystem */
  media_init();

  /* Service handling */
  service_init();

  /* Initialize backend content handlers */
  backend_init();

  /* Initialize navigator */
  nav_init();

  /* Initialize audio subsystem */
  audio_init();

  /* Initialize plugin manager */
  plugins_init(gconf.devplugins);

  /* Start software installer thread (plugins, upgrade, etc) */
  hts_thread_create_detached("swinst", swthread, NULL, THREAD_PRIO_BGTASK);

  /* Internationalization */
  i18n_init();

  /* Video settings */
  video_settings_init();

  /* Various interprocess communication stuff (D-Bus on Linux, etc) */
  init_group(INIT_GROUP_IPC);

  /* Service discovery. Must be after ipc_init() (d-bus and threads, etc) */
  if(!gconf.disable_sd)
    sd_init();

  /* Initialize various external APIs */
  init_group(INIT_GROUP_API);

  /* Asynchronous IO (Used by HTTP server, etc) */
  asyncio_start();

  runcontrol_init();

  TRACE(TRACE_DEBUG, "SYSTEM", "Hashed device ID: %s", gconf.device_id);
  if(gconf.device_type[0])
    TRACE(TRACE_DEBUG, "SYSTEM", "Device type: %s", gconf.device_type);
}