コード例 #1
0
ファイル: gates.cpp プロジェクト: Patrick6289/navguide
void gate_clear_neighbors (gate_t *g)
{
    for (GList *iter=g_queue_peek_head_link (g->features);iter;iter=iter->next) {
        navlcm_feature_list_t *f = (navlcm_feature_list_t*)iter->data;
        navlcm_feature_list_t_destroy (f);
    }
    g_queue_free (g->features);
    g_queue_free (g->neighbors);
    
    g->neighbors = NULL;
    g->features = NULL;
    
}
コード例 #2
0
ファイル: parallel.c プロジェクト: msteinert/joybubbles
static void
dispose(GObject *base)
{
	struct Private *priv = GET_PRIVATE(base);
	if (priv->children) {
		for (GList *node = g_queue_peek_head_link(priv->children);
				node; node = node->next) {
			g_object_unref(node->data);
		}
		g_queue_free(priv->children);
		priv->children = NULL;
	}
	G_OBJECT_CLASS(joy_animation_parallel_parent_class)->dispose(base);
}
コード例 #3
0
ファイル: curl_input_plugin.c プロジェクト: raumzeitlabor/mpd
/**
 * Determine the total sizes of all buffers, including portions that
 * have already been consumed.
 */
G_GNUC_PURE
static size_t
curl_total_buffer_size(const struct input_curl *c)
{
	size_t total = 0;

	for (GList *i = g_queue_peek_head_link(c->buffers);
	     i != NULL; i = g_list_next(i)) {
		struct buffer *buffer = i->data;
		total += buffer->size;
	}

	return total;
}
コード例 #4
0
static void
format_cert_infos (GQueue *cert_infos,
                   GString *output_buffer)
{
	GQueue valid = G_QUEUE_INIT;
	GList *head, *link;

	head = g_queue_peek_head_link (cert_infos);

	/* Make sure we have a valid CamelCipherCertInfo before
	 * appending anything to the output buffer, so we don't
	 * end up with "()". */
	for (link = head; link != NULL; link = g_list_next (link)) {
		CamelCipherCertInfo *cinfo = link->data;

		if ((cinfo->name != NULL && *cinfo->name != '\0') ||
		    (cinfo->email != NULL && *cinfo->email != '\0')) {
			g_queue_push_tail (&valid, cinfo);
		}
	}

	if (g_queue_is_empty (&valid))
		return;

	g_string_append (output_buffer, " (");

	while (!g_queue_is_empty (&valid)) {
		CamelCipherCertInfo *cinfo;

		cinfo = g_queue_pop_head (&valid);

		if (cinfo->name != NULL && *cinfo->name != '\0') {
			g_string_append (output_buffer, cinfo->name);

			if (cinfo->email != NULL && *cinfo->email != '\0') {
				g_string_append (output_buffer, " <");
				g_string_append (output_buffer, cinfo->email);
				g_string_append (output_buffer, ">");
			}

		} else if (cinfo->email != NULL && *cinfo->email != '\0') {
			g_string_append (output_buffer, cinfo->email);
		}

		if (!g_queue_is_empty (&valid))
			g_string_append (output_buffer, ", ");
	}

	g_string_append_c (output_buffer, ')');
}
コード例 #5
0
ファイル: screen.c プロジェクト: msteinert/joybubbles
JOY_GNUC_HOT
static void
submit(JoyScreen *self)
{
	struct Private *priv = GET_PRIVATE(self);
	// update cursor
	if (priv->cursor && priv->moved) {
		GFX3D_Cursor_Position_Set(priv->cursor,
				priv->x - priv->x_hot,
				priv->y - priv->y_hot);
	}
	// clear exposed areas of the frame buffer
	cairo_region_intersect(priv->expose, priv->area);
	for (gint i = 0; i < cairo_region_num_rectangles(priv->expose); ++i) {
		cairo_rectangle_int_t rect;
		cairo_region_get_rectangle(priv->expose, i, &rect);
		GFX3D_Display_ClearAlpha2D(priv->display, NULL,
				(gpointer)&rect, 0., 0., 0., 0.);
		g_array_append_val(priv->rects, rect);
	}
	if (priv->rects->len) {
		cairo_region_subtract(priv->expose, priv->expose);
#if !CAIRO_HAS_GFX3D_SURFACE
		GFX3D_Display_Cache_Flush(priv->display);
#endif // !CAIRO_HAS_GFX3D_SURFACE
		GFX3D_NATIVE_Display display =
			GFX3D_Display_Get_NATIVE_Display(priv->display);
		GFX3D_NATIVE_Surface surface =
			GFX3D_Display_FrameBuffer_Get_NATIVE_Surface(
					priv->display);
		// copy windows to the frame buffer
		for (GList *node = g_queue_peek_head_link(priv->windows);
				node; node = node->next) {
			JoyBubble *window = node->data;
			joy_gfx3d_window_submit(window, display, surface,
					priv->area);
		}
		// flip the display
		GFX3D_Display_Show_Partial(priv->display,
				(gpointer)priv->rects->data,
				priv->rects->len, 1);
		g_array_set_size(priv->rects, 0);
	} else {
		if (priv->moved && priv->cursor) {
			GFX3D_Display_Show_Ch_Reload(priv->cursor);
		}
	}
	priv->moved = FALSE;
}
コード例 #6
0
ファイル: gates.cpp プロジェクト: Patrick6289/navguide
void gates_assign_linear_neighbors (GQueue *gates)
{
    for (GList *iter=g_queue_peek_head_link(gates);iter;iter=g_list_next(iter)) {
        gate_t *g = (gate_t*)iter->data;
        gate_t *pg = NULL, *ng = NULL;
        if (iter->prev)
            pg = (gate_t*)iter->prev->data;
        if (iter->next)
            ng = (gate_t*)iter->next->data;
        if (pg)
            gate_insert_neighbor (g, pg->uid);
        if (ng)
            gate_insert_neighbor (g, ng->uid);
    }
}
コード例 #7
0
ファイル: rtpjitterbuffer.c プロジェクト: adesurya/gst-mobile
static guint64
get_buffer_level (RTPJitterBuffer * jbuf)
{
  GstBuffer *high_buf = NULL, *low_buf = NULL;
  guint64 level;
  GList *find;

  /* first first buffer with timestamp */
  find = g_queue_peek_head_link (jbuf->packets);
  while (find) {
    high_buf = find->data;
    if (GST_BUFFER_TIMESTAMP (high_buf) != -1)
      break;

    high_buf = NULL;
    find = g_list_next (find);
  }

  find = g_queue_peek_tail_link (jbuf->packets);
  while (find) {
    low_buf = find->data;
    if (GST_BUFFER_TIMESTAMP (low_buf) != -1)
      break;

    low_buf = NULL;
    find = g_list_previous (find);
  }

  if (!high_buf || !low_buf || high_buf == low_buf) {
    level = 0;
  } else {
    guint64 high_ts, low_ts;

    high_ts = GST_BUFFER_TIMESTAMP (high_buf);
    low_ts = GST_BUFFER_TIMESTAMP (low_buf);

    if (high_ts > low_ts)
      level = high_ts - low_ts;
    else
      level = 0;

    GST_LOG_OBJECT (jbuf,
        "low %" GST_TIME_FORMAT " high %" GST_TIME_FORMAT " level %"
        G_GUINT64_FORMAT, GST_TIME_ARGS (low_ts), GST_TIME_ARGS (high_ts),
        level);
  }
  return level;
}
コード例 #8
0
ファイル: state.cpp プロジェクト: Patrick6289/navguide
void state_init (dijk_graph_t *dg, dijk_node_t *n)
{
    assert (n);

    for (GList *iter=g_queue_peek_head_link (dg->nodes);iter;iter=iter->next) {
        dijk_node_t *p = (dijk_node_t*)iter->data;
        if (p == n) {
            p->pdf0 = 1.0;
            p->pdf1 = 1.0;
        }
        else {
            p->pdf0 = .0;
            p->pdf1 = .0;
        }
    }
}
コード例 #9
0
ファイル: audio.c プロジェクト: lunixbochs/fs-uae-gles
int fs_emu_check_audio_buffer_done(int stream, int buffer) {
    unqueue_old_buffers(stream);
    audio_stream *s = g_streams[stream];
    // not extremely efficient
    g_mutex_lock(s->mutex);
    GList *link = g_queue_peek_head_link(s->queue);
    while (link) {
        if ((unsigned int) buffer == GPOINTER_TO_UINT(link->data)) {
            g_mutex_unlock(s->mutex);
            return 1;
        }
        link = link->next;
    }
    g_mutex_unlock(s->mutex);
    return 0;
}
コード例 #10
0
ファイル: dunst.c プロジェクト: buglloc/dunst
static int get_sleep_time(void)
{

    if (settings.show_age_threshold == 0) {
        /* we need to update every second */
        return 1;
    }

    bool have_ttl = false;
    int min_ttl = 0;
    int max_age = 0;
    for (GList *iter = g_queue_peek_head_link(displayed); iter;
            iter = iter->next) {
        notification *n = iter->data;

        max_age = MAX(max_age, notification_get_age(n));
        int ttl = notification_get_ttl(n);
        if (ttl >= 0) {
            if (have_ttl) {
                min_ttl = MIN(min_ttl, ttl);
            } else {
                min_ttl = ttl;
                have_ttl = true;
            }
        }
    }

    int min_timeout;
    int show_age_timeout = settings.show_age_threshold - max_age;

    if (show_age_timeout < 1) {
        return 1;
    }

    if (!have_ttl) {
        min_timeout = show_age_timeout;
    } else {
        min_timeout = MIN(show_age_timeout, min_ttl);
    }

    /* show_age_timeout might be negative */
    if (min_timeout < 1) {
        return 1;
    } else {
        return min_timeout;
    }
}
コード例 #11
0
ファイル: state.cpp プロジェクト: Patrick6289/navguide
/* print out the state
*/
void state_print (dijk_graph_t *dg, dijk_node_t *cg)
{
    dbg (DBG_CLASS, "*************************************************");
    double sum_pdf1 = .0, sum_pdf0 = .0;

    for (GList *iter=g_queue_peek_head_link (dg->nodes);iter;iter=iter->next) {
        dijk_node_t *nd = (dijk_node_t*)iter->data;
        if (cg && nd == cg) {
            dbg (DBG_CLASS, "gate [%d]: %.4f\t%.4f (***)", nd->uid, nd->pdf0, nd->pdf1);
        } else {
            dbg (DBG_CLASS, "gate [%d]: %.4f\t%.4f", nd->uid, nd->pdf0, nd->pdf1);
        }
        sum_pdf1 += nd->pdf1;
        sum_pdf0 += nd->pdf0;
    }
    dbg (DBG_CLASS, "sum pdf0 = %.4f  sum pdf1 = %.4f", sum_pdf0, sum_pdf1);
}
コード例 #12
0
ファイル: mail-vfolder.c プロジェクト: jdapena/evolution
static GList *
mv_find_folder (GQueue *queue,
                EMailSession *session,
                const gchar *uri)
{
	CamelSession *camel_session = CAMEL_SESSION (session);
	GList *head, *link;

	head = g_queue_peek_head_link (queue);

	for (link = head; link != NULL; link = g_list_next (link)) {
		if (e_mail_folder_uri_equal (camel_session, link->data, uri))
			break;
	}

	return link;
}
コード例 #13
0
ファイル: GQueueTest.cpp プロジェクト: FabianHahn/fakeglib
TEST_F(GQueueTest, peekLink)
{
	int testData1 = 42;
	int testData2 = 1337;

	g_queue_push_tail(queue, &testData1);
	g_queue_push_tail(queue, &testData2);

	GList *link = g_queue_peek_head_link(queue);
	ASSERT_EQ(queue->head, link) << "peeking at the head of the queue should produce expected element";
	link = g_queue_peek_tail_link(queue);
	ASSERT_EQ(queue->tail, link) << "peeking at the tail of the queue should produce expected element";
	link = g_queue_peek_nth_link(queue, 0);
	ASSERT_EQ(queue->head, link) << "peeking at the first element of the queue should produce expected element";
	link = g_queue_peek_nth_link(queue, 1);
	ASSERT_EQ(queue->tail, link) << "peeking at the second element of the queue should produce expected element";
}
コード例 #14
0
ファイル: python-shell.c プロジェクト: 21347/gtkparasite
static const char *
parasite_python_shell_get_history_back(GtkWidget *python_shell)
{
    ParasitePythonShellPrivate *priv = PARASITE_PYTHON_SHELL(python_shell)->priv;

    if (priv->cur_history_item == NULL)
    {
        priv->cur_history_item = g_queue_peek_head_link(priv->history);

        if (priv->cur_history_item == NULL)
            return "";
    }
    else if (priv->cur_history_item->next != NULL)
        priv->cur_history_item = priv->cur_history_item->next;

    return (const char *)priv->cur_history_item->data;
}
コード例 #15
0
static void
store_tile (ChamplainTileCache *tile_cache,
    ChamplainTile *tile,
    const gchar *contents,
    gsize size)
{
  g_return_if_fail (CHAMPLAIN_IS_MEMORY_CACHE (tile_cache));

  ChamplainMapSource *map_source = CHAMPLAIN_MAP_SOURCE (tile_cache);
  ChamplainMapSource *next_source = champlain_map_source_get_next_source (map_source);
  ChamplainMemoryCache *memory_cache = CHAMPLAIN_MEMORY_CACHE (tile_cache);
  ChamplainMemoryCachePrivate *priv = memory_cache->priv;
  GList *link;
  gchar *key;

  key = generate_queue_key (memory_cache, tile);
  link = g_hash_table_lookup (priv->hash_table, key);
  if (link)
    {
      move_queue_member_to_head (priv->queue, link);
      g_free (key);
    }
  else
    {
      QueueMember *member;

      if (priv->queue->length >= priv->size_limit)
        {
          member = g_queue_pop_tail (priv->queue);
          g_hash_table_remove (priv->hash_table, member->key);
          delete_queue_member (member, NULL);
        }

      member = g_slice_new (QueueMember);
      member->key = key;
      member->data = g_memdup (contents, size);
      member->size = size;

      g_queue_push_head (priv->queue, member);
      g_hash_table_insert (priv->hash_table, g_strdup (key), g_queue_peek_head_link (priv->queue));
    }

  if (CHAMPLAIN_IS_TILE_CACHE (next_source))
    champlain_tile_cache_store_tile (CHAMPLAIN_TILE_CACHE (next_source), tile, contents, size);
}
コード例 #16
0
EXPORT_C
#endif

