annotate src/madplug/plugin.c @ 2201:df520f828dcf

Say goodbye to custom fileinfo dialog in madplug
author Eugene Zagidullin <e.asphyx@gmail.com>
date Sat, 01 Dec 2007 05:15:43 +0300
parents 2f7eff0bc6eb
children f76e846d53d9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
1 /*
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
2 * mad plugin for audacious
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
3 * Copyright (C) 2005-2007 William Pitcock, Yoshiki Yazawa
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
4 *
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
5 * Portions derived from xmms-mad:
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
6 * Copyright (C) 2001-2002 Sam Clegg - See COPYING
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
7 *
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
10 * the Free Software Foundation; under version 2 of the License.
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
11 *
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
15 * GNU General Public License for more details.
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
16 *
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
20 */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
21
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
22 #include "config.h"
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
23 #include "plugin.h"
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
24 #include "input.h"
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
25
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
26 #include <math.h>
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
27
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
28 #include <gtk/gtk.h>
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
29 #include <audacious/util.h>
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
30 #include <audacious/configdb.h>
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
31 #include <stdarg.h>
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
32 #include <fcntl.h>
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
33 #include <audacious/vfs.h>
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
34 #include <sys/stat.h>
922
7e14701aef54 [svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents: 916
diff changeset
35 #include "SFMT.h"
2201
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2153
diff changeset
36 #include "tuples.h"
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
37
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
38 /*
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
39 * Global variables
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
40 */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
41 struct audmad_config_t audmad_config; /**< global configuration */
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
42 GMutex *mad_mutex;
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
43 GMutex *pb_mutex;
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
44 GCond *mad_cond;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
45
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
46 /*
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
47 * static variables
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
48 */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
49 static GThread *decode_thread; /**< the single decoder thread */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
50 static struct mad_info_t info; /**< info for current track */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
51
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
52 #ifndef NOGUI
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
53 static GtkWidget *error_dialog = 0;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
54 #endif
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
55
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
56 extern gboolean scan_file(struct mad_info_t *info, gboolean fast);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
57
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
58 static gint mp3_bitrate_table[5][16] = {
1361
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
59 { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, -1 }, /* MPEG1 L1 */
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
60 { 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, -1 }, /* MPEG1 L2 */
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
61 { 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1 }, /* MPEG1 L3 */
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
62 { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, -1 }, /* MPEG2(.5) L1 */
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
63 { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, -1 } /* MPEG2(.5) L2,L3 */
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
64 };
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
65
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
66 static gint mp3_samplerate_table[4][4] = {
1361
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
67 { 11025, 12000, 8000, -1 }, /* MPEG2.5 */
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
68 { -1, -1, -1, -1 }, /* Reserved */
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
69 { 22050, 24000, 16000, -1 }, /* MPEG2 */
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
70 { 44100, 48000, 32000, -1 } /* MPEG1 */
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
71 };
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
72
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
73 /*
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
74 * Function extname (filename)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
75 *
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
76 * Return pointer within filename to its extenstion, or NULL if
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
77 * filename has no extension.
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
78 *
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
79 */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
80 static gchar *extname(const char *filename)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
81 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
82 gchar *ext = strrchr(filename, '.');
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
83
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
84 if (ext != NULL)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
85 ++ext;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
86
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
87 return ext;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
88 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
89
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
90
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
91 void audmad_config_compute(struct audmad_config_t *config)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
92 {
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
93 /* set some config parameters by parsing text fields
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
94 (RG default gain, etc..)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
95 */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
96 const gchar *text;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
97 gdouble x;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
98
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
99 text = config->pregain_db;
653
638b290641f3 [svn] - madplug: check that text is not null before using g_strtod
giacomo
parents: 651
diff changeset
100 if ( text != NULL )
638b290641f3 [svn] - madplug: check that text is not null before using g_strtod
giacomo
parents: 651
diff changeset
101 x = g_strtod(text, NULL);
638b290641f3 [svn] - madplug: check that text is not null before using g_strtod
giacomo
parents: 651
diff changeset
102 else
638b290641f3 [svn] - madplug: check that text is not null before using g_strtod
giacomo
parents: 651
diff changeset
103 x = 0;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
104 config->pregain_scale = (x != 0) ? pow(10.0, x / 20) : 1;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
105 #ifdef DEBUG
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
106 g_message("pregain=[%s] -> %g -> %g", text, x, config->pregain_scale);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
107 #endif
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
108 text = config->replaygain.default_db;
653
638b290641f3 [svn] - madplug: check that text is not null before using g_strtod
giacomo
parents: 651
diff changeset
109 if ( text != NULL )
638b290641f3 [svn] - madplug: check that text is not null before using g_strtod
giacomo
parents: 651
diff changeset
110 x = g_strtod(text, NULL);
638b290641f3 [svn] - madplug: check that text is not null before using g_strtod
giacomo
parents: 651
diff changeset
111 else
638b290641f3 [svn] - madplug: check that text is not null before using g_strtod
giacomo
parents: 651
diff changeset
112 x = 0;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
113 config->replaygain.default_scale = (x != 0) ? pow(10.0, x / 20) : 1;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
114 #ifdef DEBUG
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
115 g_message("RG.default=[%s] -> %g -> %g", text, x,
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
116 config->replaygain.default_scale);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
117 #endif
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
118 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
119
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
120 static void audmad_init()
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
121 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
122 ConfigDb *db = NULL;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
123
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
124 audmad_config.fast_play_time_calc = TRUE;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
125 audmad_config.use_xing = TRUE;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
126 audmad_config.dither = TRUE;
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
127 audmad_config.sjis = FALSE;
651
b9167008fc3f [svn] - strings in audmad_config should be freed before update. thus constant initializer has been replaced with g_strdup().
yaz
parents: 650
diff changeset
128 audmad_config.hard_limit = FALSE;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
129 audmad_config.replaygain.enable = TRUE;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
130 audmad_config.replaygain.track_mode = FALSE;
651
b9167008fc3f [svn] - strings in audmad_config should be freed before update. thus constant initializer has been replaced with g_strdup().
yaz
parents: 650
diff changeset
131 audmad_config.title_override = FALSE;
676
1733b12ef974 [svn] - show dynamic bitrate for vbr is off by default. now it is configurable from preferences.
yaz
parents: 674
diff changeset
132 audmad_config.show_avg_vbr_bitrate = TRUE;
916
a8494c2a87eb [svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
yaz
parents: 897
diff changeset
133 audmad_config.force_reopen_audio = FALSE;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
134
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
135 db = aud_cfg_db_open();
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
136 if (db) {
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
137 aud_cfg_db_get_bool(db, "MAD", "fast_play_time_calc",
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
138 &audmad_config.fast_play_time_calc);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
139 aud_cfg_db_get_bool(db, "MAD", "use_xing",
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
140 &audmad_config.use_xing);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
141 aud_cfg_db_get_bool(db, "MAD", "dither", &audmad_config.dither);
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
142 aud_cfg_db_get_bool(db, "MAD", "sjis", &audmad_config.sjis);
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
143 aud_cfg_db_get_bool(db, "MAD", "hard_limit",
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
144 &audmad_config.hard_limit);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
145 aud_cfg_db_get_string(db, "MAD", "pregain_db",
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
146 &audmad_config.pregain_db);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
147 aud_cfg_db_get_bool(db, "MAD", "RG.enable",
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
148 &audmad_config.replaygain.enable);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
149 aud_cfg_db_get_bool(db, "MAD", "RG.track_mode",
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
150 &audmad_config.replaygain.track_mode);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
151 aud_cfg_db_get_string(db, "MAD", "RG.default_db",
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
152 &audmad_config.replaygain.default_db);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
153 aud_cfg_db_get_bool(db, "MAD", "title_override",
618
a7a28782c1b0 [svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents: 613
diff changeset
154 &audmad_config.title_override);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
155 aud_cfg_db_get_string(db, "MAD", "id3_format",
618
a7a28782c1b0 [svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents: 613
diff changeset
156 &audmad_config.id3_format);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
157 aud_cfg_db_get_bool(db, "MAD", "show_avg_vbr_bitrate",
676
1733b12ef974 [svn] - show dynamic bitrate for vbr is off by default. now it is configurable from preferences.
yaz
parents: 674
diff changeset
158 &audmad_config.show_avg_vbr_bitrate);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
159 aud_cfg_db_get_bool(db, "MAD", "force_reopen_audio",
916
a8494c2a87eb [svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
yaz
parents: 897
diff changeset
160 &audmad_config.force_reopen_audio);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
161
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
162 aud_cfg_db_close(db);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
163 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
164
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
165 mad_mutex = g_mutex_new();
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
166 pb_mutex = g_mutex_new();
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
167 mad_cond = g_cond_new();
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
168 audmad_config_compute(&audmad_config);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
169
651
b9167008fc3f [svn] - strings in audmad_config should be freed before update. thus constant initializer has been replaced with g_strdup().
yaz
parents: 650
diff changeset
170 if (!audmad_config.pregain_db)
b9167008fc3f [svn] - strings in audmad_config should be freed before update. thus constant initializer has been replaced with g_strdup().
yaz
parents: 650
diff changeset
171 audmad_config.pregain_db = g_strdup("+0.00");
b9167008fc3f [svn] - strings in audmad_config should be freed before update. thus constant initializer has been replaced with g_strdup().
yaz
parents: 650
diff changeset
172
b9167008fc3f [svn] - strings in audmad_config should be freed before update. thus constant initializer has been replaced with g_strdup().
yaz
parents: 650
diff changeset
173 if (!audmad_config.replaygain.default_db)
b9167008fc3f [svn] - strings in audmad_config should be freed before update. thus constant initializer has been replaced with g_strdup().
yaz
parents: 650
diff changeset
174 audmad_config.replaygain.default_db = g_strdup("-9.00");
b9167008fc3f [svn] - strings in audmad_config should be freed before update. thus constant initializer has been replaced with g_strdup().
yaz
parents: 650
diff changeset
175
b9167008fc3f [svn] - strings in audmad_config should be freed before update. thus constant initializer has been replaced with g_strdup().
yaz
parents: 650
diff changeset
176 if (!audmad_config.id3_format)
650
8b9ef7a32e47 [svn] - make sure audmad_config.id3_format is not NULL. closes #795.
nenolod
parents: 646
diff changeset
177 audmad_config.id3_format = g_strdup("");
922
7e14701aef54 [svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents: 916
diff changeset
178
7e14701aef54 [svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents: 916
diff changeset
179 init_gen_rand(4357);
7e14701aef54 [svn] - replace random number generator in dithering code with SIMD-oriented Fast Mersenne Twister (SFMT). it reduces CPU load on SSE2 or AltiVec capable platform.
yaz
parents: 916
diff changeset
180
1995
47a7b26717d4 wow, only one plugin uses aud_mime API. that sucks! :D
William Pitcock <nenolod@atheme.org>
parents: 1979
diff changeset
181 aud_mime_set_plugin("audio/mpeg", mad_plugin);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
182 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
183
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
184 static void audmad_cleanup()
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
185 {
802
7ac48f3855b1 [svn] - add cleanup code.
yaz
parents: 801
diff changeset
186 g_free(audmad_config.pregain_db);
7ac48f3855b1 [svn] - add cleanup code.
yaz
parents: 801
diff changeset
187 g_free(audmad_config.replaygain.default_db);
7ac48f3855b1 [svn] - add cleanup code.
yaz
parents: 801
diff changeset
188 g_free(audmad_config.id3_format);
7ac48f3855b1 [svn] - add cleanup code.
yaz
parents: 801
diff changeset
189
1361
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
190 audmad_config.pregain_db = NULL;
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
191 audmad_config.replaygain.default_db = NULL;
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
192 audmad_config.id3_format = NULL;
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
193
802
7ac48f3855b1 [svn] - add cleanup code.
yaz
parents: 801
diff changeset
194 g_cond_free(mad_cond);
7ac48f3855b1 [svn] - add cleanup code.
yaz
parents: 801
diff changeset
195 g_mutex_free(mad_mutex);
7ac48f3855b1 [svn] - add cleanup code.
yaz
parents: 801
diff changeset
196 g_mutex_free(pb_mutex);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
197 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
198
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
199 static gboolean mp3_head_check(guint32 head, gint *frameSize)
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
200 {
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
201 gint version, layer, bitIndex, bitRate, sampleIndex, sampleRate, padding;
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
202
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
203 /* http://www.mp3-tech.org/programmer/frame_header.html
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
204 * Bits 21-31 must be set (frame sync)
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
205 */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
206 if ((head & 0xffe00000) != 0xffe00000)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
207 return FALSE;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
208
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
209 /* check if layer bits (17-18) are good */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
210 layer = (head >> 17) & 0x3;
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
211 if (!layer)
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
212 return FALSE; /* 00 = reserved */
897
44a922a4a591 [svn] - fix validation of mpeg2 files, by ccr.
nenolod
parents: 807
diff changeset
213 layer = 4 - layer;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
214
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
215 /* check if bitrate index bits (12-15) are acceptable */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
216 bitIndex = (head >> 12) & 0xf;
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
217
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
218 /* 1111 and 0000 are reserved values for all layers */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
219 if (bitIndex == 0xf || bitIndex == 0)
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
220 return FALSE;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
221
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
222 /* check samplerate index bits (10-11) */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
223 sampleIndex = (head >> 10) & 0x3;
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
224 if (sampleIndex == 0x3)
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
225 return FALSE;
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
226
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
227 /* check version bits (19-20) and get bitRate */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
228 version = (head >> 19) & 0x03;
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
229 switch (version) {
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
230 case 0: /* 00 = MPEG Version 2.5 */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
231 case 2: /* 10 = MPEG Version 2 */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
232 if (layer == 1)
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
233 bitRate = mp3_bitrate_table[3][bitIndex];
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
234 else
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
235 bitRate = mp3_bitrate_table[4][bitIndex];
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
236 break;
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
237
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
238 case 1: /* 01 = reserved */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
239 return FALSE;
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
240
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
241 case 3: /* 11 = MPEG Version 1 */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
242 bitRate = mp3_bitrate_table[layer][bitIndex];
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
243 break;
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
244
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
245 default:
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
246 return FALSE;
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
247 }
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
248
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
249 /* check layer II restrictions vs. bitrate */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
250 if (layer == 2) {
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
251 gint chanMode = (head >> 6) & 0x3;
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
252
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
253 if (chanMode == 0x3) {
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
254 /* single channel with bitrate > 192 */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
255 if (bitRate > 192)
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
256 return FALSE;
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
257 } else {
897
44a922a4a591 [svn] - fix validation of mpeg2 files, by ccr.
nenolod
parents: 807
diff changeset
258 /* any other mode with bitrates 32-56 and 80.
44a922a4a591 [svn] - fix validation of mpeg2 files, by ccr.
nenolod
parents: 807
diff changeset
259 * NOTICE! this check is not entirely correct, but I think
44a922a4a591 [svn] - fix validation of mpeg2 files, by ccr.
nenolod
parents: 807
diff changeset
260 * it is sufficient in most cases.
44a922a4a591 [svn] - fix validation of mpeg2 files, by ccr.
nenolod
parents: 807
diff changeset
261 */
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
262 if (((bitRate >= 32 && bitRate <= 56) || bitRate == 80))
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
263 return FALSE;
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
264 }
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
265 }
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
266
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
267 /* calculate approx. frame size */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
268 padding = (head >> 9) & 1;
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
269 sampleRate = mp3_samplerate_table[version][sampleIndex];
897
44a922a4a591 [svn] - fix validation of mpeg2 files, by ccr.
nenolod
parents: 807
diff changeset
270 if (layer == 1)
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
271 *frameSize = ((12 * bitRate * 1000 / sampleRate) + padding) * 4;
897
44a922a4a591 [svn] - fix validation of mpeg2 files, by ccr.
nenolod
parents: 807
diff changeset
272 else
44a922a4a591 [svn] - fix validation of mpeg2 files, by ccr.
nenolod
parents: 807
diff changeset
273 *frameSize = (144 * bitRate * 1000) / (sampleRate + padding);
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
274
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
275 /* check if bits 16 - 19 are all set (MPEG 1 Layer I, not protected?) */
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
276 if (((head >> 19) & 1) == 1 &&
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
277 ((head >> 17) & 3) == 3 && ((head >> 16) & 1) == 1)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
278 return FALSE;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
279
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
280 /* not sure why we check this, but ok! */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
281 if ((head & 0xffff0000) == 0xfffe0000)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
282 return FALSE;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
283
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
284 return TRUE;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
285 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
286
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
287 static int mp3_head_convert(const guchar * hbuf)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
288 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
289 return ((unsigned long) hbuf[0] << 24) |
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
290 ((unsigned long) hbuf[1] << 16) |
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
291 ((unsigned long) hbuf[2] << 8) | (unsigned long) hbuf[3];
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
292 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
293
768
1d3f70ac6b31 [svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents: 765
diff changeset
294 gboolean audmad_is_remote(gchar *url)
1d3f70ac6b31 [svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents: 765
diff changeset
295 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
296 gboolean rv = aud_vfs_is_remote(url);
1329
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
297 return rv;
768
1d3f70ac6b31 [svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents: 765
diff changeset
298 }
612
951b24719ce9 [svn] - fix for audmad_is_our_fd()
yaz
parents: 611
diff changeset
299
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
300 // audacious vfs fast version
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
301 static int audmad_is_our_fd(char *filename, VFSFile *fin)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
302 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
303 guint32 check;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
304 gchar *ext = extname(filename);
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
305 gint cyc = 0, chkcount = 0, chksize = 4096;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
306 guchar buf[4];
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
307 guchar tmp[4096];
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
308 gint ret, i, frameSize;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
309
613
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
310 info.remote = FALSE;
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
311
768
1d3f70ac6b31 [svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents: 765
diff changeset
312 if(audmad_is_remote(filename))
612
951b24719ce9 [svn] - fix for audmad_is_our_fd()
yaz
parents: 611
diff changeset
313 info.remote = TRUE;
951b24719ce9 [svn] - fix for audmad_is_our_fd()
yaz
parents: 611
diff changeset
314
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
315 /* I've seen some flac files beginning with id3 frames..
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
316 so let's exclude known non-mp3 filename extensions */
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
317 if ((ext != NULL) &&
671
e6a1ba5185ba [svn] - Tweak to check we found a file extension before using it to prevent segfault
nazca
parents: 653
diff changeset
318 (!strcasecmp("flac", ext) || !strcasecmp("mpc", ext) ||
e6a1ba5185ba [svn] - Tweak to check we found a file extension before using it to prevent segfault
nazca
parents: 653
diff changeset
319 !strcasecmp("tta", ext) || !strcasecmp("ogg", ext) ||
e6a1ba5185ba [svn] - Tweak to check we found a file extension before using it to prevent segfault
nazca
parents: 653
diff changeset
320 !strcasecmp("wma", ext) )
789
354c69a939bc [svn] revising vfs_fread() check code.
yaz
parents: 788
diff changeset
321 )
354c69a939bc [svn] revising vfs_fread() check code.
yaz
parents: 788
diff changeset
322 return 0;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
323
789
354c69a939bc [svn] revising vfs_fread() check code.
yaz
parents: 788
diff changeset
324 if (fin == NULL) {
354c69a939bc [svn] revising vfs_fread() check code.
yaz
parents: 788
diff changeset
325 g_message("fin = NULL");
354c69a939bc [svn] revising vfs_fread() check code.
yaz
parents: 788
diff changeset
326 return 0;
354c69a939bc [svn] revising vfs_fread() check code.
yaz
parents: 788
diff changeset
327 }
788
2461b711162b [svn] - revert r1664 as it breaks too much
nenolod
parents: 783
diff changeset
328
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
329 if(aud_vfs_fread(buf, 1, 4, fin) == 0) {
799
d200de50a1fc [svn] - convert filename into utf8 in debug messages.
yaz
parents: 789
diff changeset
330 gchar *tmp = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
331 g_message("aud_vfs_fread failed @1 %s", tmp);
799
d200de50a1fc [svn] - convert filename into utf8 in debug messages.
yaz
parents: 789
diff changeset
332 g_free(tmp);
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
333 return 0;
789
354c69a939bc [svn] revising vfs_fread() check code.
yaz
parents: 788
diff changeset
334 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
335
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
336 check = mp3_head_convert(buf);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
337
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
338 if (memcmp(buf, "ID3", 3) == 0)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
339 return 1;
782
6f519e34ddf0 [svn] - reject files which use Ogg container magic
nenolod
parents: 773
diff changeset
340 else if (memcmp(buf, "OggS", 4) == 0)
6f519e34ddf0 [svn] - reject files which use Ogg container magic
nenolod
parents: 773
diff changeset
341 return 0;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
342 else if (memcmp(buf, "RIFF", 4) == 0)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
343 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
344 aud_vfs_fseek(fin, 4, SEEK_CUR);
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
345 if(aud_vfs_fread(buf, 1, 4, fin) == 0) {
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
346 gchar *tmp = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
347 g_message("aud_vfs_fread failed @2 %s", tmp);
799
d200de50a1fc [svn] - convert filename into utf8 in debug messages.
yaz
parents: 789
diff changeset
348 g_free(tmp);
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
349 return 0;
789
354c69a939bc [svn] revising vfs_fread() check code.
yaz
parents: 788
diff changeset
350 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
351
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
352 if (memcmp(buf, "RMP3", 4) == 0)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
353 return 1;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
354 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
355
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
356 // check data for frame header
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
357 while (!mp3_head_check(check, &frameSize))
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
358 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
359 if((ret = aud_vfs_fread(tmp, 1, chksize, fin)) == 0){
799
d200de50a1fc [svn] - convert filename into utf8 in debug messages.
yaz
parents: 789
diff changeset
360 gchar *tmp = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
361 g_message("aud_vfs_fread failed @3 %s", tmp);
799
d200de50a1fc [svn] - convert filename into utf8 in debug messages.
yaz
parents: 789
diff changeset
362 g_free(tmp);
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
363 return 0;
789
354c69a939bc [svn] revising vfs_fread() check code.
yaz
parents: 788
diff changeset
364 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
365 for (i = 0; i < ret; i++)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
366 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
367 check <<= 8;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
368 check |= tmp[i];
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
369
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
370 if (mp3_head_check(check, &frameSize)) {
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
371 /* when the first matching frame header is found, we check for
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
372 * another frame by seeking to the approximate start of the
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
373 * next header ... also reduce the check size.
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
374 */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
375 if (++chkcount >= 3) return 1;
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
376 aud_vfs_fseek(fin, frameSize-4, SEEK_CUR);
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
377 check = 0;
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
378 chksize = 8;
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
379 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
380 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
381
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
382 if (++cyc > 32)
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
383 return 0;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
384 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
385
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
386 return 1;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
387 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
388
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
389 // audacious vfs version
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
390 static int audmad_is_our_file(char *filename)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
391 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
392 VFSFile *fin = NULL;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
393 gint rtn;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
394
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
395 fin = aud_vfs_fopen(filename, "rb");
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
396
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
397 if (fin == NULL)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
398 return 0;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
399
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
400 rtn = audmad_is_our_fd(filename, fin);
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
401 aud_vfs_fclose(fin);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
402
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
403 return rtn;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
404 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
405
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
406 static void audmad_stop(InputPlayback *playback)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
407 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
408 #ifdef DEBUG
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
409 g_message("f: audmad_stop");
612
951b24719ce9 [svn] - fix for audmad_is_our_fd()
yaz
parents: 611
diff changeset
410 #endif
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
411 g_mutex_lock(mad_mutex);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
412 info.playback = playback;
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
413 g_mutex_unlock(mad_mutex);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
414
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
415 if (decode_thread) {
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
416
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
417 g_mutex_lock(mad_mutex);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
418 info.playback->playing = 0;
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
419 g_mutex_unlock(mad_mutex);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
420 g_cond_signal(mad_cond);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
421
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
422 #ifdef DEBUG
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
423 g_message("waiting for thread");
612
951b24719ce9 [svn] - fix for audmad_is_our_fd()
yaz
parents: 611
diff changeset
424 #endif
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
425 g_thread_join(decode_thread);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
426 #ifdef DEBUG
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
427 g_message("thread done");
612
951b24719ce9 [svn] - fix for audmad_is_our_fd()
yaz
parents: 611
diff changeset
428 #endif
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
429 input_term(&info);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
430 decode_thread = NULL;
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
431
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
432 }
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
433 #ifdef DEBUG
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
434 g_message("e: audmad_stop");
612
951b24719ce9 [svn] - fix for audmad_is_our_fd()
yaz
parents: 611
diff changeset
435 #endif
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
436 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
437
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
438 static void audmad_play_file(InputPlayback *playback)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
439 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
440 gboolean rtn;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
441 gchar *url = playback->filename;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
442
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
443 #ifdef DEBUG
799
d200de50a1fc [svn] - convert filename into utf8 in debug messages.
yaz
parents: 789
diff changeset
444 {
d200de50a1fc [svn] - convert filename into utf8 in debug messages.
yaz
parents: 789
diff changeset
445 gchar *tmp = g_filename_to_utf8(url, -1, NULL, NULL, NULL);
d200de50a1fc [svn] - convert filename into utf8 in debug messages.
yaz
parents: 789
diff changeset
446 g_message("playing %s", tmp);
d200de50a1fc [svn] - convert filename into utf8 in debug messages.
yaz
parents: 789
diff changeset
447 g_free(tmp);
d200de50a1fc [svn] - convert filename into utf8 in debug messages.
yaz
parents: 789
diff changeset
448 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
449 #endif /* DEBUG */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
450
1328
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
451 if (input_init(&info, url, NULL) == FALSE) {
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
452 g_message("error initialising input");
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
453 return;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
454 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
455
768
1d3f70ac6b31 [svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents: 765
diff changeset
456 // remote access must use fast scan.
1d3f70ac6b31 [svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents: 765
diff changeset
457 rtn = input_get_info(&info, audmad_is_remote(url) ? TRUE : audmad_config.fast_play_time_calc);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
458
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
459 if (rtn == FALSE) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
460 g_message("error reading input info");
977
bdf6ccf7bf53 [svn] Fixed the embarassing situation i was in (writing a plugin and not being able to see/hear it work).
majeru
parents: 922
diff changeset
461 /*
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
462 * return;
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
463 * commenting this return seems to be a hacky fix for the damn lastfm plugin playback
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
464 * that used to work only for nenolod because of his fsck-ing lastfm subscription :p
977
bdf6ccf7bf53 [svn] Fixed the embarassing situation i was in (writing a plugin and not being able to see/hear it work).
majeru
parents: 922
diff changeset
465 */
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
466 }
613
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
467 g_mutex_lock(pb_mutex);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
468 info.playback = playback;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
469 info.playback->playing = 1;
613
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
470 g_mutex_unlock(pb_mutex);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
471
1342
ebded68de2dd madplug: Update plugin for new threading model.
William Pitcock <nenolod@atheme-project.org>
parents: 1329
diff changeset
472 decode_thread = g_thread_self();
1447
195b5657303e updated input plugins to use set_pb_ready to signal to the core that they're ready for playback
Giacomo Lozito <james@develia.org>
parents: 1428
diff changeset
473 playback->set_pb_ready(playback);
1342
ebded68de2dd madplug: Update plugin for new threading model.
William Pitcock <nenolod@atheme-project.org>
parents: 1329
diff changeset
474 decode_loop(&info);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
475 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
476
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
477 static void audmad_pause(InputPlayback *playback, short paused)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
478 {
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
479 g_mutex_lock(pb_mutex);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
480 info.playback = playback;
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
481 g_mutex_unlock(pb_mutex);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
482 playback->output->pause(paused);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
483 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
484
807
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 802
diff changeset
485 static void audmad_mseek(InputPlayback *playback, gulong millisecond)
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
486 {
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
487 g_mutex_lock(pb_mutex);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
488 info.playback = playback;
807
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 802
diff changeset
489 info.seek = millisecond;
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
490 g_mutex_unlock(pb_mutex);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
491 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
492
807
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 802
diff changeset
493 static void audmad_seek(InputPlayback *playback, gint time)
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 802
diff changeset
494 {
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 802
diff changeset
495 audmad_mseek(playback, time * 1000);
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 802
diff changeset
496 }
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 802
diff changeset
497
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
498 /**
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
499 * Scan the given file or URL.
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
500 * Fills in the title string and the track length in milliseconds.
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
501 */
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
502 static void
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
503 audmad_get_song_info(char *url, char **title, int *length)
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
504 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
505 struct mad_info_t myinfo;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
506 #ifdef DEBUG
799
d200de50a1fc [svn] - convert filename into utf8 in debug messages.
yaz
parents: 789
diff changeset
507 gchar *tmp = g_filename_to_utf8(url, -1, NULL, NULL, NULL);
d200de50a1fc [svn] - convert filename into utf8 in debug messages.
yaz
parents: 789
diff changeset
508 g_message("f: audmad_get_song_info: %s", tmp);
d200de50a1fc [svn] - convert filename into utf8 in debug messages.
yaz
parents: 789
diff changeset
509 g_free(tmp);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
510 #endif /* DEBUG */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
511
1328
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
512 if (input_init(&myinfo, url, NULL) == FALSE) {
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
513 #ifdef DEBUG
613
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
514 g_message("error initialising input");
768
1d3f70ac6b31 [svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents: 765
diff changeset
515 #endif
613
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
516 return;
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
517 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
518
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
519 if (input_get_info(&myinfo, info.remote ? TRUE : audmad_config.fast_play_time_calc) == TRUE) {
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
520 if(aud_tuple_get_string(myinfo.tuple, -1, "track-name"))
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
521 *title = g_strdup(aud_tuple_get_string(myinfo.tuple, -1, "track-name"));
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
522 else
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
523 *title = g_strdup(url);
1738
e1ebf3fc1a16 - follow the change of libaudid3tag.so's location.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1697
diff changeset
524
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
525 *length = aud_tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL);
1738
e1ebf3fc1a16 - follow the change of libaudid3tag.so's location.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1697
diff changeset
526 if(*length == -1)
738
6ea974a229a8 [svn] - add read/write support for TLEN frame.
yaz
parents: 676
diff changeset
527 *length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
528 }
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
529 else {
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
530 *title = g_strdup(url);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
531 *length = -1;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
532 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
533 input_term(&myinfo);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
534 #ifdef DEBUG
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
535 g_message("e: audmad_get_song_info");
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
536 #endif /* DEBUG */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
537 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
538
1328
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
539 static void
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
540 audmad_get_song_length(char *url, int *length, VFSFile *fd)
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
541 {
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
542 struct mad_info_t myinfo;
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
543 #ifdef DEBUG
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
544 gchar *tmp = g_filename_to_utf8(url, -1, NULL, NULL, NULL);
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
545 g_message("f: audmad_get_song_length: %s", tmp);
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
546 g_free(tmp);
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
547 #endif /* DEBUG */
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
548
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
549 if (input_init(&myinfo, url, fd ? fd : NULL) == FALSE) {
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
550 #ifdef DEBUG
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
551 g_message("error initialising input");
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
552 #endif
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
553 return;
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
554 }
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
555
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
556 if (input_get_info(&myinfo, info.remote ? TRUE : audmad_config.fast_play_time_calc) == TRUE) {
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
557 *length = aud_tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL);
1738
e1ebf3fc1a16 - follow the change of libaudid3tag.so's location.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1697
diff changeset
558 if(*length == -1)
1328
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
559 *length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS);
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
560 }
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
561 else {
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
562 *length = -1;
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
563 }
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
564 input_term(&myinfo);
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
565 #ifdef DEBUG
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
566 g_message("e: audmad_get_song_info");
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
567 #endif /* DEBUG */
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
568 }
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
569
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
570 static void audmad_about()
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
571 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
572 static GtkWidget *aboutbox;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
573 gchar *scratch;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
574
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
575 if (aboutbox != NULL)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
576 return;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
577
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
578 scratch = g_strdup_printf(
1361
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
579 _("Audacious MPEG Audio Plugin\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
580 "\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
581 "Compiled against libMAD version: %d.%d.%d%s\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
582 "\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
583 "Written by:\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
584 " William Pitcock <nenolod@sacredspiral.co.uk>\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
585 " Yoshiki Yazawa <yaz@cc.rim.or.jp>\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
586 "\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
587 "Portions derived from XMMS-MAD by:\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
588 " Sam Clegg\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
589 "\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
590 "ReplayGain support by:\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
591 " Samuel Krempp"),
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
592 MAD_VERSION_MAJOR, MAD_VERSION_MINOR, MAD_VERSION_PATCH,
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
593 MAD_VERSION_EXTRA);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
594
1677
f6f5603a0954 xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents: 1485
diff changeset
595 aboutbox = audacious_info_dialog(_("About MPEG Audio Plugin"),
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
596 scratch,
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
597 _("Ok"), FALSE, NULL, NULL);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
598
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
599 g_free(scratch);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
600
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
601 g_signal_connect(G_OBJECT(aboutbox), "destroy",
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
602 G_CALLBACK(gtk_widget_destroyed), &aboutbox);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
603 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
604
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
605 /**
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
606 * Display a GTK box containing the given error message.
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
607 * Taken from mpg123 plugin.
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
608 */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
609 void audmad_error(char *error, ...)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
610 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
611 #ifndef NOGUI
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
612 if (!error_dialog) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
613 va_list args;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
614 char string[256];
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
615 va_start(args, error);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
616 vsnprintf(string, 256, error, args);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
617 va_end(args);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
618 GDK_THREADS_ENTER();
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
619 error_dialog =
1677
f6f5603a0954 xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents: 1485
diff changeset
620 audacious_info_dialog(_("Error"), string, _("Ok"), FALSE, 0, 0);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
621 gtk_signal_connect(GTK_OBJECT(error_dialog), "destroy",
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
622 GTK_SIGNAL_FUNC(gtk_widget_destroyed),
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
623 &error_dialog);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
624 GDK_THREADS_LEAVE();
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
625 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
626 #endif /* !NOGUI */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
627 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
628
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
629 extern void audmad_configure();
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
630
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1485
diff changeset
631 static void __set_and_free(Tuple *tuple, gint nfield, gchar *name, gchar *value)
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
632 {
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
633 aud_tuple_associate_string(tuple, nfield, name, value);
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
634 g_free(value);
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
635 }
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
636
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
637 // tuple stuff
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
638 static Tuple *__audmad_get_song_tuple(char *filename, VFSFile *fd)
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
639 {
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
640 Tuple *tuple = NULL;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
641 gchar *string = NULL;
1277
e7cd962732cb file_name and file_path in a tuple should be unescaped.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1225
diff changeset
642 gchar *realfn = NULL;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
643
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
644 struct id3_file *id3file = NULL;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
645 struct id3_tag *tag = NULL;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
646
1329
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
647 gboolean local_fd = FALSE;
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
648
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
649 #ifdef DEBUG
2050
2ffc6a69fcd1 string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents: 1995
diff changeset
650 string = aud_str_to_utf8(filename);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
651 g_message("f: mad: audmad_get_song_tuple: %s", string);
613
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
652 g_free(string);
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
653 string = NULL;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
654 #endif
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
655
768
1d3f70ac6b31 [svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents: 765
diff changeset
656 if(info.remote && mad_timer_count(info.duration, MAD_UNITS_SECONDS) <= 0){
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
657 if((fd && aud_vfs_is_streaming(fd)) || (info.playback && info.playback->playing)) {
768
1d3f70ac6b31 [svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents: 765
diff changeset
658 gchar *tmp = NULL;
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
659 tuple = aud_tuple_new_from_filename(filename);
1328
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
660
613
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
661 #ifdef DEBUG
1328
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
662 if(info.playback)
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
663 g_message("info.playback->playing = %d",info.playback->playing);
613
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
664 #endif
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
665 tmp = aud_vfs_get_metadata(info.infile ? info.infile : fd, "track-name");
768
1d3f70ac6b31 [svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents: 765
diff changeset
666 if(tmp){
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
667 gchar *scratch;
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
668
2050
2ffc6a69fcd1 string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents: 1995
diff changeset
669 scratch = aud_str_to_utf8(tmp);
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
670 aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, scratch);
768
1d3f70ac6b31 [svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents: 765
diff changeset
671 g_free(tmp);
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
672 g_free(scratch);
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
673
768
1d3f70ac6b31 [svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents: 765
diff changeset
674 tmp = NULL;
1d3f70ac6b31 [svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents: 765
diff changeset
675 }
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
676 tmp = aud_vfs_get_metadata(info.infile ? info.infile : fd, "stream-name");
768
1d3f70ac6b31 [svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents: 765
diff changeset
677 if(tmp){
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
678 gchar *scratch;
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
679
2050
2ffc6a69fcd1 string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents: 1995
diff changeset
680 scratch = aud_str_to_utf8(tmp);
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
681 aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, scratch);
768
1d3f70ac6b31 [svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents: 765
diff changeset
682 g_free(tmp);
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
683 g_free(scratch);
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
684
768
1d3f70ac6b31 [svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents: 765
diff changeset
685 tmp = NULL;
1d3f70ac6b31 [svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents: 765
diff changeset
686 }
1328
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
687
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
688 #ifdef DEBUG
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
689 g_message("audmad_get_song_tuple: track_name = %s", aud_tuple_get_string(tuple, -1, "track-name"));
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
690 g_message("audmad_get_song_tuple: stream_name = %s", aud_tuple_get_string(tuple, -1, "stream-name"));
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
691 #endif
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
692 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1);
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
693 aud_tuple_associate_int(tuple, FIELD_MTIME, NULL, 0); // this indicates streaming
613
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
694 #ifdef DEBUG
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
695 g_message("get_song_tuple: remote: tuple");
613
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
696 #endif
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
697 return tuple;
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
698 }
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
699 #ifdef DEBUG
768
1d3f70ac6b31 [svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents: 765
diff changeset
700 g_message("get_song_tuple: remote: NULL");
613
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
701 #endif
1485
4e612b01f303 - make use of tuple_formatter_make_title_string(). now madplug can show file name if metadata is not available.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1463
diff changeset
702 // return NULL;
1328
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
703 } /* info.remote */
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
704
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
705 // if !fd, pre-open the file with aud_vfs_fopen() and reuse fd.
1329
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
706 if(!fd) {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
707 fd = aud_vfs_fopen(filename, "rb");
1329
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
708 if(!fd)
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
709 return NULL;
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
710 local_fd = TRUE;
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
711 }
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
712
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
713 tuple = aud_tuple_new();
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
714 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1);
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
715
1329
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
716 id3file = id3_file_vfsopen(fd, ID3_FILE_MODE_READONLY);
1315
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
717
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
718 if (id3file) {
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
719
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
720 tag = id3_file_tag(id3file);
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
721 if (tag) {
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1485
diff changeset
722 __set_and_free(tuple, FIELD_ARTIST, NULL, input_id3_get_string(tag, ID3_FRAME_ARTIST));
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1485
diff changeset
723 __set_and_free(tuple, FIELD_ALBUM, NULL, input_id3_get_string(tag, ID3_FRAME_ALBUM));
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1485
diff changeset
724 __set_and_free(tuple, FIELD_TITLE, NULL, input_id3_get_string(tag, ID3_FRAME_TITLE));
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
725
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
726 // year
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
727 string = NULL;
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
728 string = input_id3_get_string(tag, ID3_FRAME_YEAR); //TDRC
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
729 if (!string)
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
730 string = input_id3_get_string(tag, "TYER");
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
731
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
732 if (string) {
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
733 aud_tuple_associate_int(tuple, FIELD_YEAR, NULL, atoi(string));
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
734 g_free(string);
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
735 string = NULL;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
736 }
1277
e7cd962732cb file_name and file_path in a tuple should be unescaped.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1225
diff changeset
737 realfn = g_filename_from_uri(filename, NULL, NULL);
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1485
diff changeset
738 __set_and_free(tuple, FIELD_FILE_NAME, NULL, g_path_get_basename(realfn ? realfn : filename));
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1485
diff changeset
739 __set_and_free(tuple, FIELD_FILE_PATH, NULL, g_path_get_dirname(realfn ? realfn : filename));
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
740 aud_tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, extname(realfn ? realfn : filename));
1277
e7cd962732cb file_name and file_path in a tuple should be unescaped.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1225
diff changeset
741 g_free(realfn); realfn = NULL;
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
742
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
743 // length
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
744 string = input_id3_get_string(tag, "TLEN");
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
745 if (string) {
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
746 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, atoi(string));
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
747 #ifdef DEBUG
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
748 g_message("get_song_tuple: TLEN = %d", aud_tuple_get_int(tuple, FIELD_LENGTH, NULL));
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
749 #endif
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
750 g_free(string);
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
751 string = NULL;
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
752 }
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
753 else {
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
754 char *dummy = NULL;
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
755 int length = 0;
1329
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
756 audmad_get_song_length(filename, &length, fd);
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
757 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, length);
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
758 g_free(dummy);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
759 }
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
760
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
761 // track number
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
762 string = input_id3_get_string(tag, ID3_FRAME_TRACK);
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
763 if (string) {
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
764 aud_tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atoi(string));
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
765 g_free(string);
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
766 string = NULL;
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
767 }
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
768 // genre
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1485
diff changeset
769 __set_and_free(tuple, FIELD_GENRE, NULL, input_id3_get_string(tag, ID3_FRAME_GENRE));
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1485
diff changeset
770 __set_and_free(tuple, FIELD_COMMENT, NULL, input_id3_get_string(tag, ID3_FRAME_COMMENT));
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
771 #ifdef DEBUG
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
772 g_message("genre = %s", aud_tuple_get_string(tuple, FIELD_GENRE, NULL));
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
773 #endif
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
774 }
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
775 id3_file_close(id3file);
1329
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
776 } // id3file
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
777 else { // no id3tag
1277
e7cd962732cb file_name and file_path in a tuple should be unescaped.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1225
diff changeset
778 realfn = g_filename_from_uri(filename, NULL, NULL);
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1485
diff changeset
779 __set_and_free(tuple, FIELD_FILE_NAME, NULL, g_path_get_basename(realfn ? realfn : filename));
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1485
diff changeset
780 __set_and_free(tuple, FIELD_FILE_PATH, NULL, g_path_get_dirname(realfn ? realfn : filename));
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
781 aud_tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, extname(realfn ? realfn : filename));
1277
e7cd962732cb file_name and file_path in a tuple should be unescaped.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1225
diff changeset
782 g_free(realfn); realfn = NULL;
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
783 // length
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
784 {
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
785 char *dummy = NULL;
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
786 int length = 0;
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
787 if(aud_tuple_get_int(tuple, FIELD_LENGTH, NULL) == -1) {
1329
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
788 audmad_get_song_length(filename, &length, fd);
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
789 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, length);
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
790 }
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
791 g_free(dummy);
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
792 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
793 }
1329
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
794
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
795 aud_tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossy");
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
796 aud_tuple_associate_string(tuple, FIELD_CODEC, NULL, "MPEG Audio (MP3)");
2201
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2153
diff changeset
797 aud_tuple_associate_string(tuple, FIELD_MIMETYPE, NULL, "audio/mpeg");
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
798
1329
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
799 if(local_fd)
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
800 aud_vfs_fclose(fd);
1329
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
801
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
802 #ifdef DEBUG
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
803 g_message("e: mad: audmad_get_song_tuple");
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
804 #endif
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
805 return tuple;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
806 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
807
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
808 static Tuple *audmad_get_song_tuple(char *filename)
1315
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
809 {
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
810 return __audmad_get_song_tuple(filename, NULL);
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
811 }
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
812
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
813 static Tuple *audmad_probe_for_tuple(char *filename, VFSFile *fd)
1315
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
814 {
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
815 if (!audmad_is_our_fd(filename, fd))
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
816 return NULL;
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
817
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
818 aud_vfs_rewind(fd);
1326
e991d29a9c9a madplug: Fix ID3v1 tuple building.
William Pitcock <nenolod@atheme-project.org>
parents: 1324
diff changeset
819
1315
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
820 return __audmad_get_song_tuple(filename, fd);
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
821 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
822
2153
2f7eff0bc6eb madplug: add .bmu to extensions whitelist (closes bugzilla #49)
William Pitcock <nenolod@atheme.org>
parents: 2124
diff changeset
823 static gchar *fmts[] = { "mp3", "mp2", "mpg", "bmu", NULL };
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
824
1065
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
825 InputPlugin mad_ip = {
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
826 .description = "MPEG Audio Plugin",
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
827 .init = audmad_init,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
828 .about = audmad_about,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
829 .configure = audmad_configure,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
830 .is_our_file = audmad_is_our_file,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
831 .play_file = audmad_play_file,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
832 .stop = audmad_stop,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
833 .pause = audmad_pause,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
834 .seek = audmad_seek,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
835 .cleanup = audmad_cleanup,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
836 .get_song_info = audmad_get_song_info,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
837 .get_song_tuple = audmad_get_song_tuple,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
838 .is_our_file_from_vfs = audmad_is_our_fd,
1979
839804c3b3a4 aud_vfs_extensions -> vfs_extensions, some vtable fixes
William Pitcock <nenolod@atheme.org>
parents: 1978
diff changeset
839 .vfs_extensions = fmts,
1315
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
840 .mseek = audmad_mseek,
2201
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2153
diff changeset
841 .probe_for_tuple = audmad_probe_for_tuple,
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2153
diff changeset
842 .update_song_tuple = audmad_update_song_tuple,
1065
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
843 };
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
844
1065
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
845 InputPlugin *madplug_iplist[] = { &mad_ip, NULL };
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
846
1400
fe0a9cf95642 make use of SIMPLE_INPUT_PLUGIN() as an example.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1395
diff changeset
847 SIMPLE_INPUT_PLUGIN(madplug, madplug_iplist);
1065
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
848
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
849 InputPlugin *mad_plugin = &mad_ip;