Пример #1
0
void
equalizerwin_create(void)
{
    equalizer_presets = aud_equalizer_read_presets("eq.preset");
    equalizer_auto_presets = aud_equalizer_read_presets("eq.auto_preset");

    if (! equalizer_presets)
        equalizer_presets = index_new ();
    if (! equalizer_auto_presets)
        equalizer_auto_presets = index_new ();

    equalizerwin_create_window();

    gtk_window_add_accel_group( GTK_WINDOW(equalizerwin) , ui_manager_get_accel_group() );

    equalizerwin_create_widgets();
    window_show_all (equalizerwin);

    g_signal_connect (equalizerwin, "destroy", (GCallback) equalizerwin_destroyed, NULL);

    hook_associate ("set equalizer_active", (HookFunction) update_from_config, NULL);
    hook_associate ("set equalizer_bands", (HookFunction) update_from_config, NULL);
    hook_associate ("set equalizer_preamp", (HookFunction) update_from_config, NULL);

    int playlist = aud_playlist_get_playing ();

    /* Load preset for the first song. FIXME: Doing this at interface load is
     really too late as the song may already be started. Really, this stuff
     shouldn't be in the interface plugin at all but in core. -jlindgren */
    if (playlist != -1)
        position_cb (GINT_TO_POINTER (playlist), NULL);

    hook_associate ("playlist position", position_cb, NULL);
}
Пример #2
0
static void do_add (bool_t play, char * * title)
{
    int list = aud_playlist_by_unique_id (playlist_id);
    int n_items = index_count (items);
    int n_selected = 0;

    Index * filenames = index_new ();
    Index * tuples = index_new ();

    for (int i = 0; i < n_items; i ++)
    {
        if (! selection->data[i])
            continue;

        Item * item = index_get (items, i);

        for (int m = 0; m < item->matches->len; m ++)
        {
            int entry = g_array_index (item->matches, int, m);
            index_insert (filenames, -1, aud_playlist_entry_get_filename (list, entry));
            index_insert (tuples, -1, aud_playlist_entry_get_tuple (list, entry, TRUE));
        }

        n_selected ++;
        if (title && n_selected == 1)
            * title = item->name;
    }

    if (title && n_selected != 1)
        * title = NULL;

    aud_playlist_entry_insert_batch (aud_playlist_get_active (), -1, filenames,
     tuples, play);
}
Пример #3
0
static void shift_rows (void * user, gint row, gint before)
{
    gint rows = index_count (user);
    g_return_if_fail (row >= 0 && row < rows);
    g_return_if_fail (before >= 0 && before <= rows);

    if (before == row)
        return;

    Index * move = index_new ();
    Index * others = index_new ();

    gint begin, end;
    if (before < row)
    {
        begin = before;
        end = row + 1;
        while (end < rows && ((Column *) index_get (user, end))->selected)
            end ++;
    }
    else
    {
        begin = row;
        while (begin > 0 && ((Column *) index_get (user, begin - 1))->selected)
            begin --;
        end = before;
    }

    for (gint i = begin; i < end; i ++)
    {
        Column * c = index_get (user, i);
        index_append (c->selected ? move : others, c);
    }

    if (before < row)
    {
        index_merge_append (move, others);
        index_free (others);
    }
    else
    {
        index_merge_append (others, move);
        index_free (move);
        move = others;
    }

    index_copy_set (move, 0, user, begin, end - begin);
    index_free (move);

    GtkWidget * list = (user == chosen) ? chosen_list : avail_list;
    audgui_list_update_rows (list, begin, end - begin);
    audgui_list_update_selection (list, begin, end - begin);
}
Пример #4
0
bool_t playlist_save (int list, const char * filename)
{
    AUDDBG ("Saving playlist %s.\n", filename);

    PluginHandle * plugin = get_plugin (filename, TRUE);
    if (! plugin)
        return FALSE;

    PlaylistPlugin * pp = plugin_get_header (plugin);
    g_return_val_if_fail (pp && PLUGIN_HAS_FUNC (pp, load), FALSE);

    bool_t fast = get_bool (NULL, "metadata_on_play");

    VFSFile * file = vfs_fopen (filename, "w");
    if (! file)
        return FALSE;

    char * title = playlist_get_title (list);

    int entries = playlist_entry_count (list);
    Index * filenames = index_new ();
    index_allocate (filenames, entries);
    Index * tuples = index_new ();
    index_allocate (tuples, entries);

    for (int i = 0; i < entries; i ++)
    {
        index_append (filenames, playlist_entry_get_filename (list, i));
        index_append (tuples, playlist_entry_get_tuple (list, i, fast));
    }

    bool_t success = pp->save (filename, file, title, filenames, tuples);

    vfs_fclose (file);
    str_unref (title);

    for (int i = 0; i < entries; i ++)
    {
        str_unref (index_get (filenames, i));
        Tuple * tuple = index_get (tuples, i);
        if (tuple)
            tuple_unref (tuple);
    }

    index_free (filenames);
    index_free (tuples);

    return success;
}
Пример #5
0
int main()
{
	int i,ret;
	char key[KSIZE];
	char val[VSIZE];

	struct slice sk,sv;

	struct index *idx=index_new("test_idx",MAX_MTBL,MAX_MTBL_SIZE);
	for(i=0;i < LOOP;i++){
		snprintf(key,KSIZE,"key:%d",i);
		snprintf(val,VSIZE,"val:%d",i);

		sk.len=KSIZE;
		sk.data=key;
		sv.len=VSIZE;
		sv.data=val;

		ret=index_add(idx,&sk,&sv);
		if(!ret)
			__DEBUG("%s","Write failed....");
	}

	return 0;

}
Пример #6
0
static bool_t search_init (void)
{
    find_playlist ();

    search_terms = index_new ();
    items = index_new ();
    selection = g_array_new (FALSE, FALSE, 1);

    update_database ();

    hook_associate ("playlist add complete", add_complete_cb, NULL);
    hook_associate ("playlist scan complete", scan_complete_cb, NULL);
    hook_associate ("playlist update", playlist_update_cb, NULL);

    return TRUE;
}
Пример #7
0
static PluginData * open_plugin (const char * path, const LADSPA_Descriptor * desc)
{
    const char * slash = strrchr (path, G_DIR_SEPARATOR);
    g_return_val_if_fail (slash && slash[1], NULL);
    g_return_val_if_fail (desc->Label && desc->Name, NULL);

    PluginData * plugin = g_slice_new (PluginData);
    plugin->path = g_strdup (slash + 1);
    plugin->desc = desc;
    plugin->controls = index_new ();
    plugin->in_ports = g_array_new (0, 0, sizeof (int));
    plugin->out_ports = g_array_new (0, 0, sizeof (int));
    plugin->selected = 0;

    for (int i = 0; i < desc->PortCount; i ++)
    {
        if (LADSPA_IS_PORT_CONTROL (desc->PortDescriptors[i]))
        {
            ControlData * control = parse_control (desc, i);
            if (control)
                index_append (plugin->controls, control);
        }
        else if (LADSPA_IS_PORT_AUDIO (desc->PortDescriptors[i]) &&
         LADSPA_IS_PORT_INPUT (desc->PortDescriptors[i]))
            g_array_append_val (plugin->in_ports, i);
        else if (LADSPA_IS_PORT_AUDIO (desc->PortDescriptors[i]) &&
         LADSPA_IS_PORT_OUTPUT (desc->PortDescriptors[i]))
            g_array_append_val (plugin->out_ports, i);
    }

    return plugin;
}
Пример #8
0
struct index* _get_idx()
{
	struct index *idx;