gboolean
gst_data_queue_drop_head (GstDataQueue * queue, GType type)
{
  gboolean res = FALSE;
  GList *item;
  GstDataQueueItem *leak = NULL;

  g_return_val_if_fail (GST_IS_DATA_QUEUE (queue), FALSE);

  GST_DEBUG ("queue:%p", queue);

  GST_DATA_QUEUE_MUTEX_LOCK (queue);
  for (item = g_queue_peek_head_link (queue->queue); item; item = item->next) {
    GstDataQueueItem *tmp = (GstDataQueueItem *) item->data;

    if (G_TYPE_CHECK_INSTANCE_TYPE (tmp->object, type)) {
      leak = tmp;
      break;
    }
  }

  if (!leak)
    goto done;

  g_queue_delete_link (queue->queue, item);

  if (leak->visible)
    queue->cur_level.visible--;
  queue->cur_level.bytes -= leak->size;
  queue->cur_level.time -= leak->duration;

  leak->destroy (leak);

  res = TRUE;

done:
  GST_DATA_QUEUE_MUTEX_UNLOCK (queue);

  GST_DEBUG ("queue:%p , res:%d", queue, res);

  return res;
}
コード例 #17
0
ファイル: main.c プロジェクト: jmenashe/diff-ext
static GList*
get_folder_actions(ThunarxMenuProvider* provider, GtkWidget* window, ThunarxFileInfo* folder) {
  GList* actions = 0;
  gchar* scheme;

  scheme = thunarx_file_info_get_uri_scheme(folder);
  if(strncmp(scheme, "file", 4) == 0) {
    GList* files = g_list_append(0, folder);
    GtkAction* action = gtk_action_new("xdiff-ext::save", _("Compare later"), _("Select file for comparison"), "diff_later");
    g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(compare_later), window);
    g_object_set_data_full(G_OBJECT(action), "xdiff-ext::save", thunarx_file_info_list_copy(files), (GDestroyNotify)thunarx_file_info_list_free);
    actions = g_list_append(actions, action);
    
    if(!g_queue_is_empty(_saved)) {
      GString* caption = g_string_new("");
      GString* hint = g_string_new("");
      GList* head = g_queue_peek_head_link(_saved);
      gchar* head_file = (gchar*)head->data;
      gchar* uri;
      gchar* path;

      uri = thunarx_file_info_get_uri((ThunarxFileInfo*)files->data);
      path = g_filename_from_uri(uri, NULL, NULL);
      g_free(uri);
      
      g_string_printf(caption, _("Compare to '%s'"), head_file);
      g_string_printf(hint, _("Compare '%s' and '%s'"), path, head_file);
      
      action = gtk_action_new("xdiff-ext::compare_to", caption->str, hint->str, "diff_with");
      g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(compare_to), window);
      g_object_set_data_full(G_OBJECT(action), "xdiff-ext::compare_to", thunarx_file_info_list_copy(files), (GDestroyNotify)thunarx_file_info_list_free);
      g_object_set_data(G_OBJECT(action), "xdiff-ext::saved", head);
      actions = g_list_append(actions, action);
      
      g_string_free(caption, TRUE);
      g_string_free(hint, TRUE);
    }
    
    g_list_free(files);
  }

  g_free(scheme);

  return actions;
}
コード例 #18
0
void
empathy_roster_view_remove_event (EmpathyRosterView *self,
    guint event_id)
{
  GList *l;

  for (l = g_queue_peek_head_link (self->priv->events); l != NULL;
      l = g_list_next (l))
    {
      Event *event = l->data;

      if (event->id == event_id)
        {
          remove_event (self, event);
          return;
        }
    }
}
コード例 #19
0
ファイル: gates.cpp プロジェクト: Patrick6289/navguide
void gates_cleanup (GQueue *gates)
{
    for (GList *iter = g_queue_peek_head_link (gates);iter;iter=g_list_next(iter)) {
        gate_t *g = (gate_t*)iter->data;
        gboolean done = FALSE;
        while (!done) {
            done = TRUE;
            for (int i=0;i<g->ng;i++) {
                if (fabs (g->ng_names[i]-g->uid) <= 4 &&
                        fabs (g->ng_names[i]-g->uid) > 1)  {
                    gate_remove_neighbor (g, g->ng_names[i]);
                    done = FALSE;
                    break;
                }
            }
        }
    }
}
コード例 #20
0
static void
remove_all_individual_event (EmpathyRosterView *self,
    FolksIndividual *individual)
{
  GList *l;

  for (l = g_queue_peek_head_link (self->priv->events); l != NULL;
      l = g_list_next (l))
    {
      Event *event = l->data;

      if (event->individual == individual)
        {
          remove_event (self, event);
          return;
        }
    }
}
コード例 #21
0
static void
decorator_item_cache_remove (TrackerDecorator *decorator,
                             gint              id)
{
	TrackerDecoratorPrivate *priv = decorator->priv;
	GList *item;

	for (item = g_queue_peek_head_link (&priv->item_cache);
	     item; item = item->next) {
		TrackerDecoratorInfo *info = item->data;

		if (info->id != id)
			continue;

		g_queue_remove (&priv->item_cache, info);
		tracker_decorator_info_unref (info);
	}
}
コード例 #22
0
ファイル: state.cpp プロジェクト: Patrick6289/navguide
void state_print_to_file (dijk_graph_t *dg, const char *filename)
{
    char tmpfilename[256];
    sprintf (tmpfilename, "%s.zzz.tmp", filename);

    FILE *fp = fopen (tmpfilename, "w");
    if (!fp)
        return;

    for (GList *iter=g_queue_peek_head_link (dg->nodes);iter;iter=iter->next) {
        dijk_node_t *nd = (dijk_node_t*)iter->data;
        fprintf (fp, "%d %.5f\n", nd->uid, nd->pdf1);
    }

    fclose (fp);

    rename (tmpfilename, filename);
}
コード例 #23
0
ファイル: swfdec_audio_flv.c プロジェクト: fengye/swfdec
static gsize
swfdec_audio_flv_render (SwfdecAudio *audio, gint16* dest,
    gsize start, gsize n_samples)
{
  SwfdecAudioFlv *flv = SWFDEC_AUDIO_FLV (audio);
  GList *walk;
  gsize samples, rendered;
  SwfdecBuffer *buffer;

  g_assert (start < G_MAXINT);
  start += flv->playback_skip;
  SWFDEC_LOG ("flv %p rendering offset %"G_GSIZE_FORMAT", samples %"G_GSIZE_FORMAT, 
      flv, start, n_samples);
  walk = g_queue_peek_head_link (flv->playback_queue);
  for (rendered = 0; rendered < n_samples;) {
    if (walk) {
      buffer = walk->data;
      walk = walk->next;
    } else {
      buffer = swfdec_audio_flv_decode_one (flv);
      if (!buffer)
	break;
    }
    samples = swfdec_sound_buffer_get_n_samples (buffer, 
	swfdec_audio_format_new (44100, 2, TRUE));
    if (start) {
      if (samples <= start) {
	start -= samples;
	continue;
      }
      samples -= start;
      SWFDEC_LOG ("rendering %"G_GSIZE_FORMAT" samples, skipping %"G_GSIZE_FORMAT,
	  samples, start);
    } else {
      SWFDEC_LOG ("rendering %"G_GSIZE_FORMAT" samples", samples);
    }
    samples = MIN (samples, n_samples - rendered);
    swfdec_sound_buffer_render (dest, buffer, start, samples);
    start = 0;
    rendered += samples;
    dest += 2 * samples;
  }
  return rendered;
}
コード例 #24
0
ファイル: listbox.c プロジェクト: Distrotech/mc
static int
listbox_check_hotkey (WListbox * l, int key)
{
    if (!listbox_is_empty (l))
    {
        int i;
        GList *le;

        for (i = 0, le = g_queue_peek_head_link (l->list); le != NULL; i++, le = g_list_next (le))
        {
            WLEntry *e = LENTRY (le->data);

            if (e->hotkey == key)
                return i;
        }
    }

    return (-1);
}
コード例 #25
0
ファイル: listbox.c プロジェクト: Distrotech/mc
int
listbox_search_text (WListbox * l, const char *text)
{
    if (!listbox_is_empty (l))
    {
        int i;
        GList *le;

        for (i = 0, le = g_queue_peek_head_link (l->list); le != NULL; i++, le = g_list_next (le))
        {
            WLEntry *e = LENTRY (le->data);

            if (strcmp (e->text, text) == 0)
                return i;
        }
    }

    return (-1);
}
コード例 #26
0
static guint64
get_buffer_level (RTPJitterBuffer * jbuf)
{
  RTPJitterBufferItem *high_buf = NULL, *low_buf = NULL;
  guint64 level;

  /* first first buffer with timestamp */
  high_buf = (RTPJitterBufferItem *) g_queue_peek_tail_link (jbuf->packets);
  while (high_buf) {
    if (high_buf->dts != -1)
      break;

    high_buf = (RTPJitterBufferItem *) g_list_previous (high_buf);
  }

  low_buf = (RTPJitterBufferItem *) g_queue_peek_head_link (jbuf->packets);
  while (low_buf) {
    if (low_buf->dts != -1)
      break;

    low_buf = (RTPJitterBufferItem *) g_list_next (low_buf);
  }

  if (!high_buf || !low_buf || high_buf == low_buf) {
    level = 0;
  } else {
    guint64 high_ts, low_ts;

    high_ts = high_buf->dts;
    low_ts = low_buf->dts;

    if (high_ts > low_ts)
      level = high_ts - low_ts;
    else
      level = 0;

    GST_LOG_OBJECT (jbuf,
        "low %" GST_TIME_FORMAT " high %" GST_TIME_FORMAT " level %"
        G_GUINT64_FORMAT, GST_TIME_ARGS (low_ts), GST_TIME_ARGS (high_ts),
        level);
  }
  return level;
}
コード例 #27
0
ファイル: listbox.c プロジェクト: MidnightCommander/mc
/**
 * Finds item by its 'data' slot.
 */
