Mercurial > audlegacy-plugins
annotate src/madplug/plugin.c @ 2341:59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
- default pre-gain have been changed to +6dB for with RG, +0dB for the rest.
- new clipping prevention feature using track peak information has been implemented.
- reworked preferences dialog. widgets have been categorized by function and all changes will take effect immediately. and also, cancel button can reverts all changes have been done in the current session.
- some keys in preferences have been changed.
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Thu, 31 Jan 2008 15:22:15 +0900 |
parents | 47d7a45b26a0 |
children | fd8271f07747 |
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 |
2206
7c7e6f5c494e
added myself to authors
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2205
diff
changeset
|
3 * Copyright (C) 2005-2007 William Pitcock, Yoshiki Yazawa, Eugene Zagidullin |
610
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 |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2207
diff
changeset
|
22 /* #define AUD_DEBUG 1 */ |
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2207
diff
changeset
|
23 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
24 #include "config.h" |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
25 #include "plugin.h" |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
26 #include "input.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 <math.h> |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
29 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
30 #include <gtk/gtk.h> |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
31 #include <audacious/util.h> |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
32 #include <audacious/configdb.h> |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
33 #include <stdarg.h> |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
34 #include <fcntl.h> |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
35 #include <audacious/vfs.h> |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
36 #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
|
37 #include "SFMT.h" |
2202
f76e846d53d9
updating TLEN frame returned
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2201
diff
changeset
|
38 #include "tuple.h" |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
39 |
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 * Global variables |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
42 */ |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
43 audmad_config_t *audmad_config; /**< global configuration */ |
611 | 44 GMutex *mad_mutex; |
45 GMutex *pb_mutex; | |
46 GCond *mad_cond; | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
47 |
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 variables |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
50 */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
51 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
|
52 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
|
53 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
54 #ifndef NOGUI |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
55 static GtkWidget *error_dialog = 0; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
56 #endif |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
57 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
58 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
|
59 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
60 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
|
61 { 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
|
62 { 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
|
63 { 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
|
64 { 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
|
65 { 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
|
66 }; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
67 |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
68 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
|
69 { 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
|
70 { -1, -1, -1, -1 }, /* Reserved */ |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
71 { 22050, 24000, 16000, -1 }, /* MPEG2 */ |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
72 { 44100, 48000, 32000, -1 } /* MPEG1 */ |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
73 }; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
74 |
610
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 * Function extname (filename) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
77 * |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
78 * 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
|
79 * filename has no extension. |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
80 * |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
81 */ |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
82 static gchar * |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
83 extname(const char *filename) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
84 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
85 gchar *ext = strrchr(filename, '.'); |
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 if (ext != NULL) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
88 ++ext; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
89 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
90 return ext; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
91 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
92 |
611 | 93 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
94 void |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
95 audmad_config_compute(audmad_config_t *config) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
96 { |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
97 /* 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
|
98 (RG default gain, etc..) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
99 */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
100 const gchar *text; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
101 gdouble x; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
102 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
103 text = config->replaygain.preamp0_db; |
653
638b290641f3
[svn] - madplug: check that text is not null before using g_strtod
giacomo
parents:
651
diff
changeset
|
104 if ( text != NULL ) |
638b290641f3
[svn] - madplug: check that text is not null before using g_strtod
giacomo
parents:
651
diff
changeset
|
105 x = g_strtod(text, NULL); |
638b290641f3
[svn] - madplug: check that text is not null before using g_strtod
giacomo
parents:
651
diff
changeset
|
106 else |
638b290641f3
[svn] - madplug: check that text is not null before using g_strtod
giacomo
parents:
651
diff
changeset
|
107 x = 0; |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
108 config->replaygain.preamp0_scale = (x != 0) ? pow(10.0, x / 20) : 1; |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
109 AUDDBG("RG.preamp0=[%s] -> %g -> %g\n", text, x, config->preamp0_scale); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
110 |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
111 text = config->replaygain.preamp1_db; |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
112 if ( text != NULL ) |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
113 x = g_strtod(text, NULL); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
114 else |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
115 x = 0; |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
116 config->replaygain.preamp1_scale = (x != 0) ? pow(10.0, x / 20) : 1; |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
117 AUDDBG("RG.preamp1=[%s] -> %g -> %g\n", text, x, |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
118 config->replaygain.preamp1_scale); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
119 |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
120 text = config->replaygain.preamp2_db; |
653
638b290641f3
[svn] - madplug: check that text is not null before using g_strtod
giacomo
parents:
651
diff
changeset
|
121 if ( text != NULL ) |
638b290641f3
[svn] - madplug: check that text is not null before using g_strtod
giacomo
parents:
651
diff
changeset
|
122 x = g_strtod(text, NULL); |
638b290641f3
[svn] - madplug: check that text is not null before using g_strtod
giacomo
parents:
651
diff
changeset
|
123 else |
638b290641f3
[svn] - madplug: check that text is not null before using g_strtod
giacomo
parents:
651
diff
changeset
|
124 x = 0; |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
125 config->replaygain.preamp2_scale = (x != 0) ? pow(10.0, x / 20) : 1; |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
126 AUDDBG("RG.preamp2=[%s] -> %g -> %g\n", text, x, |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
127 config->replaygain.preamp2_scale); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
128 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
129 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
130 static void |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
131 audmad_init() |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
132 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
133 ConfigDb *db = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
134 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
135 audmad_config = g_malloc0(sizeof(audmad_config_t)); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
136 |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
137 audmad_config->dither = TRUE; |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
138 audmad_config->force_reopen_audio = FALSE; |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
139 audmad_config->fast_play_time_calc = TRUE; |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
140 audmad_config->use_xing = TRUE; |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
141 audmad_config->sjis = FALSE; |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
142 audmad_config->show_avg_vbr_bitrate = TRUE; |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
143 audmad_config->replaygain.enable = TRUE; |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
144 audmad_config->replaygain.track_mode = FALSE; |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
145 audmad_config->replaygain.anti_clip = FALSE; |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
146 audmad_config->replaygain.hard_limit = FALSE; |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
147 audmad_config->title_override = FALSE; |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
148 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
149 |
2124 | 150 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
|
151 if (db) { |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
152 //audio |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
153 aud_cfg_db_get_bool(db, "MAD", "dither", &audmad_config->dither); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
154 aud_cfg_db_get_bool(db, "MAD", "force_reopen_audio", |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
155 &audmad_config->force_reopen_audio); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
156 |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
157 //metadata |
2124 | 158 aud_cfg_db_get_bool(db, "MAD", "fast_play_time_calc", |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
159 &audmad_config->fast_play_time_calc); |
2124 | 160 aud_cfg_db_get_bool(db, "MAD", "use_xing", |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
161 &audmad_config->use_xing); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
162 aud_cfg_db_get_bool(db, "MAD", "sjis", &audmad_config->sjis); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
163 |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
164 //misc |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
165 aud_cfg_db_get_bool(db, "MAD", "show_avg_vbr_bitrate", |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
166 &audmad_config->show_avg_vbr_bitrate); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
167 |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
168 //gain control |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
169 aud_cfg_db_get_string(db, "MAD", "RG.preamp0_db", |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
170 &audmad_config->replaygain.preamp0_db); |
2124 | 171 aud_cfg_db_get_bool(db, "MAD", "RG.enable", |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
172 &audmad_config->replaygain.enable); |
2124 | 173 aud_cfg_db_get_bool(db, "MAD", "RG.track_mode", |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
174 &audmad_config->replaygain.track_mode); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
175 aud_cfg_db_get_string(db, "MAD", "RG.preamp1_db", |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
176 &audmad_config->replaygain.preamp1_db); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
177 aud_cfg_db_get_string(db, "MAD", "RG.preamp2_db", |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
178 &audmad_config->replaygain.preamp2_db); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
179 aud_cfg_db_get_bool(db, "MAD", "RG.anti_clip", |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
180 &audmad_config->replaygain.anti_clip); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
181 aud_cfg_db_get_bool(db, "MAD", "RG.hard_limit", |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
182 &audmad_config->replaygain.hard_limit); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
183 |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
184 //text |
2124 | 185 aud_cfg_db_get_bool(db, "MAD", "title_override", |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
186 &audmad_config->title_override); |
2124 | 187 aud_cfg_db_get_string(db, "MAD", "id3_format", |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
188 &audmad_config->id3_format); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
189 |
2124 | 190 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
|
191 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
192 |
611 | 193 mad_mutex = g_mutex_new(); |
194 pb_mutex = g_mutex_new(); | |
195 mad_cond = g_cond_new(); | |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
196 audmad_config_compute(audmad_config); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
197 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
198 if (!audmad_config->replaygain.preamp0_db) |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
199 audmad_config->replaygain.preamp0_db = g_strdup("+0.00"); |
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
|
200 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
201 if (!audmad_config->replaygain.preamp1_db) |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
202 audmad_config->replaygain.preamp1_db = g_strdup("+6.00"); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
203 if (!audmad_config->replaygain.preamp2_db) |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
204 audmad_config->replaygain.preamp2_db = g_strdup("+0.00"); |
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
|
205 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
206 if (!audmad_config->id3_format) |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
207 audmad_config->id3_format = g_strdup("(none)"); |
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
|
208 |
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
|
209 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
|
210 |
1995
47a7b26717d4
wow, only one plugin uses aud_mime API. that sucks! :D
William Pitcock <nenolod@atheme.org>
parents:
1979
diff
changeset
|
211 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
|
212 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
213 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
214 static void |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
215 audmad_cleanup() |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
216 { |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
217 g_free(audmad_config->replaygain.preamp0_db); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
218 g_free(audmad_config->replaygain.preamp1_db); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
219 g_free(audmad_config->replaygain.preamp2_db); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
220 g_free(audmad_config->id3_format); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
221 g_free(audmad_config); |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
222 |
802 | 223 g_cond_free(mad_cond); |
224 g_mutex_free(mad_mutex); | |
225 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
|
226 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
227 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
228 static gboolean |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
229 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
|
230 { |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
231 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
|
232 |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
233 /* 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
|
234 * 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
|
235 */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
236 if ((head & 0xffe00000) != 0xffe00000) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
237 return FALSE; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
238 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
239 /* 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
|
240 layer = (head >> 17) & 0x3; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
241 if (!layer) |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
242 return FALSE; /* 00 = reserved */ |
897 | 243 layer = 4 - layer; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
244 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
245 /* 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
|
246 bitIndex = (head >> 12) & 0xf; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
247 |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
248 /* 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
|
249 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
|
250 return FALSE; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
251 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
252 /* check samplerate index bits (10-11) */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
253 sampleIndex = (head >> 10) & 0x3; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
254 if (sampleIndex == 0x3) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
255 return FALSE; |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
256 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
257 /* 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
|
258 version = (head >> 19) & 0x03; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
259 switch (version) { |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
260 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
|
261 case 2: /* 10 = MPEG Version 2 */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
262 if (layer == 1) |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
263 bitRate = mp3_bitrate_table[3][bitIndex]; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
264 else |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
265 bitRate = mp3_bitrate_table[4][bitIndex]; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
266 break; |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
267 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
268 case 1: /* 01 = reserved */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
269 return FALSE; |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
270 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
271 case 3: /* 11 = MPEG Version 1 */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
272 bitRate = mp3_bitrate_table[layer][bitIndex]; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
273 break; |
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 default: |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
276 return FALSE; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
277 } |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
278 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
279 /* check layer II restrictions vs. bitrate */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
280 if (layer == 2) { |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
281 gint chanMode = (head >> 6) & 0x3; |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
282 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
283 if (chanMode == 0x3) { |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
284 /* single channel with bitrate > 192 */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
285 if (bitRate > 192) |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
286 return FALSE; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
287 } else { |
897 | 288 /* any other mode with bitrates 32-56 and 80. |
289 * NOTICE! this check is not entirely correct, but I think | |
290 * it is sufficient in most cases. | |
291 */ | |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
292 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
|
293 return FALSE; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
294 } |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
295 } |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
296 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
297 /* calculate approx. frame size */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
298 padding = (head >> 9) & 1; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
299 sampleRate = mp3_samplerate_table[version][sampleIndex]; |
897 | 300 if (layer == 1) |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
301 *frameSize = ((12 * bitRate * 1000 / sampleRate) + padding) * 4; |
897 | 302 else |
303 *frameSize = (144 * bitRate * 1000) / (sampleRate + padding); | |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
304 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
305 /* 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
|
306 if (((head >> 19) & 1) == 1 && |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
307 ((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
|
308 return FALSE; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
309 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
310 /* 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
|
311 if ((head & 0xffff0000) == 0xfffe0000) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
312 return FALSE; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
313 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
314 return TRUE; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
315 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
316 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
317 static int |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
318 mp3_head_convert(const guchar * hbuf) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
319 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
320 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
|
321 ((unsigned long) hbuf[1] << 16) | |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
322 ((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
|
323 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
324 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
325 // audacious vfs fast version |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
326 static int |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
327 audmad_is_our_fd(char *filename, VFSFile *fin) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
328 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
329 guint32 check; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
330 gchar *ext = extname(filename); |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
331 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
|
332 guchar buf[4]; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
333 guchar tmp[4096]; |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
334 gint ret, i, frameSize; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
335 |
2291 | 336 info.remote = aud_vfs_is_remote(filename); |
612 | 337 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
338 /* 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
|
339 so let's exclude known non-mp3 filename extensions */ |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
340 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
|
341 (!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
|
342 !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
|
343 !strcasecmp("wma", ext) ) |
789 | 344 ) |
345 return 0; | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
346 |
789 | 347 if (fin == NULL) { |
348 g_message("fin = NULL"); | |
349 return 0; | |
350 } | |
788 | 351 |
1978 | 352 if(aud_vfs_fread(buf, 1, 4, fin) == 0) { |
799 | 353 gchar *tmp = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); |
1978 | 354 g_message("aud_vfs_fread failed @1 %s", tmp); |
799 | 355 g_free(tmp); |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
356 return 0; |
789 | 357 } |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
358 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
359 check = mp3_head_convert(buf); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
360 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
361 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
|
362 return 1; |
782 | 363 else if (memcmp(buf, "OggS", 4) == 0) |
364 return 0; | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
365 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
|
366 { |
1978 | 367 aud_vfs_fseek(fin, 4, SEEK_CUR); |
368 if(aud_vfs_fread(buf, 1, 4, fin) == 0) { | |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
369 gchar *tmp = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); |
1978 | 370 g_message("aud_vfs_fread failed @2 %s", tmp); |
799 | 371 g_free(tmp); |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
372 return 0; |
789 | 373 } |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
374 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
375 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
|
376 return 1; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
377 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
378 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
379 // check data for frame header |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
380 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
|
381 { |
1978 | 382 if((ret = aud_vfs_fread(tmp, 1, chksize, fin)) == 0){ |
799 | 383 gchar *tmp = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); |
1978 | 384 g_message("aud_vfs_fread failed @3 %s", tmp); |
799 | 385 g_free(tmp); |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
386 return 0; |
789 | 387 } |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
388 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
|
389 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
390 check <<= 8; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
391 check |= tmp[i]; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
392 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
393 if (mp3_head_check(check, &frameSize)) { |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
394 /* 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
|
395 * 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
|
396 * 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
|
397 */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
398 if (++chkcount >= 3) return 1; |
1978 | 399 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
|
400 check = 0; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
401 chksize = 8; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
402 } |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
403 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
404 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
405 if (++cyc > 32) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
406 return 0; |
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 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
409 return 1; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
410 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
411 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
412 // audacious vfs version |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
413 static int |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
414 audmad_is_our_file(char *filename) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
415 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
416 VFSFile *fin = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
417 gint rtn; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
418 |
1978 | 419 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
|
420 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
421 if (fin == NULL) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
422 return 0; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
423 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
424 rtn = audmad_is_our_fd(filename, fin); |
1978 | 425 aud_vfs_fclose(fin); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
426 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
427 return rtn; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
428 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
429 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
430 static void |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
431 audmad_stop(InputPlayback *playback) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
432 { |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
433 AUDDBG("f: audmad_stop\n"); |
611 | 434 g_mutex_lock(mad_mutex); |
435 info.playback = playback; | |
436 g_mutex_unlock(mad_mutex); | |
437 | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
438 if (decode_thread) { |
611 | 439 |
440 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
|
441 info.playback->playing = 0; |
611 | 442 g_mutex_unlock(mad_mutex); |
443 g_cond_signal(mad_cond); | |
444 | |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
445 AUDDBG("waiting for thread\n"); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
446 g_thread_join(decode_thread); |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
447 AUDDBG("thread done\n"); |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2207
diff
changeset
|
448 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
449 input_term(&info); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
450 decode_thread = NULL; |
611 | 451 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
452 } |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
453 AUDDBG("e: audmad_stop\n"); |
610
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 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
456 static void |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
457 audmad_play_file(InputPlayback *playback) |
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 gboolean rtn; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
460 gchar *url = playback->filename; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
461 |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2207
diff
changeset
|
462 #ifdef AUD_DEBUG |
799 | 463 { |
464 gchar *tmp = g_filename_to_utf8(url, -1, NULL, NULL, NULL); | |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
465 AUDDBG("playing %s\n", tmp); |
799 | 466 g_free(tmp); |
467 } | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
468 #endif /* DEBUG */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
469 |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1326
diff
changeset
|
470 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
|
471 g_message("error initialising input"); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
472 return; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
473 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
474 |
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
|
475 // remote access must use fast scan. |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
476 rtn = input_get_info(&info, aud_vfs_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
|
477 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
478 if (rtn == FALSE) { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
479 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
|
480 /* |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
481 * return; |
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
482 * 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
|
483 * 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
|
484 */ |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
485 } |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
486 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
|
487 info.playback = playback; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
488 info.playback->playing = 1; |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
489 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
|
490 |
1342
ebded68de2dd
madplug: Update plugin for new threading model.
William Pitcock <nenolod@atheme-project.org>
parents:
1329
diff
changeset
|
491 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
|
492 playback->set_pb_ready(playback); |
1342
ebded68de2dd
madplug: Update plugin for new threading model.
William Pitcock <nenolod@atheme-project.org>
parents:
1329
diff
changeset
|
493 decode_loop(&info); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
494 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
495 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
496 static void |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
497 audmad_pause(InputPlayback *playback, short paused) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
498 { |
611 | 499 g_mutex_lock(pb_mutex); |
500 info.playback = playback; | |
501 g_mutex_unlock(pb_mutex); | |
502 playback->output->pause(paused); | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
503 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
504 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
505 static void |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
506 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
|
507 { |
611 | 508 g_mutex_lock(pb_mutex); |
509 info.playback = playback; | |
807 | 510 info.seek = millisecond; |
611 | 511 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
|
512 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
513 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
514 static void |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
515 audmad_seek(InputPlayback *playback, gint time) |
807 | 516 { |
517 audmad_mseek(playback, time * 1000); | |
518 } | |
519 | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
520 /** |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
521 * 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
|
522 * 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
|
523 */ |
611 | 524 static void |
525 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
|
526 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
527 struct mad_info_t myinfo; |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2207
diff
changeset
|
528 #ifdef AUD_DEBUG |
799 | 529 gchar *tmp = g_filename_to_utf8(url, -1, NULL, NULL, NULL); |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
530 AUDDBG("f: audmad_get_song_info: %s\n", tmp); |
799 | 531 g_free(tmp); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
532 #endif /* DEBUG */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
533 |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1326
diff
changeset
|
534 if (input_init(&myinfo, url, NULL) == FALSE) { |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
535 AUDDBG("error initialising input\n"); |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
536 return; |
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
537 } |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
538 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
539 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
|
540 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
|
541 *title = g_strdup(aud_tuple_get_string(myinfo.tuple, -1, "track-name")); |
611 | 542 else |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
543 *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
|
544 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
545 *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
|
546 if(*length == -1) |
738 | 547 *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
|
548 } |
611 | 549 else { |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
550 *title = g_strdup(url); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
551 *length = -1; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
552 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
553 input_term(&myinfo); |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
554 AUDDBG("e: audmad_get_song_info\n"); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
555 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
556 |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
557 static gboolean |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
558 audmad_fill_info(struct mad_info_t *info, VFSFile *fd) |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1326
diff
changeset
|
559 { |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
560 if (fd == NULL || info == NULL) return FALSE; |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
561 AUDDBG("f: audmad_fill_info(): %s\n", fd->uri); |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1326
diff
changeset
|
562 |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
563 if (input_init(info, fd->uri, fd) == FALSE) { |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
564 AUDDBG("audmad_fill_info(): error initialising input\n"); |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
565 return FALSE; |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1326
diff
changeset
|
566 } |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
567 |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
568 info->fileinfo_request = FALSE; /* we don't need to read tuple again */ |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
569 return input_get_info(info, aud_vfs_is_remote(fd->uri) ? TRUE : audmad_config->fast_play_time_calc); |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1326
diff
changeset
|
570 } |
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1326
diff
changeset
|
571 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
572 static void |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
573 audmad_about() |
610
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 static GtkWidget *aboutbox; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
576 gchar *scratch; |
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 if (aboutbox != NULL) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
579 return; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
580 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
581 scratch = g_strdup_printf( |
1361
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
582 _("Audacious MPEG Audio Plugin\n" |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
583 "\n" |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
584 "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
|
585 "\n" |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
586 "Written by:\n" |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
587 " 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
|
588 " 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
|
589 "\n" |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
590 "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
|
591 " Sam Clegg\n" |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
592 "\n" |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
593 "ReplayGain support by:\n" |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
594 " Samuel Krempp"), |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
595 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
|
596 MAD_VERSION_EXTRA); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
597 |
1677
f6f5603a0954
xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
598 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
|
599 scratch, |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
600 _("Ok"), FALSE, NULL, NULL); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
601 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
602 g_free(scratch); |
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 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
|
605 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
|
606 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
607 |
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 * 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
|
610 * Taken from mpg123 plugin. |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
611 */ |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
612 void |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
613 audmad_error(char *error, ...) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
614 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
615 #ifndef NOGUI |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
616 if (!error_dialog) { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
617 va_list args; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
618 char string[256]; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
619 va_start(args, error); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
620 vsnprintf(string, 256, error, args); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
621 va_end(args); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
622 GDK_THREADS_ENTER(); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
623 error_dialog = |
1677
f6f5603a0954
xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
624 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
|
625 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
|
626 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
|
627 &error_dialog); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
628 GDK_THREADS_LEAVE(); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
629 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
630 #endif /* !NOGUI */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
631 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
632 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
633 extern void audmad_configure(); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
634 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
635 static void |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
636 __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
|
637 { |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
638 aud_tuple_associate_string(tuple, nfield, name, value); |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
639 g_free(value); |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
640 } |
611 | 641 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
642 // tuple stuff |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
643 static Tuple * |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
644 __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
|
645 { |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
646 Tuple *tuple = NULL; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
647 gchar *string = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
648 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
649 struct id3_file *id3file = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
650 struct id3_tag *tag = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
651 |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
652 struct mad_info_t myinfo; |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
653 |
1329
4b07404814ca
- reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1328
diff
changeset
|
654 gboolean local_fd = FALSE; |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
655 int length; |
1329
4b07404814ca
- reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1328
diff
changeset
|
656 |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2207
diff
changeset
|
657 #ifdef AUD_DEBUG |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1995
diff
changeset
|
658 string = aud_str_to_utf8(filename); |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
659 AUDDBG("f: mad: audmad_get_song_tuple: %s\n", string); |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
660 g_free(string); |
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
661 string = NULL; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
662 #endif |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
663 |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
664 /* isn't is obfuscated? --eugene */ |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
665 |
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(info.remote && mad_timer_count(info.duration, MAD_UNITS_SECONDS) <= 0){ |
1978 | 667 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
|
668 gchar *tmp = NULL; |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
669 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
|
670 |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2207
diff
changeset
|
671 #ifdef AUD_DEBUG |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1326
diff
changeset
|
672 if(info.playback) |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
673 AUDDBG("info.playback->playing = %d\n",info.playback->playing); |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
674 #endif |
1978 | 675 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
|
676 if(tmp){ |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
677 gchar *scratch; |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
678 |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1995
diff
changeset
|
679 scratch = aud_str_to_utf8(tmp); |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
680 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
|
681 g_free(tmp); |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
682 g_free(scratch); |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
683 |
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
|
684 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
|
685 } |
1978 | 686 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
|
687 if(tmp){ |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
688 gchar *scratch; |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
689 |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1995
diff
changeset
|
690 scratch = aud_str_to_utf8(tmp); |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
691 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
|
692 g_free(tmp); |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
693 g_free(scratch); |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
694 |
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
|
695 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
|
696 } |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1326
diff
changeset
|
697 |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
698 AUDDBG("audmad_get_song_tuple: track_name = %s\n", aud_tuple_get_string(tuple, -1, "track-name")); |
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
699 AUDDBG("audmad_get_song_tuple: stream_name = %s\n", aud_tuple_get_string(tuple, -1, "stream-name")); |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
700 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
701 aud_tuple_associate_int(tuple, FIELD_MTIME, NULL, 0); // this indicates streaming |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
702 AUDDBG("get_song_tuple: remote: tuple\n"); |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
703 return tuple; |
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
704 } |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
705 AUDDBG("get_song_tuple: remote: NULL\n"); |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1326
diff
changeset
|
706 } /* info.remote */ |
611 | 707 |
1978 | 708 // 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
|
709 if(!fd) { |
1978 | 710 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
|
711 if(!fd) |
4b07404814ca
- reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1328
diff
changeset
|
712 return NULL; |
4b07404814ca
- reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1328
diff
changeset
|
713 local_fd = TRUE; |
4b07404814ca
- reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1328
diff
changeset
|
714 } |
4b07404814ca
- reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1328
diff
changeset
|
715 |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
716 if (!audmad_fill_info(&myinfo, fd)) { |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2207
diff
changeset
|
717 AUDDBG("get_song_tuple: error obtaining info\n"); |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
718 if (local_fd) aud_vfs_fclose(fd); |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
719 return NULL; |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
720 } |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
721 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
722 tuple = aud_tuple_new(); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
723 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
|
724 |
1329
4b07404814ca
- reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1328
diff
changeset
|
725 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
|
726 |
773 | 727 if (id3file) { |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
728 |
773 | 729 tag = id3_file_tag(id3file); |
730 if (tag) { | |
1687
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
731 __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
|
732 __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
|
733 __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
|
734 |
773 | 735 // year |
736 string = NULL; | |
737 string = input_id3_get_string(tag, ID3_FRAME_YEAR); //TDRC | |
738 if (!string) | |
739 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
|
740 |
773 | 741 if (string) { |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
742 aud_tuple_associate_int(tuple, FIELD_YEAR, NULL, atoi(string)); |
773 | 743 g_free(string); |
744 string = NULL; | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
745 } |
2241
a5c96af75300
make use of aud_uri_to_display_*()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
746 |
a5c96af75300
make use of aud_uri_to_display_*()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
747 __set_and_free(tuple, FIELD_FILE_NAME, NULL, aud_uri_to_display_basename(filename)); |
a5c96af75300
make use of aud_uri_to_display_*()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
748 __set_and_free(tuple, FIELD_FILE_PATH, NULL, aud_uri_to_display_dirname(filename)); |
a5c96af75300
make use of aud_uri_to_display_*()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
749 aud_tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, extname(filename)); |
773 | 750 |
611 | 751 // length |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
752 length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS); |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
753 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, length); |
773 | 754 |
755 // track number | |
756 string = input_id3_get_string(tag, ID3_FRAME_TRACK); | |
757 if (string) { | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
758 aud_tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atoi(string)); |
773 | 759 g_free(string); |
760 string = NULL; | |
761 } | |
762 // genre | |
1687
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
763 __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
|
764 __set_and_free(tuple, FIELD_COMMENT, NULL, input_id3_get_string(tag, ID3_FRAME_COMMENT)); |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
765 AUDDBG("genre = %s\n", aud_tuple_get_string(tuple, FIELD_GENRE, NULL)); |
611 | 766 } |
773 | 767 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
|
768 } // id3file |
773 | 769 else { // no id3tag |
2241
a5c96af75300
make use of aud_uri_to_display_*()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
770 __set_and_free(tuple, FIELD_FILE_NAME, NULL, aud_uri_to_display_basename(filename)); |
a5c96af75300
make use of aud_uri_to_display_*()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
771 __set_and_free(tuple, FIELD_FILE_PATH, NULL, aud_uri_to_display_dirname(filename)); |
a5c96af75300
make use of aud_uri_to_display_*()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
772 aud_tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, extname(filename)); |
773 | 773 // length |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
774 length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS); |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
775 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, length); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
776 } |
1329
4b07404814ca
- reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1328
diff
changeset
|
777 |
2207
0b67fb27db58
get benefit of FIELD_BITRATE
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2206
diff
changeset
|
778 aud_tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossy"); |
0b67fb27db58
get benefit of FIELD_BITRATE
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2206
diff
changeset
|
779 aud_tuple_associate_int(tuple, FIELD_BITRATE, NULL, myinfo.bitrate / 1000); |
2203
13b8ab116b69
removed debugging stuff. some notes added
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2202
diff
changeset
|
780 |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
781 string = g_strdup_printf("MPEG-1 Audio Layer %d", myinfo.mpeg_layer); |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
782 aud_tuple_associate_string(tuple, FIELD_CODEC, NULL, string); |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
783 g_free(string); |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
784 |
2201
df520f828dcf
Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2153
diff
changeset
|
785 aud_tuple_associate_string(tuple, FIELD_MIMETYPE, NULL, "audio/mpeg"); |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
786 |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
787 input_term(&myinfo); |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
788 |
1329
4b07404814ca
- reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1328
diff
changeset
|
789 if(local_fd) |
1978 | 790 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
|
791 |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
792 AUDDBG("e: mad: audmad_get_song_tuple\n"); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
793 return tuple; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
794 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
795 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
796 static Tuple * |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
797 audmad_get_song_tuple(char *filename) |
1315
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
798 { |
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
799 return __audmad_get_song_tuple(filename, NULL); |
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
800 } |
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
801 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
802 static Tuple * |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
803 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
|
804 { |
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
805 if (!audmad_is_our_fd(filename, fd)) |
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
806 return NULL; |
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
807 |
1978 | 808 aud_vfs_rewind(fd); |
1326
e991d29a9c9a
madplug: Fix ID3v1 tuple building.
William Pitcock <nenolod@atheme-project.org>
parents:
1324
diff
changeset
|
809 |
1315
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
810 return __audmad_get_song_tuple(filename, fd); |
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
811 } |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
812 |
2153
2f7eff0bc6eb
madplug: add .bmu to extensions whitelist (closes bugzilla #49)
William Pitcock <nenolod@atheme.org>
parents:
2124
diff
changeset
|
813 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
|
814 |
1065 | 815 InputPlugin mad_ip = { |
816 .description = "MPEG Audio Plugin", | |
817 .init = audmad_init, | |
818 .about = audmad_about, | |
819 .configure = audmad_configure, | |
820 .is_our_file = audmad_is_our_file, | |
821 .play_file = audmad_play_file, | |
822 .stop = audmad_stop, | |
823 .pause = audmad_pause, | |
824 .seek = audmad_seek, | |
825 .cleanup = audmad_cleanup, | |
826 .get_song_info = audmad_get_song_info, | |
827 .get_song_tuple = audmad_get_song_tuple, | |
828 .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
|
829 .vfs_extensions = fmts, |
1315
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
830 .mseek = audmad_mseek, |
2201
df520f828dcf
Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2153
diff
changeset
|
831 .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
|
832 .update_song_tuple = audmad_update_song_tuple, |
1065 | 833 }; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
834 |
1065 | 835 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
|
836 |
1400
fe0a9cf95642
make use of SIMPLE_INPUT_PLUGIN() as an example.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1395
diff
changeset
|
837 SIMPLE_INPUT_PLUGIN(madplug, madplug_iplist); |
1065 | 838 |
839 InputPlugin *mad_plugin = &mad_ip; |