Example #1
0
void
collector_reset (Collector *collector)
{
    /* Disable the counters so that we won't track
     * the activity of tracker_free()/tracker_new()
     *
     * They will still record fork/mmap/etc. so
     * we can keep an accurate log of process creation
     */
    if (collector->counters)
    {
	d_print ("disable counters\n");
	
	disable_counters (collector);
    }
    
    if (collector->tracker)
    {
	tracker_free (collector->tracker);
	collector->tracker = tracker_new ();
    }

    collector->n_samples = 0;
    collector->prev_samples = 0;
    
    g_get_current_time (&collector->latest_reset);

    if (collector->counters)
    {
	d_print ("enable counters\n");
	
	enable_counters (collector);
    }
}
Example #2
0
File: th.c Project: iamwjlee/My
int task_wait(task_t *task, int ntasks, unsigned long *timeout)
{
	int status;
	task_list_t *list;
	char name[32];
	int threadReturnValue;
	memset(name,0,sizeof(char)*8);
	slink_foreach(list, TaskList)
	{
		//d_print("\t\t\t m[%x] [%x] [%x]",list->name,list->task,*task,task);
		if(list->task==task)
		{
			strcpy(name,list->name);
			//d_print("\t\t\t name=%s",list->name);
			break;
		}
	}	
	
	d_print("\t\t\t remove list=%s",list->name);
	slink_remove(TaskList, list);
	d_print("\t\t\t free list=%s",list->name);
	free(list);

	SDL_WaitThread( task, &threadReturnValue);
	
	if(name)
		d_print("\t\t\t task_wait  [%s][%x] ",name,threadReturnValue);
	return 0;

}
Example #3
0
static snd_mixer_elem_t *find_mixer_elem_by_name(const char *goal_name)
{
	snd_mixer_elem_t *elem;
	snd_mixer_selem_id_t *sid = NULL;

	snd_mixer_selem_id_malloc(&sid);

	for (elem = snd_mixer_first_elem(alsa_mixer_handle); elem;
		 elem = snd_mixer_elem_next(elem)) {

		const char *name;

		snd_mixer_selem_get_id(elem, sid);
		name = snd_mixer_selem_id_get_name(sid);
		d_print("name = %s\n", name);
		d_print("has playback volume = %d\n", snd_mixer_selem_has_playback_volume(elem));
		d_print("has playback switch = %d\n", snd_mixer_selem_has_playback_switch(elem));

		if (strcasecmp(name, goal_name) == 0) {
			if (!snd_mixer_selem_has_playback_volume(elem)) {
				d_print("mixer element `%s' does not have playback volume\n", name);
				elem = NULL;
			}
			break;
		}
	}

	snd_mixer_selem_id_free(sid);
	return elem;
}
Example #4
0
void handleTime(char * gpgga)
{
	char *argv[7];
	uint8_t argc = parseNMEA(gpgga, argv, 7);

	if(argc < 5)
		return;

	argv[0][4] = 0;
	gpsMinute = t_atoi(&argv[0][2]);

	argv[0][2] = 0;
	gpsHour = t_atoi(argv[0]);

	static uint8_t flag = 0;
	if(flag)
		GPIO_ResetBits(GPIOC, GPIO_Pin_9);
	else
		GPIO_SetBits(GPIOC, GPIO_Pin_9);

	flag = !flag;

	d_print(gpsHour);
	t_print(":");
	d_print(gpsMinute);
	t_print("\n");
}
Example #5
0
void player_init(const struct player_callbacks *callbacks)
{
	int rc;
#ifdef REALTIME_SCHEDULING
	pthread_attr_t attr;
#endif
	pthread_attr_t *attrp = NULL;

	/* This mutex is locked inside of the mpris implementation which is
	 * called into from many different places. It is not trivial to see if
	 * those places do already hold this lock and so the mpris functions
	 * always acquires it. To avoid deadlocks in the places where the lock
	 * is already held by the calling context, we use a recursive mutex.
	 */
	cmus_mutex_init_recursive(&player_info.mutex);

	/*  1 s is 176400 B (0.168 MB)
	 * 10 s is 1.68 MB
	 */
	buffer_nr_chunks = 10 * 44100 * 16 / 8 * 2 / CHUNK_SIZE;
	buffer_init();

	player_cbs = callbacks;

#ifdef REALTIME_SCHEDULING
	rc = pthread_attr_init(&attr);
	BUG_ON(rc);
	rc = pthread_attr_setschedpolicy(&attr, SCHED_RR);
	if (rc) {
		d_print("could not set real-time scheduling priority: %s\n", strerror(rc));
	} else {
		struct sched_param param;

		d_print("using real-time scheduling\n");
		param.sched_priority = sched_get_priority_max(SCHED_RR);
		d_print("setting priority to %d\n", param.sched_priority);
		rc = pthread_attr_setschedparam(&attr, &param);
		BUG_ON(rc);
		attrp = &attr;
	}
#endif

	rc = pthread_create(&producer_thread, NULL, producer_loop, NULL);
	BUG_ON(rc);

	rc = pthread_create(&consumer_thread, attrp, consumer_loop, NULL);
	if (rc && attrp) {
		d_print("could not create thread using real-time scheduling: %s\n", strerror(rc));
		rc = pthread_create(&consumer_thread, NULL, consumer_loop, NULL);
	}
	BUG_ON(rc);

	/* update player_info.cont etc. */
	player_lock();
	_player_status_changed();
	player_unlock();
}
Example #6
0
static inline void file_changed(struct track_info *ti)
{
	player_info_lock();
	if (ti) {
		d_print("file: %s\n", ti->filename);
	} else {
		d_print("unloaded\n");
	}
	__file_changed(ti);
	player_info_unlock();
}
Example #7
0
File: jack.c Project: jolange/cmus
static int op_jack_open(sample_format_t sf, const channel_position_t *cm)
{
	sample_format = sf;

	if (fail) {
		/* jack went away so lets see if we can recover */
		if (client != NULL) {
			op_jack_exit();
		}
		if (op_jack_init() != OP_ERROR_SUCCESS) {
			return -OP_ERROR_INTERNAL;
		}
	}

	if (cm == NULL) {
		d_print("no channel_map\n");
		return -OP_ERROR_NOT_SUPPORTED;
	}
	channel_map = cm;

#ifdef HAVE_SAMPLERATE
	op_jack_reset_src();
	resample_ratio = (float) jack_sample_rate / (float) sf_get_rate(sf);
#else
	if (jack_sample_rate != sf_get_rate(sf)) {
		d_print("jack sample rate of %d does not match %d\n", jack_get_sample_rate(client), sf_get_rate(sf));
		return -OP_ERROR_SAMPLE_FORMAT;
	}
#endif

	if (sf_get_channels(sf) < CHANNELS) {
		d_print("%d channels not supported\n", sf_get_channels(sf));
		return -OP_ERROR_SAMPLE_FORMAT;
	}

	int bits = sf_get_bits(sf);

	if (bits == 16) {
		sample_bytes = 2;
		read_sample = sf_get_signed(sf) ? &read_sample_le16 : &read_sample_le16u;
	} else if (bits == 24) {
		sample_bytes = 3;
		read_sample = sf_get_signed(sf) ? &read_sample_le24 : &read_sample_le24u;
	} else if (bits == 32) {
		sample_bytes = 4;
		read_sample = sf_get_signed(sf) ? &read_sample_le32 : &read_sample_le32u;
	} else {
		d_print("%d bits not supported\n", sf_get_bits(sf));
		return -OP_ERROR_SAMPLE_FORMAT;
	}

	paused = false;
	return OP_ERROR_SUCCESS;
}
Example #8
0
static int sun_device_exists(const char *dev)
{
	struct stat s;

	if (stat(dev, &s) == 0) {
		d_print("device %s exists\n", dev);
		return 1;
	}
	d_print("device %s does not exist\n", dev);

	return 0;
}
Example #9
0
static void update_rg_scale(void)
{
	double gain, peak, db, scale, limit;

	replaygain_scale = 1.0;
	if (!player_info.ti || !replaygain)
		return;

	if (replaygain == RG_TRACK || replaygain == RG_TRACK_PREFERRED) {
		gain = player_info.ti->rg_track_gain;
		peak = player_info.ti->rg_track_peak;
	} else {
		gain = player_info.ti->rg_album_gain;
		peak = player_info.ti->rg_album_peak;
	}

	if (isnan(gain)) {
		if (replaygain == RG_TRACK_PREFERRED) {
			gain = player_info.ti->rg_album_gain;
			peak = player_info.ti->rg_album_peak;
		} else if (replaygain == RG_ALBUM_PREFERRED) {
			gain = player_info.ti->rg_track_gain;
			peak = player_info.ti->rg_track_peak;
		}
	}

	if (isnan(gain)) {
		d_print("gain not available\n");
		return;
	}
	if (isnan(peak)) {
		d_print("peak not available, defaulting to 1\n");
		peak = 1;
	}
	if (peak < 0.05) {
		d_print("peak (%g) is too small\n", peak);
		return;
	}

	db = replaygain_preamp + gain;

	scale = pow(10.0, db / 20.0);
	replaygain_scale = scale;
	limit = 1.0 / peak;
	if (replaygain_limit && !isnan(peak)) {
		if (replaygain_scale > limit)
			replaygain_scale = limit;
	}

	d_print("gain = %f, peak = %f, db = %f, scale = %f, limit = %f, replaygain_scale = %f\n",
			gain, peak, db, scale, limit, replaygain_scale);
}
Example #10
0
/*
 * change output plugin without stopping playback
 */