	idx = index_new("ndbs", MTBL_MAX_COUNT, TOLOG);
	return idx;
}
Пример #9
0
static int init (void)
{
    pthread_mutex_lock (& mutex);

    modules = index_new ();
    plugins = index_new ();
    loadeds = index_new ();

    aud_config_set_defaults ("ladspa", ladspa_defaults);

    module_path = aud_get_string ("ladspa", "module_path");

    open_modules ();
    load_enabled_from_config ();

    pthread_mutex_unlock (& mutex);
    return 1;
}
Пример #10
0
Файл: hfile.c Проект: pipul/lab
index_t *index_load(int32_t fd, int32_t offset, int32_t size)
{
	int32_t id;
	int32_t len;
	index_t *l;
	int8_t *buffer, *ptr;
	meta_t *o;
	
	if (fd < 0 || offset < 0 || size < 0)
		return(NULL);
	if ((l = index_new()) == NULL)
		return(NULL);
	if ((buffer = malloc(size)) == NULL)
		__ERROR_LOG(B_ERROR);
	lseek(fd,offset,SEEK_SET);
	if (size != read(fd,buffer,size))
		__ERROR_LOG(R_ERROR);

	ptr = buffer;
	l->magic = *(uint64_t *)ptr;
	ptr = ptr + sizeof(uint64_t);
	if (l->magic != crc32_encode(ptr,size - sizeof(uint64_t)))
		__ERROR_LOG(C_ERROR);

	id = 0;		/* inode id */
	while (ptr - buffer < size) {
		if ((o = meta_new()) == NULL)
			break;
		o->offset = *(int32_t *)ptr;
		ptr = ptr + sizeof(int32_t);

		o->blocksize = *(int32_t *)ptr;
		ptr = ptr + sizeof(int32_t);

		len = *(int32_t *)ptr;
		ptr = ptr + sizeof(int32_t);
		o->key = sdsnnew(ptr,len);
		ptr = ptr + len;

		if (o->key == NULL) {
			meta_free(o);
			continue;
		}
		o->id = id++;
		index_add(l,o);
	}

	free(buffer);
	return(l);

C_ERROR:
R_ERROR:
	free(buffer);
B_ERROR:
	index_free(l);
	return(NULL);
}
Пример #11
0
Index * equalizer_read_presets (const char * basename)
{
    char *filename, *name;
    GKeyFile *rcfile;
    int i, p = 0;
    EqualizerPreset *preset;

    filename = g_build_filename (get_path (AUD_PATH_USER_DIR), basename, NULL);

    rcfile = g_key_file_new();
    if (!g_key_file_load_from_file(rcfile, filename, G_KEY_FILE_NONE, NULL))
    {
        g_free(filename);
        filename = g_build_filename (get_path (AUD_PATH_DATA_DIR), basename,
         NULL);

        if (!g_key_file_load_from_file(rcfile, filename, G_KEY_FILE_NONE, NULL))
        {
           g_free(filename);
           return NULL;
        }
    }

    g_free(filename);

    Index * list = index_new ();

    for (;;)
    {
        char section[32];

        g_snprintf(section, sizeof(section), "Preset%d", p++);

        if ((name = g_key_file_get_string(rcfile, "Presets", section, NULL)) != NULL)
        {
            preset = g_new0(EqualizerPreset, 1);
            preset->name = name;
            preset->preamp = g_key_file_get_double(rcfile, name, "Preamp", NULL);

            for (i = 0; i < AUD_EQUALIZER_NBANDS; i++)
            {
                char band[16];
                g_snprintf(band, sizeof(band), "Band%d", i);

                preset->bands[i] = g_key_file_get_double(rcfile, name, band, NULL);
            }

            index_append (list, preset);
        }
        else
            break;
    }

    g_key_file_free(rcfile);

    return list;
}
Пример #12
0
bool_t playlist_load (const char * filename, char * * title,
 Index * * filenames_p, Index * * tuples_p)
{
    AUDDBG ("Loading playlist %s.\n", filename);

    PluginHandle * plugin = get_plugin (filename, FALSE);
    if (! plugin)
        return FALSE;

    PlaylistPlugin * pp = plugin_get_header (plugin);
    g_return_val_if_fail (pp && PLUGIN_HAS_FUNC (pp, load), FALSE);

    VFSFile * file = vfs_fopen (filename, "r");
    if (! file)
        return FALSE;

    Index * filenames = index_new ();
    Index * tuples = index_new ();
    bool_t success = pp->load (filename, file, title, filenames, tuples);

    vfs_fclose (file);

    if (! success)
    {
        index_free (filenames);
        index_free (tuples);
        return FALSE;
    }

    if (index_count (tuples))
        g_return_val_if_fail (index_count (tuples) == index_count (filenames),
         FALSE);
    else
    {
        index_free (tuples);
        tuples = NULL;
    }

    * filenames_p = filenames;
    * tuples_p = tuples;
    return TRUE;
}
Пример #13
0
static void initialize(const char *config) {
	g.env = env_create(config);
	if (!g.env) {
		fprintf(stderr, "usage: ./service config\n");
		exit(0);
	}
	g.log = 0;
	g.total = 0;
	g.index = index_new();
	g.names = env_create(0);
}
Пример #14
0
void pw_col_save (void)
{
    Index * index = index_new ();

    for (int i = 0; i < pw_num_cols; i ++)
        index_insert (index, -1, (void *) pw_col_keys[pw_cols[i]]);

    char * columns = index_to_str_list (index, " ");
    aud_set_str ("gtkui", "playlist_columns", columns);
    str_unref (columns);

    index_free (index);
}
Пример #15
0
static void begin_add (const char * path)
{
    int list = get_playlist (FALSE, FALSE);

    if (list < 0)
        list = create_playlist ();

    aud_set_str ("search-tool", "path", path);

    char * uri = filename_to_uri (path);
    g_return_if_fail (uri);

    if (! g_str_has_suffix (uri, "/"))
    {
        SCONCAT2 (temp, uri, "/");
        str_unref (uri);
        uri = str_get (temp);
    }

    destroy_added_table ();

    added_table = g_hash_table_new_full ((GHashFunc) str_hash, (GEqualFunc)
     str_equal, (GDestroyNotify) str_unref, NULL);

    int entries = aud_playlist_entry_count (list);

    for (int entry = 0; entry < entries; entry ++)
    {
        char * filename = aud_playlist_entry_get_filename (list, entry);

        if (g_str_has_prefix (filename, uri) && ! g_hash_table_contains (added_table, filename))
        {
            aud_playlist_entry_set_selected (list, entry, FALSE);
            g_hash_table_insert (added_table, filename, NULL);
        }
        else
        {
            aud_playlist_entry_set_selected (list, entry, TRUE);
            str_unref (filename);
        }
    }

    aud_playlist_delete_selected (list);
    aud_playlist_remove_failed (list);

    Index * add = index_new ();
    index_insert (add, -1, uri);
    aud_playlist_entry_insert_filtered (list, -1, add, NULL, filter_cb, NULL, FALSE);

    adding = TRUE;
}
Пример #16
0
Index * import_winamp_eqf (VFSFile * file)
{
    char header[31];
    char bands[11];
    int i = 0;
    EqualizerPreset *preset = NULL;
    char *markup;
    char preset_name[0xb4];

    if (vfs_fread (header, 1, sizeof header, file) != sizeof header || strncmp
     (header, "Winamp EQ library file v1.1", 27))
        goto error;

    AUDDBG("The EQF header is OK\n");

    if (vfs_fseek(file, 0x1f, SEEK_SET) == -1) goto error;

    Index * list = index_new ();

    while (vfs_fread(preset_name, 1, 0xb4, file) == 0xb4) {
        AUDDBG("The preset name is '%s'\n", preset_name);
        if (vfs_fseek (file, 0x4d, SEEK_CUR)) /* unknown crap --asphyx */
            break;
        if (vfs_fread(bands, 1, 11, file) != 11) break;

        preset = equalizer_preset_new(preset_name);
        /*this was divided by 63, but shouldn't it be 64? --majeru*/
        preset->preamp = EQUALIZER_MAX_GAIN - ((bands[10] * EQUALIZER_MAX_GAIN * 2) / 64.0);

        for (i = 0; i < 10; i++)
            preset->bands[i] = EQUALIZER_MAX_GAIN - ((bands[i] * EQUALIZER_MAX_GAIN * 2) / 64.0);

        index_append (list, preset);
    }

    return list;

error:
    markup = g_strdup_printf (_("Error importing Winamp EQF file '%s'"),
     vfs_get_filename (file));
    interface_show_error(markup);

    g_free(markup);
    return NULL;
}
Пример #17
0
static void add_list (GList * list, gint at, gboolean to_temp, gboolean play)
{
    if (to_temp)
        activate_temp ();

    gint playlist = playlist_get_active ();

    if (play)
    {
        if (get_bool (NULL, "clear_playlist"))
            playlist_entry_delete (playlist, 0, playlist_entry_count (playlist));
        else
            playlist_queue_delete (playlist, 0, playlist_queue_count (playlist));
    }

    struct index * filenames = index_new ();
    for (; list != NULL; list = list->next)
        index_append (filenames, g_strdup (list->data));

    playlist_entry_insert_batch (playlist, at, filenames, NULL, play);
}
Пример #18
0
static void do_search (void)
{
    index_delete (items, 0, index_count (items));

    if (! database)
        return;

    SearchState state;

    for (int f = 0; f < FIELDS; f ++)
        state.items[f] = index_new ();

    /* effectively limits number of search terms to 32 */
    state.mask = (1 << index_count (search_terms)) - 1;

    g_hash_table_foreach (database, search_cb, & state);

    int total = 0;

    for (int f = 0; f < FIELDS; f ++)
    {
        int count = index_count (state.items[f]);
        if (count > MAX_RESULTS - total)
            count = MAX_RESULTS - total;

        if (count)
        {
            index_sort (state.items[f], item_compare);
            index_copy_insert (state.items[f], 0, items, -1, count);
            total += count;
        }

        index_free (state.items[f]);
    }

    g_array_set_size (selection, total);
    memset (selection->data, 0, selection->len);
    if (selection->len > 0)
        selection->data[0] = 1;
}
Пример #19
0
void pw_col_choose (void)
{
    if (window)
    {
        gtk_window_present ((GtkWindow *) window);
        return;
    }

    chosen = index_new ();
    avail = index_new ();

    gboolean added[PW_COLS];
    memset (added, 0, sizeof added);

    for (gint i = 0; i < pw_num_cols; i ++)
    {
        if (added[pw_cols[i]])
            continue;
        added[pw_cols[i]] = TRUE;
        Column * column = g_slice_new (Column);
        column->column = pw_cols[i];
        column->selected = 0;
        index_append (chosen, column);
    }

    for (gint i = 0; i < PW_COLS; i ++)
    {
        if (added[i])
            continue;
        Column * column = g_slice_new (Column);
        column->column = i;
        column->selected = 0;
        index_append (avail, column);
    }

    window = gtk_dialog_new_with_buttons (_("Choose Columns"), NULL, 0,
     GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
     NULL);
    gtk_window_set_default_size ((GtkWindow *) window, 400, 300);
    gtk_dialog_set_default_response ((GtkDialog *) window, GTK_RESPONSE_ACCEPT);

    g_signal_connect (window, "response", (GCallback) response_cb, NULL);
    g_signal_connect (window, "destroy", (GCallback) destroy_cb, NULL);

    GtkWidget * hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start ((GtkBox *) gtk_dialog_get_content_area ((GtkDialog *)
     window), hbox, TRUE, TRUE, 0);

    GtkWidget * vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
    gtk_box_pack_start ((GtkBox *) hbox, vbox, TRUE, TRUE, 0);

    GtkWidget * label = gtk_label_new (_("Available:"));
    g_object_set ((GObject *) label, "xalign", (gfloat) 0, NULL);
    gtk_box_pack_start ((GtkBox *) vbox, label, FALSE, FALSE, 0);

    GtkWidget * scroll = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy ((GtkScrolledWindow *) scroll,
     GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_set_shadow_type ((GtkScrolledWindow *) scroll,
     GTK_SHADOW_IN);
    gtk_box_pack_start ((GtkBox *) vbox, scroll, TRUE, TRUE, 0);

    avail_list = audgui_list_new (& callbacks, avail, index_count (avail));
    gtk_tree_view_set_headers_visible ((GtkTreeView *) avail_list, FALSE);
    audgui_list_add_column (avail_list, NULL, 0, G_TYPE_STRING, -1);
    gtk_container_add ((GtkContainer *) scroll, avail_list);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
    gtk_box_pack_start ((GtkBox *) hbox, vbox, FALSE, FALSE, 0);

    GtkWidget * button = gtk_button_new ();
    gtk_container_add ((GtkContainer *) button, gtk_image_new_from_stock
     (GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_BUTTON));
    gtk_box_pack_start ((GtkBox *) vbox, button, TRUE, FALSE, 0);
    g_signal_connect_swapped (button, "clicked", (GCallback) transfer, avail);

    button = gtk_button_new ();
    gtk_container_add ((GtkContainer *) button, gtk_image_new_from_stock
     (GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON));
    gtk_box_pack_start ((GtkBox *) vbox, button, TRUE, FALSE, 0);
    g_signal_connect_swapped (button, "clicked", (GCallback) transfer, chosen);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
    gtk_box_pack_start ((GtkBox *) hbox, vbox, TRUE, TRUE, 0);

    label = gtk_label_new (_("Chosen:"));
    g_object_set ((GObject *) label, "xalign", (gfloat) 0, NULL);
    gtk_box_pack_start ((GtkBox *) vbox, label, FALSE, FALSE, 0);

    scroll = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy ((GtkScrolledWindow *) scroll,
     GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_set_shadow_type ((GtkScrolledWindow *) scroll,
     GTK_SHADOW_IN);
    gtk_box_pack_start ((GtkBox *) vbox, scroll, TRUE, TRUE, 0);

    chosen_list = audgui_list_new (& callbacks, chosen, index_count (chosen));
    gtk_tree_view_set_headers_visible ((GtkTreeView *) chosen_list, FALSE);
    audgui_list_add_column (chosen_list, NULL, 0, G_TYPE_STRING, -1);
    gtk_container_add ((GtkContainer *) scroll, chosen_list);

    gtk_widget_show_all (window);
}
Пример #20
0
static void start_plugin (LoadedPlugin * loaded)
{
    if (loaded->active)
        return;

    loaded->active = 1;

    PluginData * plugin = loaded->plugin;
    const LADSPA_Descriptor * desc = plugin->desc;

    int ports = plugin->in_ports->len;

    if (ports == 0 || ports != plugin->out_ports->len)
    {
        fprintf (stderr, "Plugin has unusable port configuration: %s\n", desc->Name);
        return;
    }

    if (ladspa_channels % ports != 0)
    {
        fprintf (stderr, "Plugin cannot be used with %d channels: %s\n",
         ladspa_channels, desc->Name);
        return;
    }

    int instances = ladspa_channels / ports;

    loaded->instances = index_new ();
    loaded->in_bufs = g_malloc (sizeof (float *) * ladspa_channels);
    loaded->out_bufs = g_malloc (sizeof (float *) * ladspa_channels);

    for (int i = 0; i < instances; i ++)
    {
        LADSPA_Handle handle = desc->instantiate (desc, ladspa_rate);
        index_append (loaded->instances, handle);

        int controls = index_count (plugin->controls);
        for (int c = 0; c < controls; c ++)
        {
            ControlData * control = index_get (plugin->controls, c);
            desc->connect_port (handle, control->port, & loaded->values[c]);
        }

        for (int p = 0; p < ports; p ++)
        {
            int channel = ports * i + p;

            float * in = g_malloc (sizeof (float) * LADSPA_BUFLEN);
            loaded->in_bufs[channel] = in;
            int in_port = g_array_index (plugin->in_ports, int, p);
            desc->connect_port (handle, in_port, in);

            float * out = g_malloc (sizeof (float) * LADSPA_BUFLEN);
            loaded->out_bufs[channel] = out;
            int out_port = g_array_index (plugin->out_ports, int, p);
            desc->connect_port (handle, out_port, out);
        }

        if (desc->activate)
            desc->activate (handle);
    }
}
Пример #21
0
int
main(int argc, char *argv[])
{
	struct rusage begin, end;
	struct itimerval timer;
	struct trace *trace;
	struct index *idx;
	int ch, ret;
	time_t secs = DEFAULT_SECS;
	size_t round;

	while ((ch = getopt(argc, argv, "qt:")) != -1) {
		switch (ch) {
		case 'q':
			quiet = true;
			break;
		case 't':
			secs = atoi(optarg);
			if (secs <= 0)
				usage();
			break;
		default:
			usage();
			/* NOTREACHED */
		}
	}
	argc -= optind;
	argv += optind;

	if (argc != 1)
		usage();

	errno = 0;
	trace = trace_load(argv[0]);
	if (trace == NULL)
		err(1, "trace_load");

	idx = index_new();
	if (idx == NULL)
		errx(1, "index_new failed");

	timer.it_interval.tv_sec = 0;
	timer.it_interval.tv_usec = 0;
	timer.it_value.tv_sec = secs;
	timer.it_value.tv_usec = 0;

	signal(SIGPROF, do_stop);

	round = 0;
	stop = 0;
	setitimer(ITIMER_PROF, &timer, NULL);
	getrusage(RUSAGE_SELF, &begin);
	do {
		ret = do_round(idx, trace);
		if (ret != 0)
			errx(1, "failed in round %zu", round);
		round++;
	} while (!stop);
	getrusage(RUSAGE_SELF, &end);

	stats(&begin, &end, round);

	return 0;
}
Пример #22
0
void drct_pl_add (const char * filename, int at)
{
    Index * filenames = index_new ();
    index_append (filenames, str_get (filename));
    add_list (filenames, at, FALSE, FALSE);
}
Пример #23
0
void drct_pl_open (const char * filename)
{
    Index * filenames = index_new ();
    index_append (filenames, str_get (filename));
    add_list (filenames, -1, get_bool (NULL, "open_to_temporary"), TRUE);
}
Пример #24
0
void drct_pl_open_temp (const char * filename)
{
    Index * filenames = index_new ();
    index_append (filenames, str_get (filename));
    add_list (filenames, -1, TRUE, TRUE);
}