int
listbox_search_data (WListbox * l, const void *data)
{
    if (!listbox_is_empty (l))
    {
        int i;
        GList *le;

        for (i = 0, le = g_queue_peek_head_link (l->list); le != NULL; i++, le = g_list_next (le))
        {
            WLEntry *e = LENTRY (le->data);

            if (e->data == data)
                return i;
        }
    }

    return (-1);
}
コード例 #28
0
ファイル: scrollplot2d.c プロジェクト: PennPanda/libbot2
static void
_plot2d_render_window (void *key, void *value, void *user_data)
{
    _plot2d_t *plot = (_plot2d_t*) value;
    BotGlScrollPlot2d *sp = (BotGlScrollPlot2d*) user_data;

    // remove all points that aren't visible
    while (! g_queue_is_empty (plot->points)) {
        _plot2d_point_t *pt = 
            (_plot2d_point_t*)g_queue_peek_head (plot->points);
        if (pt->x < sp->x_min) {
            g_queue_pop_head (plot->points);
            g_slice_free (_plot2d_point_t, pt);
        } else {
            break;
        }
    }

    double size_x = sp->x_max - sp->x_min;
    double size_y = sp->y_max - sp->y_min;

    glBegin (GL_LINES);
    _plot2d_setup_gl_line_style (plot);

    GList *piter = g_queue_peek_head_link (plot->points);
    for (; piter && piter->next; piter=piter->next) {
        _plot2d_point_t *pt = (_plot2d_point_t*) piter->data;
        _plot2d_point_t *next_pt = (_plot2d_point_t*) piter->next->data;

        double py = MIN (sp->y_max, MAX (sp->y_min, pt->y));
        double npy = MIN (sp->y_max, MAX (sp->y_min, next_pt->y));

        double sx = (pt->x - sp->x_min) / size_x;
        double sy = 1 - (py - sp->y_min) / size_y;
        double snx = (next_pt->x - sp->x_min) / size_x;
        double sny = 1 - (npy - sp->y_min) / size_y;

        glVertex2f (sx, sy);
        glVertex2f (snx, sny);
    }
    glEnd ();
}
コード例 #29
0
ファイル: swfdec_audio_stream.c プロジェクト: fengye/swfdec
static gsize
swfdec_audio_stream_render (SwfdecAudio *audio, gint16* dest,
    gsize start, gsize n_samples)
{
  SwfdecAudioStream *stream = SWFDEC_AUDIO_STREAM (audio);
  GList *walk;
  gsize samples, rendered, skip;
  SwfdecBuffer *buffer;

  g_assert (start < G_MAXINT);
  SWFDEC_LOG ("stream %p rendering offset %"G_GSIZE_FORMAT", samples %"G_GSIZE_FORMAT,
      stream, start, n_samples);
  swfdec_audio_stream_require (stream, start + n_samples);
  if (stream->queue_size <= start)
    return 0;
  n_samples = MIN (stream->queue_size, n_samples + start);

  rendered = 0;
  for (walk = g_queue_peek_head_link (stream->queue); 
       rendered < n_samples; walk = walk->next) {
    /* must hold, we check above that enough data is available */
    g_assert (walk);
    buffer = walk->data;
    samples = buffer->length / 4;
    if (rendered < start) {
      skip = MIN (samples, start - rendered);
      samples -= skip;
      samples = MIN (n_samples - start, samples);
    } else {
      skip = 0;
      samples = MIN (n_samples - rendered, samples);
    }
    samples = MIN (n_samples - MAX (start, rendered), samples);
    if (samples)
      swfdec_sound_buffer_render (dest, buffer, skip, samples);

    rendered += skip + samples;
    dest += 2 * samples;
  }

  return rendered - start;
}
コード例 #30
0
ファイル: state.cpp プロジェクト: Patrick6289/navguide
/* update the classifier state with pdf values
*/
void state_update_class_param (navlcm_class_param_t *state, dijk_graph_t *dg)
{
    if (g_queue_is_empty (dg->nodes))
        return;

    if (state->pdfval)
        free (state->pdfval);
    if (state->pdfind)
        free (state->pdfind);
    state->pdf_size = g_queue_get_length (dg->nodes);
    state->pdfind = (int*)calloc(state->pdf_size, sizeof(int));
    state->pdfval = (double*)calloc(state->pdf_size, sizeof(double));

    int count = 0;
    for (GList *iter=g_queue_peek_head_link(dg->nodes);iter;iter=iter->next) {
        dijk_node_t *nd = (dijk_node_t*)iter->data;
        state->pdfind[count] = nd->uid;
        state->pdfval[count] = nd->pdf1;
        count++;
    }
}