void player_set_op(const char *name)
{
	int rc;

	player_lock();

	/* drop needed because close drains the buffer */
	if (consumer_status == CS_PAUSED)
		op_drop();

	if (consumer_status == CS_PLAYING || consumer_status == CS_PAUSED)
		op_close();

	if (name) {
		d_print("setting op to '%s'\n", name);
		rc = op_select(name);
	} else {
		/* first initialized plugin */
		d_print("selecting first initialized op\n");
		rc = op_select_any();
	}
	if (rc) {
		__consumer_status_update(CS_STOPPED);

		__producer_stop();
		if (name)
			player_op_error(rc, "selecting output plugin '%s'", name);
		else
			player_op_error(rc, "selecting any output plugin");
		player_unlock();
		return;
	}

	if (consumer_status == CS_PLAYING || consumer_status == CS_PAUSED) {
		set_buffer_sf();
		rc = op_open(buffer_sf, buffer_channel_map);
		if (rc) {
			__consumer_status_update(CS_STOPPED);
			__producer_stop();
			player_op_error(rc, "opening audio device");
			player_unlock();
			return;
		}
		if (consumer_status == CS_PAUSED)
			op_pause();
	}

	player_unlock();
}
Example #11
0
void player_init(const struct player_callbacks *callbacks)
{
	int rc;
#ifdef REALTIME_SCHEDULING
	pthread_attr_t attr;
#endif
	pthread_attr_t *attrp = NULL;

	/*  1 s is 176400 B (0.168 MB)
	 * 10 s is 1.68 MB
	 */
	buffer_nr_chunks = 10 * 44100 * 16 / 8 * 2 / CHUNK_SIZE;
	buffer_init();

	player_cbs = callbacks;

#ifdef REALTIME_SCHEDULING
	rc = pthread_attr_init(&attr);
	BUG_ON(rc);
	rc = pthread_attr_setschedpolicy(&attr, SCHED_RR);
	if (rc) {
		d_print("could not set real-time scheduling priority: %s\n", strerror(rc));
	} else {
		struct sched_param param;

		d_print("using real-time scheduling\n");
		param.sched_priority = sched_get_priority_max(SCHED_RR);
		d_print("setting priority to %d\n", param.sched_priority);
		rc = pthread_attr_setschedparam(&attr, &param);
		BUG_ON(rc);
		attrp = &attr;
	}
#endif

	rc = pthread_create(&producer_thread, NULL, producer_loop, NULL);
	BUG_ON(rc);

	rc = pthread_create(&consumer_thread, attrp, consumer_loop, NULL);
	if (rc && attrp) {
		d_print("could not create thread using real-time scheduling: %s\n", strerror(rc));
		rc = pthread_create(&consumer_thread, NULL, consumer_loop, NULL);
	}
	BUG_ON(rc);

	/* update player_info.cont etc. */
	player_lock();
	__player_status_changed();
	player_unlock();
}
Example #12
0
File: jack.c Project: BG2BKK/cmus
static int op_jack_set_option(int key, const char *val)
{
	switch (key) {
	case CFG_SERVER_NAME:
		free(server_name);
		server_name = val[0] != '\0' ? xstrdup(val) : NULL;
		break;
#ifdef HAVE_SAMPLERATE
	case CFG_RESAMPLING_QUALITY:
		if (strlen(val) != 1) {
			return -OP_ERROR_NOT_SUPPORTED;
		}
		switch (val[0]) {
		default:
		case '2':
			src_quality = SRC_SINC_BEST_QUALITY;
			break;
		case '1':
			src_quality = SRC_SINC_MEDIUM_QUALITY;
			break;
		case '0':
			src_quality = SRC_SINC_FASTEST;
			break;
		}
		break;
#endif
	default:
		d_print("unknown key %d = %s\n", key, val);
		return -OP_ERROR_NOT_OPTION;
	}
	return OP_ERROR_SUCCESS;
}
Example #13
0
File: cmus.c Project: Aseeker/cmus
void cmus_exit(void)
{
	worker_remove_jobs(JOB_TYPE_ANY);
	worker_exit();
	if (cache_close())
		d_print("error: %s\n", strerror(errno));
}
Example #14
0
int network_set_neuron_number(network *nn, unsigned long nr)
{
  int i;

  if (!nn || !nr)
	return -1;

  if (nr == nn->num_of_neurons) /* do nothing... */
	return 0;

  if (nn->neurons)
    	/* free the previous array if any */
	free(nn->neurons);

  nn->neurons = (neuron *)malloc(sizeof(neuron) * nr);
  if (!nn->neurons) {
	printf("No memory available to allocate the neurons array!\n");
	exit(-1);
  }

  memset(nn->neurons, 0, sizeof(neuron) * nr);
  nn->num_of_neurons = nr;

  for (i = 0; i < nr; ++i) {
	nn->neurons[i].global_id = i; /* set the global is once */
	nn->neurons[i].output = 0.0;
  }

  d_print("neurons array allocated: size for %d elements\n", nr);

  return 0;
}
Example #15
0
static void
process_exit (Collector *collector, exit_event_t *exit)
{
    d_print ("for %d %d", exit->pid, exit->tid);
    
    tracker_add_exit (collector->tracker, exit->pid);
}
Example #16
0
static void
counter_disable (counter_t *counter)
{
    d_print ("disable\n");
    
    ioctl (counter->fd, PERF_EVENT_IOC_DISABLE);
}
Example #17
0
static inline int d_factorial(int f_max)
{
    double factorial = 1.0;
    double old_value = factorial;
    int i;
    for (i = 1; i < 200; i++)
    {
        old_value = factorial;
        factorial *= i;
        if (!isfinite(factorial))
            break;
        if (i <= 12 || (i == f_max + 1 || i == f_max))
            d_print(i, factorial);
    }
    d_print(i - 1, old_value);
    return i - 1;
}
Example #18
0
static void
process_fork (Collector *collector, fork_event_t *fork)
{
    d_print ("ppid: %d  pid: %d   ptid: %d  tid %d\n",
	     fork->ppid, fork->pid, fork->ptid, fork->tid);
    
    tracker_add_fork (collector->tracker, fork->ppid, fork->pid);
}
Example #19
0
static int alsa_mixer_set_volume(int l, int r)
{
	if (mixer_elem == NULL) {
		return -1;
	}
	l += mixer_vol_min;
	r += mixer_vol_min;
	if (l > mixer_vol_max)
		d_print("error: left volume too high (%d > %ld)\n",
				l, mixer_vol_max);
	if (r > mixer_vol_max)
		d_print("error: right volume too high (%d > %ld)\n",
				r, mixer_vol_max);
	snd_mixer_selem_set_playback_volume(mixer_elem, SND_MIXER_SCHN_FRONT_LEFT, l);
	snd_mixer_selem_set_playback_volume(mixer_elem, SND_MIXER_SCHN_FRONT_RIGHT, r);
	return 0;
}
Example #20
0
File: jack.c Project: BG2BKK/cmus
/* init or resize buffers if needed */
static int op_jack_buffer_init(jack_nframes_t samples, void *arg)
{
	if (buffer_size > samples * BUFFER_MULTIPLYER) {
		/* we just don't shrink buffers, since this could result
		 * in gaps and they won't get that big anyway
		 */
		return 0;
	}

	buffer_size = samples * BUFFER_MULTIPLYER;
	if (buffer_size < BUFFER_SIZE_MIN) {
		buffer_size = BUFFER_SIZE_MIN;
	}
	d_print("new buffer size %zu\n", buffer_size);

	char *tmp = xmalloc(buffer_size);

	for (int i = 0; i < CHANNELS; i++) {
		jack_ringbuffer_t *new_buffer = jack_ringbuffer_create(buffer_size);

		if (!new_buffer) {
			d_print("ringbuffer alloc failed\n");
			free(tmp);
			fail = 1;
			op_jack_exit();
			return 1;
		}
		if (ringbuffer[i] != NULL) {
			size_t length = jack_ringbuffer_read_space(ringbuffer[i]);

			/* actualy this could both read/write less than length.
			 * In that case, which should not happen[TM], there will
			 * be a gap in playback.
			 */
			jack_ringbuffer_read(ringbuffer[i], tmp, length);
			jack_ringbuffer_write(new_buffer, tmp, length);

			jack_ringbuffer_free(ringbuffer[i]);
		}

		ringbuffer[i] = new_buffer;
	}

	free(tmp);
	return 0;
}
Example #21
0
static void
process_comm (Collector *collector, comm_event_t *comm)
{
    d_print ("pid, tid: %d %d", comm->pid, comm->tid);
    
    tracker_add_process (collector->tracker,
			 comm->pid,
			 comm->comm);
}
Example #22
0
static int alsa_mixer_open(int *volume_max)
{
	snd_mixer_elem_t *elem;
	int count;
	int rc;

	rc = snd_mixer_open(&alsa_mixer_handle, 0);
	if (rc < 0)
		goto error;
	rc = snd_mixer_attach(alsa_mixer_handle, alsa_mixer_device);
	if (rc < 0)
		goto error;
	rc = snd_mixer_selem_register(alsa_mixer_handle, NULL, NULL);
	if (rc < 0)
		goto error;
	rc = snd_mixer_load(alsa_mixer_handle);
	if (rc < 0)
		goto error;
	count = snd_mixer_get_count(alsa_mixer_handle);
	if (count == 0) {
		d_print("error: mixer does not have elements\n");
		return -2;
	}

	elem = find_mixer_elem_by_name(alsa_mixer_element);
	if (!elem) {
		d_print("mixer element `%s' not found, trying `Master'\n", alsa_mixer_element);
		elem = find_mixer_elem_by_name("Master");
		if (!elem) {
			d_print("error: cannot find suitable mixer element\n");
			return -2;
		}
	}
	snd_mixer_selem_get_playback_volume_range(elem, &mixer_vol_min, &mixer_vol_max);
	/* FIXME: get number of channels */
	mixer_elem = elem;
	*volume_max = mixer_vol_max - mixer_vol_min;

	return 0;

error:
	d_print("error: %s\n", snd_strerror(rc));
	return -1;
}
Example #23
0
static int alsa_mixer_open(int *volume_max)
{
	snd_mixer_selem_id_t *sid;
	snd_mixer_elem_t *elem;
	int count;
	int rc;

	snd_mixer_selem_id_alloca(&sid);

	rc = snd_mixer_open(&alsa_mixer_handle, 0);
	if (rc < 0)
		goto error;
	rc = snd_mixer_attach(alsa_mixer_handle, alsa_mixer_device);
	if (rc < 0)
		goto error;
	rc = snd_mixer_selem_register(alsa_mixer_handle, NULL, NULL);
	if (rc < 0)
		goto error;
	rc = snd_mixer_load(alsa_mixer_handle);
	if (rc < 0)
		goto error;
	count = snd_mixer_get_count(alsa_mixer_handle);
	if (count == 0) {
		d_print("error: mixer does not have elements\n");
		return -2;
	}
	elem = snd_mixer_first_elem(alsa_mixer_handle);
	while (elem) {
		const char *name;
		int has_vol, has_switch;

		snd_mixer_selem_get_id(elem, sid);
		name = snd_mixer_selem_id_get_name(sid);
		d_print("name = %s\n", name);
		d_print("has playback volume = %d\n", snd_mixer_selem_has_playback_volume(elem));
		d_print("has playback switch = %d\n", snd_mixer_selem_has_playback_switch(elem));
		if (strcasecmp(name, alsa_mixer_element)) {
			elem = snd_mixer_elem_next(elem);
			continue;
		}
		has_vol = snd_mixer_selem_has_playback_volume(elem);
		if (!has_vol) {
			d_print("mixer element `%s' does not have playback volume\n", name);
			return -2;
		}
		snd_mixer_selem_get_playback_volume_range(elem,
				&mixer_vol_min, &mixer_vol_max);
		has_switch = snd_mixer_selem_has_playback_switch(elem);
		/* FIXME: get number of channels */
		mixer_elem = elem;
		*volume_max = mixer_vol_max - mixer_vol_min;
		return 0;
	}
	d_print("error: mixer element `%s' not found\n", alsa_mixer_element);
	return -2;
error:
	d_print("error: %s\n", snd_strerror(rc));
	return -1;
}
Example #24
0
File: roar.c Project: Brijen/cmus
static ssize_t op_roar_debug_write(struct roar_vio_calls *vio, void *buf_, size_t count)
{
    char *buf = (char *) buf_;
    int len = count;
    if (len > 0 && buf[len-1] == '\n')
        len--;
    if (len > 0)
        d_print("%*s\n", len, buf);
    return count;
}
Example #25
0
void weed_layer_set_from_yuv4m(weed_plant_t *layer, lives_clip_t *sfile) {
  lives_yuv4m_t *yuv4mpeg=(lives_yuv4m_t *)(sfile->ext_src);

  y4data thread_data;

  int error;

  pthread_t y4thread;

  int alarm_handle;

  if (!yuv4mpeg->ready) lives_yuv_stream_start_read(sfile);

  weed_set_int_value(layer,"width",sfile->hsize);
  weed_set_int_value(layer,"height",sfile->vsize);
  weed_set_int_value(layer,"current_palette",WEED_PALETTE_YUV420P);
  weed_set_int_value(layer,"YUV_subspace",WEED_YUV_SUBSPACE_YCBCR);

  create_empty_pixel_data(layer,TRUE,TRUE);

  if (!yuv4mpeg->ready) {
    return;
  }

  yuv4mpeg->pixel_data=weed_get_voidptr_array(layer,"pixel_data",&error);

  // create a thread to open the stream header

  thread_data.yuv4mpeg=yuv4mpeg;
  pthread_create(&y4thread,NULL,y4frame_thread,&thread_data);

  alarm_handle=lives_alarm_set(YUV4_F_TIME);

  while (!lives_alarm_get(alarm_handle)&&!pthread_kill(y4thread,0)) {
    // wait for thread to complete or timeout
    lives_usleep(prefs->sleep_time);
  }

  if (lives_alarm_get(alarm_handle)) {
    // timeout - kill thread and wait for it to terminate
    // timeout - kill thread and wait for it to terminate
    pthread_cancel(y4thread);
    d_print(_("Unable to read the incoming video frame\n"));
  }

  pthread_join(y4thread,NULL);
  lives_alarm_clear(alarm_handle);

  lives_free(yuv4mpeg->pixel_data);
  yuv4mpeg->pixel_data=NULL;

  weed_set_int_value(layer,"YUV_sampling",WEED_YUV_SAMPLING_MPEG);

  return;
}
Example #26
0
int test_fatfs(void)
{
    int ret;
    uint8_t buf[1024];

    memset(buf, 0, 1024);

    ret = fatfs_mount(&fs);
    if (ret != 0) {
        bl_dbg("Failed mounting flash device.");
    }

    ret = fatfs_open(&fs, "CONFIG.INI");
    if (ret) {
        bl_dbg("Failed opening config file.");
    }
    ret = fatfs_read(&fs, buf, 1024);
    if (ret < 0) {
        bl_dbg("Failed reading data.");
    }
    buf[ret] = '\0';
    d_print("%s\r\n", buf);

    fatfs_close(&fs);

    fatfs_umount(&fs);

    bl_dbg("Done");
#if 0
    int k;
    for (i = 44; i < 8192; i++) {
        at45db_bread(i, 1, buf);
        for (k = 0; k < 1024; k++) {
            d_print("%c", buf[k]);
            wait(25);
        }
        d_print("Page: %d\r\n", i);
        wait(5000);
    }
#endif
    return 0;
}
Example #27
0
File: th.c Project: iamwjlee/My
void th_test0()
{
	my_thread=malloc(sizeof(my_first_t));
	my_thread->g_on=1;
	my_thread->task = SDL_CreateThread( TestThread,  (void *)my_thread);
	SDL_Delay(2000);
	my_thread->g_on=0;
	SDL_WaitThread( my_thread->task, NULL);
	d_print("\nMy First thread_test0 end");
	
}
Example #28
0
File: arts.c Project: jolange/cmus
static int op_arts_write(const char *buffer, int count)
{
	int rc;

	rc = arts_write(arts_stream, buffer, count);
	if (rc < 0) {
		d_print("rc = %d, count = %d\n", rc, count);
		return -1;
	}
	return rc;
}
Example #29
0
File: th.c Project: iamwjlee/My
int TestThread( void *data )
{
		my_first_t *my=(my_first_t *)data;
        my->cnt=10;
		while(my->g_on)
        {
                d_print( "\nThread counter: %d", my->cnt++);
                SDL_Delay(20);
        }
		
        return 0;
}
Example #30
0
File: th.c Project: iamwjlee/My
int  counting(void *data)
{
	int i=0;
	mycounting_t *p=(mycounting_t *)data;
	while(p->running)
	{
		 d_print("%s[0x%x] : %d [%d]",p->name,(unsigned int )p,p->counting,p->running);
		p->counting++;
		SDL_Delay(500);
	}
	return 0;
}