Пример #1
0
void PeakODF::reset()
{
    reset_mq(mq_params);
    destroy_mq(mq_params);
    mq_params->frame_size = frame_size;
    mq_params->num_bins = (frame_size/2) + 1;
    mq_params->fundamental = 44100.0 / frame_size; /* TODO: change to params->sampling_rate */
    init_mq(mq_params);
}
Пример #2
0
sdk_ret sdk_ipc_init(int module_id)
{
    sdk_ret sret = SDK_EINNER;
    int ret = -1;

    if (g_init_flag)
        return SDK_EBADPARA;

    g_self_id = module_id;

    sret = init_mq();
    if (SDK_OK != sret)
        goto err_mq;

    sret = init_sync();
    if (SDK_OK != sret)
        goto err_sync;

    sret = init_notify();
    if (SDK_OK != sret)
        goto err_notify;
    
    sret = init_socket();
    if (SDK_OK != sret)
        goto err_sock;

    /* Create IPC main MQ */
    g_main_mq = sdk_ipc_mq_create();
    if (NULL == g_main_mq)
        goto  err_sock;

    /* Start IPC recv thread */
    g_run_flag = 1;
    ret = pthread_create(&g_recv_pid, NULL, recv_thread_routine, NULL);
    if (0 != ret)
        goto err_sock;

    /* Init OK */
    g_init_flag = 1;

    return SDK_OK;

err_sock:
    uninit_socket();

err_notify:
    uninit_notify();

err_sync:
    uninit_sync();

err_mq:
    uninit_mq();

    return SDK_EINNER;
}
Пример #3
0
static void init_global_config(global_conf_st *g_conf, char *file)
{
    if (NULL == file)
    {
	fprintf(stderr, "config file is wrong\n");
	exit(1);
    }
    int L_level = 0;
    xode pnode = xode_from_file(file);
    if (NULL == pnode)
    {
	fprintf(stderr, "config file is wrong\n");
	exit(1);
    }
    int max_thread = xode_get_integer(pnode, "maxThread");
    if (max_thread != -1)
    {
	g_conf->max_thread = max_thread;
    }
    int max_msg_queue_len = xode_get_integer(pnode, "maxMsgQueueLen");
    if (max_msg_queue_len != -1)
    {
	g_conf->max_msg_queue_len = max_msg_queue_len;
    }
    char *log_file = xode_get_string(pnode, "logDir");
    char *redis_conf = xode_get_string(pnode, "redisConf");
    char *reload_file = xode_get_string(pnode, "reloadFile");
    if (log_file == NULL || redis_conf == NULL || reload_file == NULL)
    {
	fprintf(stderr,
		"conf file format wrong ,can't file logDir or redisConf or reload_file\n");
	exit(1);
    }

    snprintf(g_conf->log_dir, sizeof(g_conf->log_dir), "%s", log_file);
    snprintf(g_conf->reload_file, sizeof(g_conf->reload_file), "%s",
	     reload_file);
    snprintf(g_conf->redis_config, sizeof(g_conf->redis_config), "%s",
	     redis_conf);
    char *log_level = xode_get_string(pnode, "logLevel");
    if (log_level != NULL)
    {
	L_level = get_log_level(log_level);
    }
    char program[128];
    memset(program, 0, sizeof(program));
    init_mq(g_conf, pnode);
    snprintf(program, sizeof(program), "%s-%s", PROGRAM,
	     g_conf->receive_mq->task_name);

    gozap_log_init(g_conf->log_dir, L_level, program);

    g_conf->redis_client = redis_client_init(g_conf->redis_config);
    return;
}
Пример #4
0
PeakODF::PeakODF()
{
    mq_params = (MQParameters*)malloc(sizeof(MQParameters));
    mq_params->max_peaks = 20;
    mq_params->frame_size = frame_size;
    mq_params->num_bins = (frame_size/2) + 1;
    mq_params->peak_threshold = 0.1;
    mq_params->matching_interval = 200.0;
    mq_params->fundamental = 44100.0 / frame_size; /* TODO: change to params->sampling_rate */
    init_mq(mq_params);
}
Пример #5
0
int main(int argc, char const *argv[])
{

	//init mq
	close_mq();

	init_mq();

	send_url(argv[1]);
/*
	pthread_t crawler;
	if((pthread_create (&crawler, NULL, asyncCrawling,NULL)!=0)){
		printf("create crawler pthread failed!\n");
		return 0;
	}

	pthread_t analysis;
	if((pthread_create (&analysis, NULL, analysis_thread_dispatch,NULL)!=0)){
		printf("create analysis pthread failed!\n");
		return 0;
	}

	pthread_join(crawler, NULL);
	printf("quit the crawler thread!\n");
	pthread_join(analysis, NULL);
	printf("quit the analysis thread!\n");
	*/
	pool_init(THREAD_NUM);

	sleep(1);
	
	int i;
	for(i=0;i<THREAD_NUM;i++){
		if(i==THREAD_NUM-1){
	 		pool_add_worker(asyncCrawling,NULL);
		}else{
			pool_add_worker(Analysis,NULL);	
		}
	}
	
	printf("nihao!\n");
	sleep(2);
	pool_destroy();

	close_mq();

	return 0;
}
Пример #6
0
int main(void)
{
  psm_ep_t ep;
  psm_epid_t epid, remote_epid;
  psm_mq_t mq;

  psm_epaddr_t *epaddrs;

  char *send = (char*)malloc(BUF_SIZE);
  memset(send, 1, BUF_SIZE);
  char *recv = (char*)malloc(BUF_SIZE);
  memset(recv, 1, BUF_SIZE);
  psm_mq_req_t req;

  init_ep(&ep, &epid);
  write_epid((char*)&epid, sizeof(psm_epid_t), SPATH);
  sleep(5);
  read_epid((char*)&remote_epid, sizeof(psm_epid_t), CPATH);

  fprintf(stderr, "connecting...");
  connect_endpoints(ep, 1, &remote_epid, &epaddrs);
  fprintf(stderr, "done\n");

  init_mq(&ep, &mq);
  int len = 128;
  int repeat;
  int i ;
  while (len < BUF_SIZE) {
    if (len < 8388608) repeat = 1000;
    if (len < BUF_SIZE) repeat = 10;
    repeat = 10;
    for (i = 0; i < repeat; i++) {
      //      fprintf(stderr, "recv: %d\n", len);
      psm_mq_irecv(mq, 0, 0, 0, recv, len, NULL, &req);
      psm_mq_wait(&req, NULL);
      //      fprintf(stderr, "send: %d\n", len);
      psm_mq_send(mq, *epaddrs, 0, 0, send, len);
      //    fprintf(stderr, "recvd: \n");
    }
    len = len << 1;
  }

  sleep(100000);
  return 1;
}
Пример #7
0
/* imc_mail_startup: start up the mail subsystem */
void imc_mail_startup(void)
{
  init_mq();
  init_ml();
  init_idlist();

  /* order is important here: we need the maillist to resolve the ID refs in
   * the mailqueue
   */

  load_ml();
  load_mq();
  load_idlist();

  /* queue an expiry event */

  imc_add_event(24*3600, ev_mailid_expire, NULL, 0);
}