annotate src/null/null.c @ 984:df7b09989aee trunk

[svn] - We got a new plugin, captain! - FileWriter is the ultimate plugin for dumping audio to files. It should be the successor of Disk Writer and Out-Lame, as it supports the same output formats as those (WAVE and MP3). The main advantage of having only one file dumping plugin for many formats is that not every plugin has to think about file handling (where to write files to, how to call them etc.) that much anymore. - FileWriter is also very extensible - adding new output formats should be very easy.
author mf0102
date Mon, 30 Apr 2007 14:16:32 -0700
parents d124034ebea3
children e363a0fa8ea0
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:
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
5 * Copyright 2000 Håvard Kvålen <havardk@sol.no>
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;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
56
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
57 if (about)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
58 return;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
59 about = xmms_show_message(_("About Null Output"),
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
60 _("Null output plugin " VERSION
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
61 " by Christian Birchinger <joker@netswarm.net>\n"
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
62 " based on the XMMS plugin by Håvard Kvål <havardk@xmms.org>"),
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
63 _("Ok"), FALSE, NULL, NULL);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
64
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
65 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
66 G_CALLBACK(gtk_widget_destroyed), &about);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
67 }
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 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
70 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
71 ConfigDb *db;
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 db = bmp_cfg_db_open();
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
74 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
75 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
76 bmp_cfg_db_close(db);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
77 gtk_widget_destroy(configurewin);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
78 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
79
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
80
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
81 static void null_configure(void)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
82 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
83 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
84
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
85 if (configurewin)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
86 return;
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 configurewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
89 gtk_window_set_title(GTK_WINDOW(configurewin), "Null output preferences");
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
90 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
91 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
92 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
93 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
94
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
95 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
96 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
97
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
98 rt_btn = gtk_check_button_new_with_label("Run in real time");
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
99 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
100 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
101 bbox = gtk_hbutton_box_new();
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
102 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
103 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
104 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
105 ok_button = gtk_button_new_with_label("Ok");
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
106 cancel_button = gtk_button_new_with_label("Cancel");
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
107 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
108 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
109 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
110 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
111 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
112 GTK_OBJECT(configurewin));
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
113 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
114 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
115 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
116 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
117
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
118 gtk_widget_show_all(configurewin);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
119 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
120
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
121 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
122 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
123 offset_time = 0;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
124 written = 0;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
125 started = FALSE;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
126 paused = FALSE;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
127 input_format.format = fmt;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
128 input_format.frequency = rate;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
129 input_format.channels = nch;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
130 bps = rate * nch;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
131 switch (fmt)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
132 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
133 case FMT_U8:
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
134 case FMT_S8:
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
135 break;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
136 default:
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
137 bps <<= 1;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
138 break;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
139 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
140 if (real_time)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
141 timer = g_timer_new();
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
142 return 1;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
143 }
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 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
146 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
147 EffectPlugin *ep;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
148 if (timer && !started)
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 g_timer_start(timer);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
151 started = TRUE;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
152 }
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 if ((ep = get_current_effect_plugin()) != NULL &&
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
155 effects_enabled() && ep->mod_samples)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
156 ep->mod_samples(&ptr, length, input_format.format,
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
157 input_format.frequency, input_format.channels);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
158
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
159 written += length;
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
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
162 static void null_close(void)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
163 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
164 if (timer)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
165 g_timer_destroy(timer);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
166 timer = NULL;
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
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
169 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
170 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
171 offset_time = time;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
172 written = ((double)time * bps) / 1000;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
173 if (timer)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
174 g_timer_reset(timer);
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
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
177 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
178 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
179 paused = p;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
180 if (!timer)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
181 return;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
182
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
183 if (paused)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
184 g_timer_stop(timer);
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
185 else
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
186 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
187 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
188 g_timer_start(timer);
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
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
192 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
193 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
194 if (timer)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
195 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
196 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
197 }
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
198 else
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
199 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
200 if (!paused)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
201 return 10000;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
202 else
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
203 return 0;
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
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
207 static int null_playing(void)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
208 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
209 if (!timer)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
210 return FALSE;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
211
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
212 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
213 return TRUE;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
214 return FALSE;
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
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
217 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
218 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
219 if (!bps)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
220 return 0;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
221 return ((gint64)written * 1000) / bps;
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
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
224 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
225 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
226 if (!timer)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
227 return null_get_written_time();
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
228
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
229 return ELAPSED_TIME;
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
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
232 OutputPlugin null_op =
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
233 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
234 NULL,
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
235 NULL,
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
236 "Null output " VERSION,
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
237 null_init,
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
238 NULL, /* cleanup */
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
239 null_about,
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
240 null_configure,
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
241 NULL, /* Get volume */
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
242 NULL, /* Set volume */
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
243 null_open,
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
244 null_write,
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
245 null_close,
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
246 null_flush,
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
247 null_pause,
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
248 null_buffer_free,
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
249 null_playing,
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
250 null_get_output_time,
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
251 null_get_written_time,
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
252 NULL /* tell */
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
253 };
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
254
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
255 OutputPlugin *get_oplugin_info(void)
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
256 {
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
257 return &null_op;
5dfc0e491ad3 [svn] Null output plugin added; original code by Christian Birchinger <joker -at- gentoo.org>
kiyoshi
parents:
diff changeset
258 }