annotate src/null/null.c @ 1896:946de0b91bdc

Use GTK+ Stock buttons for everything.
author William Pitcock <nenolod@atheme.org>
date Wed, 26 Sep 2007 12:34:39 -0500
parents 8c93d207a4d9
children b8da6a0b0da2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
144
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
1 /*
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
2 * Copyright 2006 Christian Birchinger <joker@netswarm.net>
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
3 *
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
4 * Based on the XMMS plugin:
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
5 * Copyright 2000 H�vard Kv�len <havardk@sol.no>
144
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
6 *
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
7 *
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
11 * (at your option) any later version.
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
12 *
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
16 * GNU General Public License for more details.
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
17 *
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
21 */
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
22
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
23 #include <glib.h>
527
d124034ebea3 [svn] - glib/gi18n.h -> audacious/i18n.h for automatic dgettext support
nenolod
parents: 434
diff changeset
24 #include <audacious/i18n.h>
144
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
25 #include <gtk/gtk.h>
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
26 #include <audacious/plugin.h>
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
27 #include <audacious/util.h>
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
28 #include <audacious/configdb.h>
434
7385182ae4b8 [svn] - add missing config.h inclusion for wavpack, null and metronom plugin
giacomo
parents: 144
diff changeset
29 #include "../../config.h"
144
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
30
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
31 static GTimer *timer;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
32 static gulong offset_time, written;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
33 static gint bps;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
34 static gboolean real_time = TRUE;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
35 static gboolean paused, started;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
36 static GtkWidget *configurewin;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
37 static struct {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
38 AFormat format;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
39 gint frequency;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
40 gint channels;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
41 } input_format;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
42
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
43 #define ELAPSED_TIME (offset_time + g_timer_elapsed(timer, NULL) * 1000)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
44
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
45 static void null_init(void)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
46 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
47 ConfigDb *db;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
48 db = bmp_cfg_db_open();
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
49 bmp_cfg_db_get_bool(db, "null", "real_time", &real_time);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
50 bmp_cfg_db_close(db);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
51 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
52
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
53 static void null_about(void)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
54 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
55 static GtkWidget *about;
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
56 gchar *about_text;
144
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
57
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
58 if (about)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
59 return;
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
60
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
61 about_text = g_strjoin("", _("Null output plugin "), VERSION,
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
62 _(" by Christian Birchinger <joker@netswarm.net>\n"
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
63 "based on the XMMS plugin by Håvard Kvål <havardk@xmms.org>"), NULL);
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
64
1677
f6f5603a0954 xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents: 1628
diff changeset
65 about = audacious_info_dialog(_("About Null Output"),
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
66 about_text,
144
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
67 _("Ok"), FALSE, NULL, NULL);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
68
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
69 g_signal_connect(G_OBJECT(about), "destroy",
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
70 G_CALLBACK(gtk_widget_destroyed), &about);
1325
a33da9237bed Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents: 1304
diff changeset
71 g_free(about_text);
144
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
72 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
73
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
74 static void null_configure_ok_cb(GtkButton *w, gpointer data)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
75 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
76 ConfigDb *db;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
77
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
78 db = bmp_cfg_db_open();
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
79 real_time = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data));
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
80 bmp_cfg_db_set_bool(db, "null", "real_time", real_time);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
81 bmp_cfg_db_close(db);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
82 gtk_widget_destroy(configurewin);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
83 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
84
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
85
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
86 static void null_configure(void)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
87 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
88 GtkWidget *rt_btn, *ok_button, *cancel_button, *vbox, *bbox;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
89
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
90 if (configurewin)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
91 return;
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
92
144
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
93 configurewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
94 gtk_window_set_title(GTK_WINDOW(configurewin), _("Null output preferences"));
144
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
95 gtk_window_set_policy(GTK_WINDOW(configurewin), FALSE, FALSE, FALSE);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
96 gtk_container_set_border_width(GTK_CONTAINER(configurewin), 10);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
97 gtk_signal_connect(GTK_OBJECT(configurewin), "destroy",
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
98 GTK_SIGNAL_FUNC(gtk_widget_destroyed), &configurewin);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
99
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
100 vbox = gtk_vbox_new(FALSE, 10);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
101 gtk_container_add(GTK_CONTAINER(configurewin), vbox);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
102
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
103 rt_btn = gtk_check_button_new_with_label(_("Run in real time"));
144
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
104 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rt_btn), real_time);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
105 gtk_box_pack_start(GTK_BOX(vbox), rt_btn, FALSE, FALSE, 0);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
106 bbox = gtk_hbutton_box_new();
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
107 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
108 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
109 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
110 ok_button = gtk_button_new_with_label(_("Ok"));
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
111 cancel_button = gtk_button_new_with_label(_("Cancel"));
144
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
112 GTK_WIDGET_SET_FLAGS(ok_button, GTK_CAN_DEFAULT);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
113 GTK_WIDGET_SET_FLAGS(cancel_button, GTK_CAN_DEFAULT);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
114 gtk_widget_grab_default(ok_button);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
115 gtk_signal_connect_object(GTK_OBJECT(cancel_button), "clicked",
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
116 GTK_SIGNAL_FUNC(gtk_widget_destroy),
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
117 GTK_OBJECT(configurewin));
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
118 gtk_signal_connect(GTK_OBJECT(ok_button), "clicked",
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
119 GTK_SIGNAL_FUNC(null_configure_ok_cb), rt_btn);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
120 gtk_box_pack_start_defaults(GTK_BOX(bbox), ok_button);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
121 gtk_box_pack_start_defaults(GTK_BOX(bbox), cancel_button);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
122
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
123 gtk_widget_show_all(configurewin);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
124 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
125
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
126 static int null_open(AFormat fmt, int rate, int nch)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
127 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
128 offset_time = 0;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
129 written = 0;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
130 started = FALSE;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
131 paused = FALSE;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
132 input_format.format = fmt;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
133 input_format.frequency = rate;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
134 input_format.channels = nch;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
135 bps = rate * nch;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
136 switch (fmt)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
137 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
138 case FMT_U8:
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
139 case FMT_S8:
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
140 break;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
141 default:
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
142 bps <<= 1;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
143 break;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
144 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
145 if (real_time)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
146 timer = g_timer_new();
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
147 return 1;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
148 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
149
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
150 static void null_write(void *ptr, int length)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
151 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
152 if (timer && !started)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
153 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
154 g_timer_start(timer);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
155 started = TRUE;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
156 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
157
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
158 written += length;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
159 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
160
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
161 static void null_close(void)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
162 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
163 if (timer)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
164 g_timer_destroy(timer);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
165 timer = NULL;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
166 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
167
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
168 static void null_flush(int time)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
169 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
170 offset_time = time;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
171 written = ((double)time * bps) / 1000;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
172 if (timer)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
173 g_timer_reset(timer);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
174 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
175
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
176 static void null_pause(short p)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
177 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
178 paused = p;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
179 if (!timer)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
180 return;
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
181
144
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
182 if (paused)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
183 g_timer_stop(timer);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
184 else
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
185 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
186 offset_time += g_timer_elapsed(timer, NULL) * 1000;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
187 g_timer_start(timer);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
188 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
189 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
190
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
191 static int null_buffer_free(void)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
192 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
193 if (timer)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
194 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
195 return 10240 - (written - (ELAPSED_TIME * bps) / 1000);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
196 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
197 else
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
198 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
199 if (!paused)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
200 return 10000;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
201 else
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
202 return 0;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
203 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
204 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
205
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
206 static int null_playing(void)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
207 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
208 if (!timer)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
209 return FALSE;
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
210
144
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
211 if ((gdouble)(written * 1000) / bps > ELAPSED_TIME)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
212 return TRUE;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
213 return FALSE;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
214 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
215
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
216 static int null_get_written_time(void)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
217 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
218 if (!bps)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
219 return 0;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
220 return ((gint64)written * 1000) / bps;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
221 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
222
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
223 static int null_get_output_time(void)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
224 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
225 if (!timer)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
226 return null_get_written_time();
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
227
144
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
228 return ELAPSED_TIME;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
229 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
230
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
231 OutputPlugin null_op =
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
232 {
1628
0a3b3b6430b1 null: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
233 .description = "Null Output Plugin",
0a3b3b6430b1 null: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
234 .init = null_init,
0a3b3b6430b1 null: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
235 .about = null_about,
0a3b3b6430b1 null: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
236 .configure = null_configure,
0a3b3b6430b1 null: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
237 .open_audio = null_open,
0a3b3b6430b1 null: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
238 .write_audio = null_write,
0a3b3b6430b1 null: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
239 .close_audio = null_close,
0a3b3b6430b1 null: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
240 .flush = null_flush,
0a3b3b6430b1 null: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
241 .pause = null_pause,
0a3b3b6430b1 null: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
242 .buffer_free = null_buffer_free,
0a3b3b6430b1 null: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
243 .buffer_playing = null_playing,
0a3b3b6430b1 null: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
244 .output_time = null_get_output_time,
0a3b3b6430b1 null: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
245 .written_time = null_get_written_time,
144
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
246 };
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
247
1100
e363a0fa8ea0 [svn] - null: convert to plugin API v2
nenolod
parents: 527
diff changeset
248 OutputPlugin *null_oplist[] = { &null_op, NULL };
e363a0fa8ea0 [svn] - null: convert to plugin API v2
nenolod
parents: 527
diff changeset
249
1395
761e17b23e0c added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents: 1325
diff changeset
250 DECLARE_PLUGIN(null, NULL, NULL, NULL, null_oplist, NULL, NULL, NULL, NULL);