Mercurial > audlegacy
annotate Plugins/Input/timidity/src/xmms-timidity.c @ 302:baee45e12cd6 trunk
[svn] Convert to configdb usage.
author | chainsaw |
---|---|
date | Sat, 17 Dec 2005 08:21:58 -0800 |
parents | 4f42c8bcf186 |
children | f0cbbb4071a4 |
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 |
290
5ca6e39394b5
[svn] GThreadify and fix includes. And although it compiles, let us not ship this. No playback at all.
chainsaw
parents:
285
diff
changeset
|
24 #include "libaudacious/util.h" |
302 | 25 #include "libaudacious/configdb.h" |
290
5ca6e39394b5
[svn] GThreadify and fix includes. And although it compiles, let us not ship this. No playback at all.
chainsaw
parents:
285
diff
changeset
|
26 #include "libaudacious/titlestring.h" |
285
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
27 #include <gtk/gtk.h> |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
28 #include <string.h> |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
29 #include <timidity.h> |
292
f99bf98118fc
[svn] How about a default timidity.cfg location that actually works?
chainsaw
parents:
290
diff
changeset
|
30 #include <stdio.h> |
285
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
31 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
32 #include "xmms-timidity.h" |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
33 #include "interface.h" |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
34 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
35 InputPlugin xmmstimid_ip = { |
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 NULL, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
38 NULL, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
39 xmmstimid_init, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
40 xmmstimid_about, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
41 xmmstimid_configure, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
42 xmmstimid_is_our_file, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
43 NULL, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
44 xmmstimid_play_file, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
45 xmmstimid_stop, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
46 xmmstimid_pause, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
47 xmmstimid_seek, |
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 xmmstimid_get_time, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
50 NULL, |
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 xmmstimid_cleanup, |
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 NULL, |
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 xmmstimid_get_song_info, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
58 NULL, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
59 NULL |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
60 }; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
61 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
62 static struct { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
63 gchar *config_file; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
64 gint rate; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
65 gint bits; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
66 gint channels; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
67 gint buffer_size; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
68 } xmmstimid_cfg; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
69 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
70 static gboolean xmmstimid_initialized = FALSE; |
290
5ca6e39394b5
[svn] GThreadify and fix includes. And although it compiles, let us not ship this. No playback at all.
chainsaw
parents:
285
diff
changeset
|
71 static GThread *xmmstimid_decode_thread; |
285
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
72 static gboolean xmmstimid_audio_error = FALSE; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
73 static MidSongOptions xmmstimid_opts; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
74 static MidSong *xmmstimid_song; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
75 static gboolean xmmstimid_going; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
76 static gboolean xmmstimid_eof; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
77 static gint xmmstimid_seek_to; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
78 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
79 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
|
80 static GtkEntry |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
81 *xmmstimid_conf_config_file; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
82 static GtkToggleButton |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
83 *xmmstimid_conf_rate_11000, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
84 *xmmstimid_conf_rate_22000, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
85 *xmmstimid_conf_rate_44100; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
86 static GtkToggleButton |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
87 *xmmstimid_conf_bits_8, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
88 *xmmstimid_conf_bits_16; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
89 static GtkToggleButton |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
90 *xmmstimid_conf_channels_1, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
91 *xmmstimid_conf_channels_2; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
92 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
93 InputPlugin *get_iplugin_info(void) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
94 xmmstimid_ip.description = g_strdup_printf( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
95 "TiMidity Player %s", VERSION); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
96 return &xmmstimid_ip; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
97 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
98 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
99 void xmmstimid_init(void) { |
302 | 100 ConfigDb *db; |
285
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
101 |
302 | 102 xmmstimid_cfg.config_file = g_strdup("/etc/timidity.cfg"); |
285
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
103 xmmstimid_cfg.rate = 44100; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
104 xmmstimid_cfg.bits = 16; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
105 xmmstimid_cfg.channels = 2; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
106 xmmstimid_cfg.buffer_size = 512; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
107 |
302 | 108 db = bmp_cfg_db_open(); |
285
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
109 |
302 | 110 bmp_cfg_db_get_string(db, "timidity", "config_file", &xmmstimid_cfg.config_file); |
111 bmp_cfg_db_get_int(db, "timidity", "samplerate", &xmmstimid_cfg.rate); | |
112 bmp_cfg_db_get_int(db, "timidity", "bits", &xmmstimid_cfg.bits); | |
113 bmp_cfg_db_get_int(db, "timidity", "channels", &xmmstimid_cfg.channels); | |
114 bmp_cfg_db_close(db); | |
285
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
115 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
116 if (mid_init(xmmstimid_cfg.config_file) != 0) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
117 xmmstimid_initialized = FALSE; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
118 return; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
119 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
120 xmmstimid_initialized = TRUE; |
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 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
123 void xmmstimid_about(void) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
124 if (xmmstimid_about_wnd == NULL) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
125 gchar *name_version; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
126 xmmstimid_about_wnd = create_xmmstimid_about_wnd(); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
127 name_version = g_strdup_printf( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
128 "TiMidity Plugin %s", VERSION); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
129 gtk_label_set_text( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
130 GTK_LABEL(gtk_object_get_data( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
131 GTK_OBJECT(xmmstimid_about_wnd), |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
132 "name_version")), name_version); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
133 g_free(name_version); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
134 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
135 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
136 gtk_widget_show(xmmstimid_about_wnd); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
137 gdk_window_raise(xmmstimid_about_wnd->window); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
138 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
139 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
140 void xmmstimid_conf_ok(GtkButton *button, gpointer user_data); |
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 void xmmstimid_configure(void) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
143 GtkToggleButton *tb; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
144 if (xmmstimid_conf_wnd == NULL) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
145 xmmstimid_conf_wnd = create_xmmstimid_conf_wnd(); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
146 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
147 #define get_conf_wnd_item(type, name) \ |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
148 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
|
149 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
150 xmmstimid_conf_config_file = get_conf_wnd_item( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
151 GTK_ENTRY, "config_file"); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
152 xmmstimid_conf_rate_11000 = get_conf_wnd_item( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
153 GTK_TOGGLE_BUTTON, "rate_11000"); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
154 xmmstimid_conf_rate_22000 = get_conf_wnd_item( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
155 GTK_TOGGLE_BUTTON, "rate_22000"); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
156 xmmstimid_conf_rate_44100 = get_conf_wnd_item( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
157 GTK_TOGGLE_BUTTON, "rate_44100"); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
158 xmmstimid_conf_bits_8 = get_conf_wnd_item( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
159 GTK_TOGGLE_BUTTON, "bits_8"); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
160 xmmstimid_conf_bits_16 = get_conf_wnd_item( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
161 GTK_TOGGLE_BUTTON, "bits_16"); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
162 xmmstimid_conf_channels_1 = get_conf_wnd_item( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
163 GTK_TOGGLE_BUTTON, "channels_1"); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
164 xmmstimid_conf_channels_2 = get_conf_wnd_item( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
165 GTK_TOGGLE_BUTTON, "channels_2"); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
166 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
167 gtk_signal_connect_object( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
168 get_conf_wnd_item(GTK_OBJECT, "conf_ok"), |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
169 "clicked", GTK_SIGNAL_FUNC(xmmstimid_conf_ok), |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
170 NULL); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
171 } |
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_entry_set_text(xmmstimid_conf_config_file, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
174 xmmstimid_cfg.config_file); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
175 switch (xmmstimid_cfg.rate) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
176 case 11000: tb = xmmstimid_conf_rate_11000; break; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
177 case 22000: tb = xmmstimid_conf_rate_22000; break; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
178 case 44100: tb = xmmstimid_conf_rate_44100; break; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
179 default: tb = NULL; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
180 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
181 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
|
182 switch (xmmstimid_cfg.bits) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
183 case 8: tb = xmmstimid_conf_bits_8; break; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
184 case 16: tb = xmmstimid_conf_bits_16; 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.channels) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
189 case 1: tb = xmmstimid_conf_channels_1; break; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
190 case 2: tb = xmmstimid_conf_channels_2; 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 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
195 gtk_widget_show(xmmstimid_conf_wnd); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
196 gdk_window_raise(xmmstimid_conf_wnd->window); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
197 } |
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 void xmmstimid_conf_ok(GtkButton *button, gpointer user_data) { |
302 | 200 ConfigDb *db; |
285
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
201 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
202 g_free(xmmstimid_cfg.config_file); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
203 xmmstimid_cfg.config_file = g_strdup( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
204 gtk_entry_get_text(xmmstimid_conf_config_file)); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
205 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
206 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
|
207 xmmstimid_cfg.rate = 11000; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
208 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
|
209 xmmstimid_cfg.rate = 22000; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
210 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
|
211 xmmstimid_cfg.rate = 44100; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
212 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
|
213 xmmstimid_cfg.bits = 8; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
214 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
|
215 xmmstimid_cfg.bits = 16; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
216 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
|
217 xmmstimid_cfg.channels = 1; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
218 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
|
219 xmmstimid_cfg.channels = 2; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
220 |
302 | 221 db = bmp_cfg_db_open(); |
285
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
222 |
302 | 223 bmp_cfg_db_set_string(db, "timidity", "config_file", xmmstimid_cfg.config_file); |
224 bmp_cfg_db_set_int(db, "timidity", "samplerate", xmmstimid_cfg.rate); | |
225 bmp_cfg_db_set_int(db, "timidity", "bits", xmmstimid_cfg.bits); | |
226 bmp_cfg_db_set_int(db, "timidity", "channels", xmmstimid_cfg.channels); | |
227 bmp_cfg_db_close(db); | |
285
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
228 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
229 gtk_widget_hide(xmmstimid_conf_wnd); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
230 } |
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 int xmmstimid_is_our_file(char *filename) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
233 gchar *ext; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
234 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
235 ext = strrchr(filename, '.'); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
236 if (ext && !( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
237 strcasecmp(ext, ".mid") && |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
238 strcasecmp(ext, ".midi"))) return 1; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
239 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
240 return 0; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
241 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
242 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
243 static void *xmmstimid_play_loop(void *arg) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
244 size_t buffer_size; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
245 void *buffer; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
246 size_t bytes_read; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
247 AFormat fmt; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
248 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
249 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
|
250 xmmstimid_opts.channels / 8 * |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
251 xmmstimid_opts.buffer_size; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
252 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
253 buffer = g_malloc(buffer_size); |
290
5ca6e39394b5
[svn] GThreadify and fix includes. And although it compiles, let us not ship this. No playback at all.
chainsaw
parents:
285
diff
changeset
|
254 if (buffer == NULL) g_thread_exit(NULL); |
285
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 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
|
257 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
258 while (xmmstimid_going) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
259 bytes_read = mid_song_read_wave(xmmstimid_song, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
260 buffer, buffer_size); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
261 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
262 if (bytes_read != 0) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
263 xmmstimid_ip.add_vis_pcm( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
264 mid_song_get_time(xmmstimid_song), |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
265 fmt, xmmstimid_opts.channels, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
266 bytes_read, buffer); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
267 else xmmstimid_eof = TRUE; |
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 while (xmmstimid_going && xmmstimid_seek_to == -1 && |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
270 (bytes_read == 0 || |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
271 xmmstimid_ip.output->buffer_free() < bytes_read)) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
272 xmms_usleep(10000); |
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 if (xmmstimid_seek_to != -1) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
275 mid_song_seek(xmmstimid_song, xmmstimid_seek_to * 1000); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
276 xmmstimid_ip.output->flush(xmmstimid_seek_to * 1000); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
277 xmmstimid_seek_to = -1; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
278 bytes_read = 0; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
279 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
280 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
281 if (xmmstimid_going && bytes_read != 0) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
282 xmmstimid_ip.output->write_audio(buffer, bytes_read); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
283 } |
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 g_free(buffer); |
290
5ca6e39394b5
[svn] GThreadify and fix includes. And although it compiles, let us not ship this. No playback at all.
chainsaw
parents:
285
diff
changeset
|
286 g_thread_exit(NULL); |
298 | 287 return(NULL); |
285
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
288 } |
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 static gchar *xmmstimid_get_title(gchar *filename) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
291 TitleInput *input; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
292 gchar *temp, *ext, *title, *path, *temp2; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
293 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
294 input = bmp_title_input_new(); |
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 path = g_strdup(filename); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
297 temp = g_strdup(filename); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
298 ext = strrchr(temp, '.'); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
299 if (ext) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
300 *ext = '\0'; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
301 temp2 = strrchr(path, '/'); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
302 if (temp2) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
303 *temp2 = '\0'; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
304 |
298 | 305 input->file_name = g_path_get_basename(filename); |
285
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
306 input->file_ext = ext ? ext+1 : NULL; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
307 input->file_path = g_strdup_printf("%s/", path); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
308 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
309 title = xmms_get_titlestring(xmms_get_gentitle_format(), input); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
310 if (title == NULL) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
311 title = g_strdup(input->file_name); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
312 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
313 g_free(temp); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
314 g_free(path); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
315 g_free(input); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
316 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
317 return title; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
318 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
319 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
320 void xmmstimid_play_file(char *filename) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
321 MidIStream *stream; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
322 gchar *title; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
323 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
324 if (!xmmstimid_initialized) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
325 xmmstimid_init(); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
326 if (!xmmstimid_initialized) return; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
327 } |
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 if (xmmstimid_song != NULL) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
330 mid_song_free(xmmstimid_song); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
331 xmmstimid_song = NULL; |
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 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
334 stream = mid_istream_open_file(filename); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
335 if (stream == NULL) return; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
336 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
337 xmmstimid_audio_error = FALSE; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
338 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
339 xmmstimid_opts.rate = xmmstimid_cfg.rate; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
340 xmmstimid_opts.format = (xmmstimid_cfg.bits == 16) ? |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
341 MID_AUDIO_S16LSB : MID_AUDIO_S8; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
342 xmmstimid_opts.channels = xmmstimid_cfg.channels; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
343 xmmstimid_opts.buffer_size = xmmstimid_cfg.buffer_size; |
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 xmmstimid_song = mid_song_load(stream, &xmmstimid_opts); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
346 mid_istream_close(stream); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
347 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
348 if (xmmstimid_song == NULL) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
349 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
|
350 return; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
351 } |
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 if (xmmstimid_ip.output->open_audio( |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
354 (xmmstimid_opts.format == MID_AUDIO_S16LSB) ? |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
355 FMT_S16_LE : FMT_S8, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
356 xmmstimid_opts.rate, xmmstimid_opts.channels) == 0) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
357 xmmstimid_audio_error = TRUE; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
358 mid_song_free(xmmstimid_song); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
359 xmmstimid_song = NULL; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
360 return; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
361 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
362 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
363 title = xmmstimid_get_title(filename); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
364 xmmstimid_ip.set_info(title, |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
365 mid_song_get_total_time(xmmstimid_song), |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
366 0, xmmstimid_opts.rate, xmmstimid_opts.channels); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
367 g_free(title); |
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 mid_song_start(xmmstimid_song); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
370 xmmstimid_going = TRUE; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
371 xmmstimid_eof = FALSE; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
372 xmmstimid_seek_to = -1; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
373 |
292
f99bf98118fc
[svn] How about a default timidity.cfg location that actually works?
chainsaw
parents:
290
diff
changeset
|
374 xmmstimid_decode_thread = g_thread_create((GThreadFunc)xmmstimid_play_loop, NULL, TRUE, NULL); |
290
5ca6e39394b5
[svn] GThreadify and fix includes. And although it compiles, let us not ship this. No playback at all.
chainsaw
parents:
285
diff
changeset
|
375 if (xmmstimid_decode_thread == NULL) { |
285
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
376 mid_song_free(xmmstimid_song); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
377 xmmstimid_stop(); |
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 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
380 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
381 void xmmstimid_stop(void) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
382 if (xmmstimid_song != NULL && xmmstimid_going) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
383 xmmstimid_going = FALSE; |
290
5ca6e39394b5
[svn] GThreadify and fix includes. And although it compiles, let us not ship this. No playback at all.
chainsaw
parents:
285
diff
changeset
|
384 g_thread_join(xmmstimid_decode_thread); |
285
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
385 xmmstimid_ip.output->close_audio(); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
386 mid_song_free(xmmstimid_song); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
387 xmmstimid_song = NULL; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
388 } |
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 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
391 void xmmstimid_pause(short p) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
392 xmmstimid_ip.output->pause(p); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
393 } |
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 void xmmstimid_seek(int time) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
396 xmmstimid_seek_to = time; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
397 xmmstimid_eof = FALSE; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
398 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
399 while (xmmstimid_seek_to != -1) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
400 xmms_usleep(10000); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
401 } |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
402 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
403 int xmmstimid_get_time(void) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
404 if (xmmstimid_audio_error) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
405 return -2; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
406 if (xmmstimid_song == NULL) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
407 return -1; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
408 if (!xmmstimid_going || (xmmstimid_eof && |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
409 xmmstimid_ip.output->buffer_playing())) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
410 return -1; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
411 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
412 return mid_song_get_time(xmmstimid_song); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
413 } |
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 void xmmstimid_cleanup(void) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
416 if (xmmstimid_initialized) |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
417 mid_exit(); |
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 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
420 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
|
421 MidIStream *stream; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
422 MidSongOptions opts; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
423 MidSong *song; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
424 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
425 if (!xmmstimid_initialized) { |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
426 xmmstimid_init(); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
427 if (!xmmstimid_initialized) return; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
428 } |
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 stream = mid_istream_open_file(filename); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
431 if (stream == NULL) return; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
432 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
433 opts.rate = xmmstimid_cfg.rate; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
434 opts.format = (xmmstimid_cfg.bits == 16) ? |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
435 MID_AUDIO_S16LSB : MID_AUDIO_S8; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
436 opts.channels = xmmstimid_cfg.channels; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
437 opts.buffer_size = 8; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
438 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
439 song = mid_song_load(stream, &opts); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
440 mid_istream_close(stream); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
441 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
442 if (song == NULL) return; |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
443 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
444 *length = mid_song_get_total_time(song); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
445 *title = xmmstimid_get_title(filename); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
446 |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
447 mid_song_free(song); |
d1762728ea4b
[svn] Timidity support, via external contractor dai+audacious@cdr.jp.
nenolod
parents:
diff
changeset
|
448 } |