Mercurial > audlegacy
annotate Plugins/Input/timidity/src/xmms-timidity.c @ 285:d1762728ea4b trunk
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
author | nenolod |
---|---|
date | Wed, 14 Dec 2005 08:51:51 -0800 |
parents | |
children | 5ca6e39394b5 |
rev | line source |
---|---|
285
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
1 /* |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
2 xmms-timidity - MIDI Plugin for XMMS |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
3 Copyright (C) 2004 Konstantin Korikov <lostclus@ua.fm> |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
4 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
5 This program is free software; you can redistribute it and/or modify |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
6 it under the terms of the GNU General Public License as published by |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
7 the Free Software Foundation; either version 2 of the License, or |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
8 (at your option) any later version. |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
9 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
10 This program is distributed in the hope that it will be useful, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
13 GNU General Public License for more details. |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
14 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
15 You should have received a copy of the GNU General Public License |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
16 along with this program; if not, write to the Free Software |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
18 */ |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
19 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
20 #ifdef HAVE_CONFIG_H |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
21 #include <config.h> |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
22 #endif |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
23 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
24 #include <audacious/configfile.h> |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
25 #include <audacious/titlestring.h> |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
26 #include <gtk/gtk.h> |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
27 #include <string.h> |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
28 #include <timidity.h> |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
29 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
30 #include "xmms-timidity.h" |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
31 #include "interface.h" |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
32 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
33 InputPlugin xmmstimid_ip = { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
34 NULL, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
35 NULL, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
36 NULL, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
37 xmmstimid_init, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
38 xmmstimid_about, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
39 xmmstimid_configure, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
40 xmmstimid_is_our_file, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
41 NULL, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
42 xmmstimid_play_file, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
43 xmmstimid_stop, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
44 xmmstimid_pause, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
45 xmmstimid_seek, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
46 NULL, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
47 xmmstimid_get_time, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
48 NULL, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
49 NULL, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
50 xmmstimid_cleanup, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
51 NULL, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
52 NULL, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
53 NULL, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
54 NULL, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
55 xmmstimid_get_song_info, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
56 NULL, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
57 NULL |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
58 }; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
59 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
60 static struct { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
61 gchar *config_file; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
62 gint rate; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
63 gint bits; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
64 gint channels; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
65 gint buffer_size; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
66 } xmmstimid_cfg; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
67 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
68 static gboolean xmmstimid_initialized = FALSE; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
69 static pthread_t xmmstimid_decode_thread; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
70 static gboolean xmmstimid_audio_error = FALSE; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
71 static MidSongOptions xmmstimid_opts; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
72 static MidSong *xmmstimid_song; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
73 static gboolean xmmstimid_going; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
74 static gboolean xmmstimid_eof; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
75 static gint xmmstimid_seek_to; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
76 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
77 static GtkWidget *xmmstimid_conf_wnd = NULL, *xmmstimid_about_wnd = NULL; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
78 static GtkEntry |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
79 *xmmstimid_conf_config_file; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
80 static GtkToggleButton |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
81 *xmmstimid_conf_rate_11000, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
82 *xmmstimid_conf_rate_22000, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
83 *xmmstimid_conf_rate_44100; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
84 static GtkToggleButton |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
85 *xmmstimid_conf_bits_8, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
86 *xmmstimid_conf_bits_16; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
87 static GtkToggleButton |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
88 *xmmstimid_conf_channels_1, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
89 *xmmstimid_conf_channels_2; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
90 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
91 InputPlugin *get_iplugin_info(void) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
92 xmmstimid_ip.description = g_strdup_printf( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
93 "TiMidity Player %s", VERSION); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
94 return &xmmstimid_ip; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
95 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
96 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
97 void xmmstimid_init(void) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
98 ConfigFile *cf; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
99 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
100 xmmstimid_cfg.config_file = NULL; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
101 xmmstimid_cfg.rate = 44100; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
102 xmmstimid_cfg.bits = 16; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
103 xmmstimid_cfg.channels = 2; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
104 xmmstimid_cfg.buffer_size = 512; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
105 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
106 cf = xmms_cfg_open_default_file(); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
107 if (cf != NULL) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
108 xmms_cfg_read_string(cf, "TIMIDITY", "config_file", |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
109 &xmmstimid_cfg.config_file); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
110 xmms_cfg_read_int(cf, "TIMIDITY", "rate", |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
111 &xmmstimid_cfg.rate); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
112 xmms_cfg_read_int(cf, "TIMIDITY", "bits", |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
113 &xmmstimid_cfg.bits); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
114 xmms_cfg_read_int(cf, "TIMIDITY", "channels", |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
115 &xmmstimid_cfg.channels); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
116 xmms_cfg_free(cf); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
117 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
118 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
119 if (xmmstimid_cfg.config_file == NULL) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
120 xmmstimid_cfg.config_file = g_strdup("/etc/timidity/timidity.cfg"); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
121 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
122 if (mid_init(xmmstimid_cfg.config_file) != 0) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
123 xmmstimid_initialized = FALSE; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
124 return; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
125 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
126 xmmstimid_initialized = TRUE; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
127 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
128 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
129 void xmmstimid_about(void) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
130 if (xmmstimid_about_wnd == NULL) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
131 gchar *name_version; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
132 xmmstimid_about_wnd = create_xmmstimid_about_wnd(); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
133 name_version = g_strdup_printf( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
134 "TiMidity Plugin %s", VERSION); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
135 gtk_label_set_text( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
136 GTK_LABEL(gtk_object_get_data( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
137 GTK_OBJECT(xmmstimid_about_wnd), |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
138 "name_version")), name_version); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
139 g_free(name_version); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
140 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
141 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
142 gtk_widget_show(xmmstimid_about_wnd); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
143 gdk_window_raise(xmmstimid_about_wnd->window); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
144 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
145 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
146 void xmmstimid_conf_ok(GtkButton *button, gpointer user_data); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
147 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
148 void xmmstimid_configure(void) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
149 GtkToggleButton *tb; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
150 if (xmmstimid_conf_wnd == NULL) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
151 xmmstimid_conf_wnd = create_xmmstimid_conf_wnd(); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
152 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
153 #define get_conf_wnd_item(type, name) \ |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
154 type (gtk_object_get_data(GTK_OBJECT(xmmstimid_conf_wnd), name)) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
155 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
156 xmmstimid_conf_config_file = get_conf_wnd_item( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
157 GTK_ENTRY, "config_file"); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
158 xmmstimid_conf_rate_11000 = get_conf_wnd_item( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
159 GTK_TOGGLE_BUTTON, "rate_11000"); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
160 xmmstimid_conf_rate_22000 = get_conf_wnd_item( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
161 GTK_TOGGLE_BUTTON, "rate_22000"); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
162 xmmstimid_conf_rate_44100 = get_conf_wnd_item( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
163 GTK_TOGGLE_BUTTON, "rate_44100"); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
164 xmmstimid_conf_bits_8 = get_conf_wnd_item( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
165 GTK_TOGGLE_BUTTON, "bits_8"); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
166 xmmstimid_conf_bits_16 = get_conf_wnd_item( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
167 GTK_TOGGLE_BUTTON, "bits_16"); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
168 xmmstimid_conf_channels_1 = get_conf_wnd_item( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
169 GTK_TOGGLE_BUTTON, "channels_1"); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
170 xmmstimid_conf_channels_2 = get_conf_wnd_item( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
171 GTK_TOGGLE_BUTTON, "channels_2"); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
172 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
173 gtk_signal_connect_object( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
174 get_conf_wnd_item(GTK_OBJECT, "conf_ok"), |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
175 "clicked", GTK_SIGNAL_FUNC(xmmstimid_conf_ok), |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
176 NULL); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
177 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
178 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
179 gtk_entry_set_text(xmmstimid_conf_config_file, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
180 xmmstimid_cfg.config_file); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
181 switch (xmmstimid_cfg.rate) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
182 case 11000: tb = xmmstimid_conf_rate_11000; break; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
183 case 22000: tb = xmmstimid_conf_rate_22000; break; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
184 case 44100: tb = xmmstimid_conf_rate_44100; break; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
185 default: tb = NULL; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
186 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
187 if (tb != NULL) gtk_toggle_button_set_active(tb, TRUE); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
188 switch (xmmstimid_cfg.bits) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
189 case 8: tb = xmmstimid_conf_bits_8; break; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
190 case 16: tb = xmmstimid_conf_bits_16; break; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
191 default: tb = NULL; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
192 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
193 if (tb != NULL) gtk_toggle_button_set_active(tb, TRUE); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
194 switch (xmmstimid_cfg.channels) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
195 case 1: tb = xmmstimid_conf_channels_1; break; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
196 case 2: tb = xmmstimid_conf_channels_2; break; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
197 default: tb = NULL; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
198 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
199 if (tb != NULL) gtk_toggle_button_set_active(tb, TRUE); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
200 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
201 gtk_widget_show(xmmstimid_conf_wnd); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
202 gdk_window_raise(xmmstimid_conf_wnd->window); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
203 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
204 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
205 void xmmstimid_conf_ok(GtkButton *button, gpointer user_data) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
206 gchar *config_file, *filename; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
207 ConfigFile *cf; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
208 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
209 g_free(xmmstimid_cfg.config_file); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
210 xmmstimid_cfg.config_file = g_strdup( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
211 gtk_entry_get_text(xmmstimid_conf_config_file)); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
212 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
213 if (gtk_toggle_button_get_active(xmmstimid_conf_rate_11000)) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
214 xmmstimid_cfg.rate = 11000; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
215 else if (gtk_toggle_button_get_active(xmmstimid_conf_rate_22000)) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
216 xmmstimid_cfg.rate = 22000; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
217 else if (gtk_toggle_button_get_active(xmmstimid_conf_rate_44100)) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
218 xmmstimid_cfg.rate = 44100; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
219 if (gtk_toggle_button_get_active(xmmstimid_conf_bits_8)) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
220 xmmstimid_cfg.bits = 8; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
221 else if (gtk_toggle_button_get_active(xmmstimid_conf_bits_16)) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
222 xmmstimid_cfg.bits = 16; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
223 if (gtk_toggle_button_get_active(xmmstimid_conf_channels_1)) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
224 xmmstimid_cfg.channels = 1; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
225 else if (gtk_toggle_button_get_active(xmmstimid_conf_channels_2)) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
226 xmmstimid_cfg.channels = 2; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
227 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
228 filename = g_strconcat(g_get_home_dir(), "/.audacious/config", NULL); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
229 cf = xmms_cfg_open_file(filename); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
230 if (cf == NULL) cf = xmms_cfg_new(); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
231 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
232 xmms_cfg_write_string(cf, "TIMIDITY", "config_file", |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
233 xmmstimid_cfg.config_file); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
234 xmms_cfg_write_int(cf, "TIMIDITY", "rate", |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
235 xmmstimid_cfg.rate); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
236 xmms_cfg_write_int(cf, "TIMIDITY", "bits", |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
237 xmmstimid_cfg.bits); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
238 xmms_cfg_write_int(cf, "TIMIDITY", "channels", |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
239 xmmstimid_cfg.channels); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
240 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
241 xmms_cfg_write_file(cf, filename); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
242 xmms_cfg_free(cf); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
243 g_free(filename); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
244 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
245 gtk_widget_hide(xmmstimid_conf_wnd); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
246 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
247 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
248 int xmmstimid_is_our_file(char *filename) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
249 gchar *ext; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
250 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
251 ext = strrchr(filename, '.'); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
252 if (ext && !( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
253 strcasecmp(ext, ".mid") && |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
254 strcasecmp(ext, ".midi"))) return 1; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
255 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
256 return 0; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
257 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
258 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
259 static void *xmmstimid_play_loop(void *arg) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
260 size_t buffer_size; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
261 void *buffer; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
262 size_t bytes_read; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
263 AFormat fmt; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
264 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
265 buffer_size = ((xmmstimid_opts.format == MID_AUDIO_S16LSB) ? 16 : 8) * |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
266 xmmstimid_opts.channels / 8 * |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
267 xmmstimid_opts.buffer_size; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
268 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
269 buffer = g_malloc(buffer_size); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
270 if (buffer == NULL) pthread_exit(NULL); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
271 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
272 fmt = (xmmstimid_opts.format == MID_AUDIO_S16LSB) ? FMT_S16_LE : FMT_S8; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
273 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
274 while (xmmstimid_going) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
275 bytes_read = mid_song_read_wave(xmmstimid_song, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
276 buffer, buffer_size); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
277 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
278 if (bytes_read != 0) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
279 xmmstimid_ip.add_vis_pcm( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
280 mid_song_get_time(xmmstimid_song), |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
281 fmt, xmmstimid_opts.channels, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
282 bytes_read, buffer); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
283 else xmmstimid_eof = TRUE; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
284 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
285 while (xmmstimid_going && xmmstimid_seek_to == -1 && |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
286 (bytes_read == 0 || |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
287 xmmstimid_ip.output->buffer_free() < bytes_read)) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
288 xmms_usleep(10000); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
289 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
290 if (xmmstimid_seek_to != -1) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
291 mid_song_seek(xmmstimid_song, xmmstimid_seek_to * 1000); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
292 xmmstimid_ip.output->flush(xmmstimid_seek_to * 1000); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
293 xmmstimid_seek_to = -1; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
294 bytes_read = 0; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
295 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
296 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
297 if (xmmstimid_going && bytes_read != 0) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
298 xmmstimid_ip.output->write_audio(buffer, bytes_read); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
299 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
300 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
301 g_free(buffer); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
302 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
303 pthread_exit(NULL); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
304 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
305 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
306 static gchar *xmmstimid_get_title(gchar *filename) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
307 TitleInput *input; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
308 gchar *temp, *ext, *title, *path, *temp2; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
309 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
310 input = bmp_title_input_new(); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
311 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
312 path = g_strdup(filename); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
313 temp = g_strdup(filename); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
314 ext = strrchr(temp, '.'); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
315 if (ext) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
316 *ext = '\0'; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
317 temp2 = strrchr(path, '/'); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
318 if (temp2) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
319 *temp2 = '\0'; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
320 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
321 input->file_name = g_basename(filename); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
322 input->file_ext = ext ? ext+1 : NULL; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
323 input->file_path = g_strdup_printf("%s/", path); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
324 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
325 title = xmms_get_titlestring(xmms_get_gentitle_format(), input); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
326 if (title == NULL) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
327 title = g_strdup(input->file_name); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
328 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
329 g_free(temp); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
330 g_free(path); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
331 g_free(input); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
332 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
333 return title; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
334 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
335 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
336 void xmmstimid_play_file(char *filename) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
337 MidIStream *stream; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
338 gchar *title; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
339 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
340 if (!xmmstimid_initialized) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
341 xmmstimid_init(); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
342 if (!xmmstimid_initialized) return; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
343 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
344 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
345 if (xmmstimid_song != NULL) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
346 mid_song_free(xmmstimid_song); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
347 xmmstimid_song = NULL; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
348 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
349 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
350 stream = mid_istream_open_file(filename); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
351 if (stream == NULL) return; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
352 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
353 xmmstimid_audio_error = FALSE; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
354 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
355 xmmstimid_opts.rate = xmmstimid_cfg.rate; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
356 xmmstimid_opts.format = (xmmstimid_cfg.bits == 16) ? |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
357 MID_AUDIO_S16LSB : MID_AUDIO_S8; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
358 xmmstimid_opts.channels = xmmstimid_cfg.channels; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
359 xmmstimid_opts.buffer_size = xmmstimid_cfg.buffer_size; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
360 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
361 xmmstimid_song = mid_song_load(stream, &xmmstimid_opts); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
362 mid_istream_close(stream); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
363 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
364 if (xmmstimid_song == NULL) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
365 xmmstimid_ip.set_info_text("Couldn't load MIDI file"); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
366 return; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
367 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
368 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
369 if (xmmstimid_ip.output->open_audio( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
370 (xmmstimid_opts.format == MID_AUDIO_S16LSB) ? |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
371 FMT_S16_LE : FMT_S8, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
372 xmmstimid_opts.rate, xmmstimid_opts.channels) == 0) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
373 xmmstimid_audio_error = TRUE; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
374 mid_song_free(xmmstimid_song); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
375 xmmstimid_song = NULL; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
376 return; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
377 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
378 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
379 title = xmmstimid_get_title(filename); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
380 xmmstimid_ip.set_info(title, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
381 mid_song_get_total_time(xmmstimid_song), |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
382 0, xmmstimid_opts.rate, xmmstimid_opts.channels); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
383 g_free(title); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
384 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
385 mid_song_start(xmmstimid_song); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
386 xmmstimid_going = TRUE; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
387 xmmstimid_eof = FALSE; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
388 xmmstimid_seek_to = -1; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
389 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
390 if (pthread_create(&xmmstimid_decode_thread, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
391 NULL, xmmstimid_play_loop, NULL) != 0) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
392 mid_song_free(xmmstimid_song); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
393 xmmstimid_stop(); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
394 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
395 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
396 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
397 void xmmstimid_stop(void) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
398 if (xmmstimid_song != NULL && xmmstimid_going) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
399 xmmstimid_going = FALSE; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
400 pthread_join(xmmstimid_decode_thread, NULL); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
401 xmmstimid_ip.output->close_audio(); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
402 mid_song_free(xmmstimid_song); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
403 xmmstimid_song = NULL; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
404 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
405 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
406 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
407 void xmmstimid_pause(short p) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
408 xmmstimid_ip.output->pause(p); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
409 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
410 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
411 void xmmstimid_seek(int time) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
412 xmmstimid_seek_to = time; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
413 xmmstimid_eof = FALSE; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
414 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
415 while (xmmstimid_seek_to != -1) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
416 xmms_usleep(10000); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
417 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
418 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
419 int xmmstimid_get_time(void) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
420 if (xmmstimid_audio_error) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
421 return -2; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
422 if (xmmstimid_song == NULL) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
423 return -1; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
424 if (!xmmstimid_going || (xmmstimid_eof && |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
425 xmmstimid_ip.output->buffer_playing())) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
426 return -1; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
427 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
428 return mid_song_get_time(xmmstimid_song); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
429 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
430 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
431 void xmmstimid_cleanup(void) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
432 if (xmmstimid_initialized) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
433 mid_exit(); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
434 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
435 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
436 void xmmstimid_get_song_info(char *filename, char **title, int *length) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
437 MidIStream *stream; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
438 MidSongOptions opts; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
439 MidSong *song; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
440 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
441 if (!xmmstimid_initialized) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
442 xmmstimid_init(); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
443 if (!xmmstimid_initialized) return; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
444 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
445 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
446 stream = mid_istream_open_file(filename); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
447 if (stream == NULL) return; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
448 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
449 opts.rate = xmmstimid_cfg.rate; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
450 opts.format = (xmmstimid_cfg.bits == 16) ? |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
451 MID_AUDIO_S16LSB : MID_AUDIO_S8; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
452 opts.channels = xmmstimid_cfg.channels; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
453 opts.buffer_size = 8; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
454 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
455 song = mid_song_load(stream, &opts); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
456 mid_istream_close(stream); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
457 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
458 if (song == NULL) return; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
459 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
460 *length = mid_song_get_total_time(song); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
461 *title = xmmstimid_get_title(filename); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
462 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
463 mid_song_free(song); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
464 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
465 |