コード例 #1
0
ファイル: fa_locatedb.c プロジェクト: Ezio-PS/movian
/**
 * Consume 'locate' (updatedb) output results and feed into search results.
 */
static void
fa_locate_searcher (fa_search_t *fas)
{
  char buf[PATH_MAX];
  char iconpath[PATH_MAX];
  regex_t preg;

  prop_t *entries[2] = {NULL, NULL};
  prop_t *nodes[2] = {NULL, NULL};
  int t, i;

  if (fa_create_paths_regex(&preg) == -1)
    return fa_search_destroy(fas);

  snprintf(iconpath, sizeof(iconpath), "%s/res/fileaccess/fs_icon.png",
	   app_dataroot());

  /* Consume 'locate' results. */
  while (1) {
    char url[PATH_MAX+strlen("file://")];
    prop_t *p, *metadata;
    const char *type;
    struct fa_stat fs;
    int ctype;

    prop_courier_poll(fas->fas_pc);

    if (!fas->fas_run)
      break;

    if (!fgets(buf, sizeof(buf), fas->fas_fp))
      break;

    if (!*buf || *buf == '\n')
      continue;

    buf[strlen(buf)-1] = '\0';

    /* Ignore dot-files/dirs. */
    if (strstr(buf, "/."))
      continue;

    if (regexec(&preg, buf, 0, NULL, 0)) {
      TRACE(TRACE_DEBUG, "FA", "Searcher: %s: \"%s\" not matching regex: SKIP",
	    fas->fas_query, buf);
      continue;
    }

    /* Probe media type.
     *
     * FIXME: We might want to hide matching files under a matching directory,
     *        or the other way around.
     *        E..g:
     *           Metallica/
     *                     01-Metallica-Song1.mp3
     *                     02-Metallica-Song1.mp3
     *
     *        Should either hide Metallica/ or 01-Metallica-Song1..2..
     *        But that would require the 'locate' output to be sorted, is it?
     *        Its also problematic where a sub set of the tracks matches
     *        the directory name. Then what should we show?.
     *
     *        There is also the problem with:
     *        Scrubs S01E01/
     *                 Scrubs_s01e01.avi
     *                 Sample/
     *                    Scrubs_s01e01_sample.avi
     *        Which will show as four separate entries, less than optimal.
     *
     *        For now we provide all matches, directories and files,
     *        matching on the entire path (not just the basename).
     */

    snprintf(url, sizeof(url), "file://%s", buf);

    if (fa_stat(url, &fs, NULL, 0))
      continue;

    metadata = prop_create_root("metadata");

    if(fs.fs_type == CONTENT_DIR) {
      ctype = CONTENT_DIR;
      prop_set_string(prop_create(metadata, "title"), basename(buf));
    } else {
      metadata_t *md = fa_probe_metadata(url, NULL, 0, NULL, NULL);
      if(md != NULL) {
	ctype = md->md_contenttype;
	metadata_destroy(md);
      } else {
	ctype = CONTENT_UNKNOWN;
      }
    }


    if (ctype == CONTENT_UNKNOWN)
      continue;

    switch(ctype) {
    case CONTENT_AUDIO:
      t = 0;
      break;

    case CONTENT_VIDEO:
    case CONTENT_DVD:
      t = 1;
      break;

    default:
      continue;
    }


    if(nodes[t] == NULL)
      if(search_class_create(fas->fas_nodes, &nodes[t], &entries[t],
			     t ? "Local video files" : "Local audio files",
			     iconpath))
	break;

    prop_add_int(entries[t], 1);

    if ((type = content2type(ctype)) == NULL)
      continue; /* Unlikely.. */


    p = prop_create_root(NULL);

    if (prop_set_parent(metadata, p))
      prop_destroy(metadata);

    prop_set_string(prop_create(p, "url"), url);
    prop_set_string(prop_create(p, "type"), type);

    if(prop_set_parent(p, nodes[t])) {
      prop_destroy(p);
      break;
    }
  }
  
  for(i = 0; i < 2; i++) {
    if(nodes[i])
      prop_ref_dec(nodes[i]);
    if(entries[i])
      prop_ref_dec(entries[i]);
  }

  TRACE(TRACE_DEBUG, "FA", "Searcher: %s: Done", fas->fas_query);
  fa_search_destroy(fas);

  regfree(&preg);
}
コード例 #2
0
ファイル: glw_rsx.c プロジェクト: tajmouati/showtime
static rsx_fp_t *
load_fp(glw_root_t *gr, const char *filename)
{
  char errmsg[100];
  buf_t *b;
  int i;
  const char *name;

  char url[512];
  snprintf(url, sizeof(url), "%s/src/ui/glw/rsx/%s", 
	   app_dataroot(), filename);

  if((b = fa_load(url, FA_LOAD_ERRBUF(errmsg, sizeof(errmsg)),
                   NULL)) == NULL) {
    TRACE(TRACE_ERROR, "glw", "Unable to load shader %s -- %s\n",
	  url, log);
    return NULL;
  }

  realityFragmentProgram *fp = b->b_ptr;
  RSX_TRACE("Loaded fragment program %s", url);
  RSX_TRACE("  num regs: %d", fp->num_regs);

  realityProgramConst *constants;
  constants = realityFragmentProgramGetConsts(fp);
  for(i = 0; i < fp->num_const; i++) {
    if(constants[i].name_off)
      name = ((char*)fp)+constants[i].name_off;
    else
      name = "<anon>";

    RSX_TRACE("  Constant %s @ 0x%x [%f, %f, %f, %f] type=%d",
	  name,
	  constants[i].index,
	  constants[i].values[0].f,
	  constants[i].values[1].f,
	  constants[i].values[2].f,
	  constants[i].values[3].f,
	  constants[i].type);
  }

  realityProgramAttrib *attributes;
  attributes = realityFragmentProgramGetAttribs(fp);
  for(i = 0; i < fp->num_attrib; i++) {
    if(attributes[i].name_off)
      name = ((char*)fp)+attributes[i].name_off;
    else
      name = "<anon>";

    RSX_TRACE("  Attribute %s @ 0x%x",
	  name, attributes[i].index);
  }

  int offset = rsx_alloc(fp->num_insn * 16, 256);
  uint32_t *buf = rsx_to_ppu(offset);
  RSX_TRACE("  PPU location: 0x%08x  %d bytes",
	buf, fp->num_insn * 16);
  const uint32_t *src = (uint32_t *)((char*)fp + fp->ucode_off);

  memcpy(buf, src, fp->num_insn * 16);
  RSX_TRACE("  RSX location: 0x%08x", offset);

  rsx_fp_t *rfp = calloc(1, sizeof(rsx_fp_t));
  rfp->rfp_binary = fp;
  rfp->rfp_rsx_location = offset;

  rfp->rfp_u_color =
    realityFragmentProgramGetConst(fp, "u_color");

  rfp->rfp_u_color_matrix =
    realityFragmentProgramGetConst(fp, "u_colormtx");

  rfp->rfp_u_blend =
    realityFragmentProgramGetConst(fp, "u_blend");

  for(i = 0; i < 6; i++) {
    char name[8];
    snprintf(name, sizeof(name), "u_t%d", i);
    rfp->rfp_texunit[i] = 
      realityFragmentProgramGetAttrib(fp, name);
    if(rfp->rfp_texunit[i] != -1)
      RSX_TRACE("    Texture %d via unit %d",
	    i, rfp->rfp_texunit[i]);
  }

  return rfp;
}
コード例 #3
0
ファイル: glw_rsx.c プロジェクト: tajmouati/showtime
static rsx_vp_t *
load_vp(const char *filename)
{
  char errmsg[100];
  buf_t *b;
  int i;
  const char *name;
  char url[512];

  snprintf(url, sizeof(url), "%s/src/ui/glw/rsx/%s", 
	   app_dataroot(), filename);

  if((b = fa_load(url, FA_LOAD_ERRBUF(errmsg, sizeof(errmsg)),
                   NULL)) == NULL) {
    TRACE(TRACE_ERROR, "glw", "Unable to load shader %s -- %s\n",
	  url, log);
    return NULL;
  }

  realityVertexProgram *vp = b->b_ptr;

  RSX_TRACE("Loaded Vertex program %s", url);
  RSX_TRACE("    input mask: %x", 
	realityVertexProgramGetInputMask(vp));
  RSX_TRACE("   output mask: %x", 
	realityVertexProgramGetOutputMask(vp));

  realityProgramConst *constants;
  constants = realityVertexProgramGetConstants(vp);
  for(i = 0; i < vp->num_const; i++) {
    if(constants[i].name_off)
      name = ((char*)vp)+constants[i].name_off;
    else
      name = "<anon>";

    RSX_TRACE("  Constant %s @ 0x%x [%f, %f, %f, %f]",
	  name,
	  constants[i].index,
	  constants[i].values[0].f,
	  constants[i].values[1].f,
	  constants[i].values[2].f,
	  constants[i].values[3].f);
  }

  realityProgramAttrib *attributes;
  attributes = realityVertexProgramGetAttributes(vp);
  for(i = 0; i < vp->num_attrib; i++) {
    if(attributes[i].name_off)
      name = ((char*)vp)+attributes[i].name_off;
    else
      name = "<anon>";

    RSX_TRACE("  Attribute %s @ 0x%x",
	  name, attributes[i].index);
  }

  rsx_vp_t *rvp = calloc(1, sizeof(rsx_vp_t));
  rvp->rvp_binary = vp;

  rvp->rvp_u_modelview = realityVertexProgramGetConstant(vp, "u_modelview");
  rvp->rvp_u_color     = vp_get_vector_const(vp, "u_color");
  rvp->rvp_u_color_offset = vp_get_vector_const(vp, "u_color_offset");
  rvp->rvp_u_blur = vp_get_vector_const(vp, "u_blur");

  RSX_TRACE("%d %d", rvp->rvp_u_modelview, rvp->rvp_u_color);

  rvp->rvp_a_position = realityVertexProgramGetAttribute(vp, "a_position");
  rvp->rvp_a_color    = realityVertexProgramGetAttribute(vp, "a_color");
  rvp->rvp_a_texcoord = realityVertexProgramGetAttribute(vp, "a_texcoord");
  RSX_TRACE("%d %d %d",
	rvp->rvp_a_position, rvp->rvp_a_color, rvp->rvp_a_texcoord);

  return rvp;
}
コード例 #4
0
ファイル: showtime.c プロジェクト: tajmouati/showtime
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);
}