示例#1
0
void k8s_net::stop_watching()
{
	if(!m_stopped)
	{
		m_stopped = true;
		unsubscribe();
		end_thread();
	}
}
示例#2
0
文件: server.c 项目: Nakrez/multi
/* FIXME doc */
static void *compile_file(void *state)
{
    thread_state_t *thread_state = (thread_state_t *)state;

    process_file_t *file = NULL;

    /* Set a timeout on the socket */
    if (set_timeout(thread_state->cli_fd) < 0)
        goto exit_thread;

    file = process_file_new();

    if (recv_argv(thread_state->cli_fd,
                  &thread_state->argc, &thread_state->argv) < 0)
        goto exit_thread;

    if (recv_file(thread_state->cli_fd, file->input_name) < 0)
        goto exit_thread;

    update_argv_file(thread_state->argc,
                     thread_state->argv,
                     file->input_name,
                     file->output_name);

    /* TODO : put it somewhere else */
    for (int i = 0; i < thread_state->argc; ++i)
        printf("%s ", thread_state->argv[i]);
    printf("\n");
    /* END TODO */

    file->result = compile_without_preprocess(thread_state->argc,
                                              thread_state->argv);
    if (!file->result)
        goto exit_thread;

    if (send_compile_result(thread_state->cli_fd, file->result) == -1)
    {
        printf("[multi deamon] Can not send compile result\n");
        goto exit_thread;
    }

    if (!file->result->status)
    {
        if (send_file(thread_state->cli_fd, file->output_name) < 0)
        {
            printf("[multi deamon] Can not send compiled file\n");
            goto exit_thread;
        }
    }

exit_thread:
    if (file)
        process_file_free(&file);

    return end_thread(&thread_state);
}
示例#3
0
input_source::~input_source() {
  end_thread();
  close(internalpipe);
  close(priv_pipe);
  close(epfd);
  for (int i = 0; i < ev_map.size(); i++) {
    if (ev_map[i].trans) delete ev_map[i].trans;
  }



  for (auto it : adv_trans) {
    if (it.second.trans) delete it.second.trans;
    if (it.second.fields) delete it.second.fields;
  }

  if (assigned_slot) {
    assigned_slot->remove_device(this);
    assigned_slot = nullptr;
  };
  if (plugin.destroy)
    plugin.destroy(plug_data);
}
示例#4
0
static void *
DecodeThread(void *a)
{
    ape_tag tag;
    char *filename = (char *) a;
    int bps_updateCounter = 0;
    int bps;
    int i;
    WavpackDecoder d(&mod);

    if (!d.attach(filename)) {
        printf("wavpack: Error opening file: \"%s\"\n", filename);
        killDecodeThread = true;
        return end_thread();
    }
    bps = WavpackGetBytesPerSample(d.ctx) * d.num_channels;
    DBG("reading %s at %d rate with %d channels\n", filename, d.sample_rate, d.num_channels);

    if (!d.open_audio()) {
        DBG("error opening xmms audio channel\n");
        killDecodeThread = true;
        AudioError = true;
        openedAudio = false;
    }
    else {
        DBG("opened xmms audio channel\n");
        openedAudio = true;
    }
    unsigned status;
    char *display = generate_title(filename, d.ctx);
    int length = (int) (1000 * WavpackGetNumSamples(d.ctx));

    while (!killDecodeThread) {
        if (isSeek != -1) {
            DBG("seeking to position %d\n", isSeek);
            WavpackSeekSample(d.ctx, isSeek * d.sample_rate);
            isSeek = -1;
        }
        if (paused == 0
                && (mod.output->buffer_free() >=
                    (1152 * 2 *
                     (16 / 8)) << (mod.output->buffer_playing()? 1 : 0))) {
            status =
                WavpackUnpackSamples(d.ctx, d.input, BUFFER_SIZE);
            if (status == (unsigned) (-1)) {
                printf("wavpack: Error decoding file.\n");
                break;
            }
            else if (status == 0) {
                killDecodeThread = true;
                break;
            }
            else {
                d.process_buffer(status);
            }
        }
        else {
            xmms_usleep(10000);
        }
    }
    return end_thread();
}
示例#5
0
k8s_net::~k8s_net()
{
	end_thread();
	cleanup();
}