annotate src/madplug/plugin.c @ 2687:206f0322d221

Remove the obsolete is_our_file() function.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 06 Jun 2008 06:41:10 +0300
parents 45be141b7586
children 17da667fb14d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
1 /*
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
2 * mad plugin for audacious
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 <stdarg.h>
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
32 #include <fcntl.h>
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
33 #include <sys/stat.h>
2202
f76e846d53d9 updating TLEN frame returned
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2201
diff changeset
34 #include "tuple.h"
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
35
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
36 /*
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
37 * Global variables
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
38 */
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
39 audmad_config_t *audmad_config; /**< global configuration */
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
40 GMutex *mad_mutex;
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
41 GMutex *pb_mutex;
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
42 GCond *mad_cond;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
43
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
44 /*
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
45 * static variables
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
46 */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
47 static 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
48 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
49
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
50 #ifndef NOGUI
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
51 static GtkWidget *error_dialog = 0;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
52 #endif
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 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
55
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
56 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
57 { 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
58 { 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
59 { 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
60 { 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
61 { 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
62 };
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
63
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
64 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
65 { 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
66 { -1, -1, -1, -1 }, /* Reserved */
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
67 { 22050, 24000, 16000, -1 }, /* MPEG2 */
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
68 { 44100, 48000, 32000, -1 } /* MPEG1 */
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
69 };
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
70
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
71 /*
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
72 * Function extname (filename)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
73 *
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
74 * 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
75 * filename has no extension.
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
76 *
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
77 */
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
78 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
79 extname(const char *filename)
610
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 gchar *ext = strrchr(filename, '.');
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
82
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
83 if (ext != NULL)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
84 ++ext;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
85
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
86 return ext;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
87 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
88
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
89
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
90 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
91 audmad_init()
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
92 {
2523
769e17da93dd Replaced s/ConfigDb/mcs_handle_t/g, as per changes in the core.
Matti Hamalainen <ccr@tnsp.org>
parents: 2497
diff changeset
93 mcs_handle_t *db = NULL;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
94
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
95 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
96
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
97 audmad_config->dither = TRUE;
2460
a651657361d7 make force reopen audio default
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2393
diff changeset
98 audmad_config->force_reopen_audio = TRUE;
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
99 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
100 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
101 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
102 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
103 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
104
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
105
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
106 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
107 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
108 //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
109 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
110 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
111 &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
112
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 //metadata
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
114 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
115 &audmad_config->fast_play_time_calc);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
116 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
117 &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
118 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
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 //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
121 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
122 &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
123
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
124 //text
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
125 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
126 &audmad_config->title_override);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
127 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
128 &audmad_config->id3_format);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
129
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2050
diff changeset
130 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
131 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
132
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
133 mad_mutex = g_mutex_new();
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
134 pb_mutex = g_mutex_new();
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
135 mad_cond = g_cond_new();
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
136
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
137 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
138 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
139
1995
47a7b26717d4 wow, only one plugin uses aud_mime API. that sucks! :D
William Pitcock <nenolod@atheme.org>
parents: 1979
diff changeset
140 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
141 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
142
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
143 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
144 audmad_cleanup()
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
145 {
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
146 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
147 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
148
802
7ac48f3855b1 [svn] - add cleanup code.
yaz
parents: 801
diff changeset
149 g_cond_free(mad_cond);
7ac48f3855b1 [svn] - add cleanup code.
yaz
parents: 801
diff changeset
150 g_mutex_free(mad_mutex);
7ac48f3855b1 [svn] - add cleanup code.
yaz
parents: 801
diff changeset
151 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
152 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
153
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
154 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
155 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
156 {
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
157 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
158
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
159 /* 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
160 * 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
161 */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
162 if ((head & 0xffe00000) != 0xffe00000)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
163 return FALSE;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
164
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
165 /* 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
166 layer = (head >> 17) & 0x3;
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
167 if (!layer)
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
168 return FALSE; /* 00 = reserved */
897
44a922a4a591 [svn] - fix validation of mpeg2 files, by ccr.
nenolod
parents: 807
diff changeset
169 layer = 4 - layer;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
170
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
171 /* 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
172 bitIndex = (head >> 12) & 0xf;
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
173
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
174 /* 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
175 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
176 return FALSE;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
177
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
178 /* check samplerate index bits (10-11) */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
179 sampleIndex = (head >> 10) & 0x3;
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
180 if (sampleIndex == 0x3)
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
181 return FALSE;
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
182
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
183 /* 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
184 version = (head >> 19) & 0x03;
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
185 switch (version) {
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
186 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
187 case 2: /* 10 = MPEG Version 2 */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
188 if (layer == 1)
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
189 bitRate = mp3_bitrate_table[3][bitIndex];
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
190 else
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
191 bitRate = mp3_bitrate_table[4][bitIndex];
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
192 break;
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
193
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
194 case 1: /* 01 = reserved */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
195 return FALSE;
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
196
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
197 case 3: /* 11 = MPEG Version 1 */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
198 bitRate = mp3_bitrate_table[layer][bitIndex];
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
199 break;
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
200
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
201 default:
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
202 return FALSE;
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
203 }
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
204
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
205 /* check layer II restrictions vs. bitrate */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
206 if (layer == 2) {
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
207 gint chanMode = (head >> 6) & 0x3;
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
208
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
209 if (chanMode == 0x3) {
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
210 /* single channel with bitrate > 192 */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
211 if (bitRate > 192)
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
212 return FALSE;
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
213 } else {
897
44a922a4a591 [svn] - fix validation of mpeg2 files, by ccr.
nenolod
parents: 807
diff changeset
214 /* any other mode with bitrates 32-56 and 80.
44a922a4a591 [svn] - fix validation of mpeg2 files, by ccr.
nenolod
parents: 807
diff changeset
215 * NOTICE! this check is not entirely correct, but I think
44a922a4a591 [svn] - fix validation of mpeg2 files, by ccr.
nenolod
parents: 807
diff changeset
216 * it is sufficient in most cases.
44a922a4a591 [svn] - fix validation of mpeg2 files, by ccr.
nenolod
parents: 807
diff changeset
217 */
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
218 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
219 return FALSE;
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
220 }
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
221 }
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
222
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
223 /* calculate approx. frame size */
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
224 padding = (head >> 9) & 1;
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
225 sampleRate = mp3_samplerate_table[version][sampleIndex];
897
44a922a4a591 [svn] - fix validation of mpeg2 files, by ccr.
nenolod
parents: 807
diff changeset
226 if (layer == 1)
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
227 *frameSize = ((12 * bitRate * 1000 / sampleRate) + padding) * 4;
897
44a922a4a591 [svn] - fix validation of mpeg2 files, by ccr.
nenolod
parents: 807
diff changeset
228 else
44a922a4a591 [svn] - fix validation of mpeg2 files, by ccr.
nenolod
parents: 807
diff changeset
229 *frameSize = (144 * bitRate * 1000) / (sampleRate + padding);
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
230
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
231 /* 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
232 if (((head >> 19) & 1) == 1 &&
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
233 ((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
234 return FALSE;
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 /* 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
237 if ((head & 0xffff0000) == 0xfffe0000)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
238 return FALSE;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
239
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
240 return TRUE;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
241 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
242
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
243 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
244 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
245 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
246 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
247 ((unsigned long) hbuf[1] << 16) |
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
248 ((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
249 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
250
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
251 // 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
252 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
253 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
254 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
255 guint32 check;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
256 gchar *ext = extname(filename);
2685
45be141b7586 Use a bit bigger buffer.
Matti Hamalainen <ccr@tnsp.org>
parents: 2667
diff changeset
257 guchar buf[16];
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
258
2291
1457b35713d9 remove obsolete function
mf0102 <0102@gmx.at>
parents: 2276
diff changeset
259 info.remote = aud_vfs_is_remote(filename);
612
951b24719ce9 [svn] - fix for audmad_is_our_fd()
yaz
parents: 611
diff changeset
260
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
261 /* 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
262 so let's exclude known non-mp3 filename extensions */
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
263 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
264 (!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
265 !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
266 !strcasecmp("wma", ext) )
789
354c69a939bc [svn] revising vfs_fread() check code.
yaz
parents: 788
diff changeset
267 )
354c69a939bc [svn] revising vfs_fread() check code.
yaz
parents: 788
diff changeset
268 return 0;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
269
789
354c69a939bc [svn] revising vfs_fread() check code.
yaz
parents: 788
diff changeset
270 if (fin == NULL) {
2667
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
271 g_message("fin = NULL for %s", filename);
789
354c69a939bc [svn] revising vfs_fread() check code.
yaz
parents: 788
diff changeset
272 return 0;
354c69a939bc [svn] revising vfs_fread() check code.
yaz
parents: 788
diff changeset
273 }
788
2461b711162b [svn] - revert r1664 as it breaks too much
nenolod
parents: 783
diff changeset
274
2685
45be141b7586 Use a bit bigger buffer.
Matti Hamalainen <ccr@tnsp.org>
parents: 2667
diff changeset
275 if (aud_vfs_fread(buf, 1, sizeof(buf), fin) == 0) {
2667
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
276 g_message("aud_vfs_fread failed @1 %s", filename);
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
277 return 0;
789
354c69a939bc [svn] revising vfs_fread() check code.
yaz
parents: 788
diff changeset
278 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
279
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
280 check = mp3_head_convert(buf);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
281
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
282 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
283 return 1;
782
6f519e34ddf0 [svn] - reject files which use Ogg container magic
nenolod
parents: 773
diff changeset
284 else if (memcmp(buf, "OggS", 4) == 0)
6f519e34ddf0 [svn] - reject files which use Ogg container magic
nenolod
parents: 773
diff changeset
285 return 0;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
286 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
287 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
288 aud_vfs_fseek(fin, 4, SEEK_CUR);
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
289 if(aud_vfs_fread(buf, 1, 4, fin) == 0) {
2667
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
290 g_message("aud_vfs_fread failed @2 %s", filename);
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
291 return 0;
789
354c69a939bc [svn] revising vfs_fread() check code.
yaz
parents: 788
diff changeset
292 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
293
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
294 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
295 return 1;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
296 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
297
2667
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
298 /* Check stream data for frame header(s)
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
299 */
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
300 guchar chkbuf[2048];
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
301 gint chkret, i, framesize, cyc, chkcount, chksize = sizeof(chkbuf);
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
302
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
303 for (cyc = chkcount = 0; cyc < 32; cyc++)
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
304 {
2667
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
305 if ((chkret = aud_vfs_fread(chkbuf, 1, chksize, fin)) == 0)
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
306 break;
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
307
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
308 for (i = 0; i < chkret; i++)
610
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 check <<= 8;
2667
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
311 check |= chkbuf[i];
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
312
2667
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
313 if (mp3_head_check(check, &framesize)) {
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
314 /* 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
315 * 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
316 * 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
317 */
2667
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
318 if (++chkcount >= 4) return 1;
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
319 aud_vfs_fseek(fin, framesize-8, SEEK_CUR);
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
320 check = 0;
2667
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
321 chksize = 16;
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
322 } else {
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
323 aud_vfs_fseek(fin, chksize, SEEK_CUR);
801
dd06b14a43a9 [svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents: 799
diff changeset
324 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
325 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
326 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
327
2667
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
328 g_message("Rejecting %s (not an MP3 file?)", filename);
84d34cd6aa71 Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
329 return 0;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
330 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
331
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
332 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
333 audmad_stop(InputPlayback *playback)
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
334 {
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2241
diff changeset
335 AUDDBG("f: audmad_stop\n");
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
336 g_mutex_lock(mad_mutex);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
337 info.playback = playback;
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
338 g_mutex_unlock(mad_mutex);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
339
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
340 if (decode_thread) {
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
341
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
342 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
343 info.playback->playing = 0;
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
344 g_mutex_unlock(mad_mutex);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
345 g_cond_signal(mad_cond);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
346
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2241
diff changeset
347 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
348 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
349 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
350
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
351 input_term(&info);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
352 decode_thread = NULL;
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
353
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
354 }
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2241
diff changeset
355 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
356 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
357
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
358 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
359 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
360 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
361 gboolean rtn;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
362 gchar *url = playback->filename;
2390
bd9673d8b7d5 converted to new sound engine scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2344
diff changeset
363 ReplayGainInfo rg_info;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
364
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2207
diff changeset
365 #ifdef AUD_DEBUG
799
d200de50a1fc [svn] - convert filename into utf8 in debug messages.
yaz
parents: 789
diff changeset
366 {
d200de50a1fc [svn] - convert filename into utf8 in debug messages.
yaz
parents: 789
diff changeset
367 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
368 AUDDBG("playing %s\n", tmp);
799
d200de50a1fc [svn] - convert filename into utf8 in debug messages.
yaz
parents: 789
diff changeset
369 g_free(tmp);
d200de50a1fc [svn] - convert filename into utf8 in debug messages.
yaz
parents: 789
diff changeset
370 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
371 #endif /* DEBUG */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
372
1328
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
373 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
374 g_message("error initialising input");
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
375 return;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
376 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
377
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
378 // 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
379 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
380
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
381 if (rtn == FALSE) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
382 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
383 /*
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
384 * return;
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
385 * 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
386 * 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
387 */
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
388 }
2390
bd9673d8b7d5 converted to new sound engine scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2344
diff changeset
389
bd9673d8b7d5 converted to new sound engine scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2344
diff changeset
390 rg_info.track_gain = info.replaygain_track_scale;
bd9673d8b7d5 converted to new sound engine scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2344
diff changeset
391 rg_info.track_peak = info.replaygain_track_peak;
bd9673d8b7d5 converted to new sound engine scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2344
diff changeset
392 rg_info.album_gain = info.replaygain_album_scale;
bd9673d8b7d5 converted to new sound engine scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2344
diff changeset
393 rg_info.album_peak = info.replaygain_album_peak;
2392
4ad6e7dfb389 imported 5298b10777b3 by Eugene Zagidullin.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2390
diff changeset
394 AUDDBG("Replay Gain info:\n");
4ad6e7dfb389 imported 5298b10777b3 by Eugene Zagidullin.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2390
diff changeset
395 AUDDBG("* track gain: %+f dB\n", rg_info.track_gain);
4ad6e7dfb389 imported 5298b10777b3 by Eugene Zagidullin.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2390
diff changeset
396 AUDDBG("* track peak: %f\n", rg_info.track_peak);
4ad6e7dfb389 imported 5298b10777b3 by Eugene Zagidullin.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2390
diff changeset
397 AUDDBG("* album gain: %+f dB\n", rg_info.album_gain);
4ad6e7dfb389 imported 5298b10777b3 by Eugene Zagidullin.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2390
diff changeset
398 AUDDBG("* album peak: %f\n", rg_info.album_peak);
2390
bd9673d8b7d5 converted to new sound engine scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2344
diff changeset
399 playback->set_replaygain_info(playback, &rg_info);
bd9673d8b7d5 converted to new sound engine scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2344
diff changeset
400
613
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
401 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
402 info.playback = playback;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
403 info.playback->playing = 1;
613
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
404 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
405
1342
ebded68de2dd madplug: Update plugin for new threading model.
William Pitcock <nenolod@atheme-project.org>
parents: 1329
diff changeset
406 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
407 playback->set_pb_ready(playback);
1342
ebded68de2dd madplug: Update plugin for new threading model.
William Pitcock <nenolod@atheme-project.org>
parents: 1329
diff changeset
408 decode_loop(&info);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
409 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
410
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
411 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
412 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
413 {
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
414 g_mutex_lock(pb_mutex);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
415 info.playback = playback;
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
416 g_mutex_unlock(pb_mutex);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
417 playback->output->pause(paused);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
418 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
419
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
420 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
421 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
422 {
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
423 g_mutex_lock(pb_mutex);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
424 info.playback = playback;
807
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 802
diff changeset
425 info.seek = millisecond;
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
426 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
427 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
428
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
429 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
430 audmad_seek(InputPlayback *playback, gint time)
807
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 802
diff changeset
431 {
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 802
diff changeset
432 audmad_mseek(playback, time * 1000);
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 802
diff changeset
433 }
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 802
diff changeset
434
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
435 /**
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
436 * 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
437 * 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
438 */
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
439 static void
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
440 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
441 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
442 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
443 #ifdef AUD_DEBUG
799
d200de50a1fc [svn] - convert filename into utf8 in debug messages.
yaz
parents: 789
diff changeset
444 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
445 AUDDBG("f: audmad_get_song_info: %s\n", tmp);
799
d200de50a1fc [svn] - convert filename into utf8 in debug messages.
yaz
parents: 789
diff changeset
446 g_free(tmp);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
447 #endif /* DEBUG */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
448
1328
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
449 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
450 AUDDBG("error initialising input\n");
613
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
451 return;
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
452 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
453
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
454 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
455 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
456 *title = g_strdup(aud_tuple_get_string(myinfo.tuple, -1, "track-name"));
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
457 else
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
458 *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
459
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
460 *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
461 if(*length == -1)
738
6ea974a229a8 [svn] - add read/write support for TLEN frame.
yaz
parents: 676
diff changeset
462 *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
463 }
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
464 else {
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
465 *title = g_strdup(url);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
466 *length = -1;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
467 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
468 input_term(&myinfo);
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2241
diff changeset
469 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
470 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
471
2205
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
472 static gboolean
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
473 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
474 {
2205
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
475 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
476 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
477
2205
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
478 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
479 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
480 return FALSE;
1328
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
481 }
2205
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
482
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
483 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
484 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
485 }
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
486
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
487 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
488 audmad_about()
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
489 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
490 static GtkWidget *aboutbox;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
491 gchar *scratch;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
492
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
493 if (aboutbox != NULL)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
494 return;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
495
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
496 scratch = g_strdup_printf(
1361
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
497 _("Audacious MPEG Audio Plugin\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
498 "\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
499 "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
500 "\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
501 "Written by:\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
502 " 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
503 " 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
504 "\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
505 "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
506 " Sam Clegg\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
507 "\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
508 "ReplayGain support by:\n"
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
509 " Samuel Krempp"),
f8b498451a84 - Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents: 1329
diff changeset
510 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
511 MAD_VERSION_EXTRA);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
512
1677
f6f5603a0954 xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents: 1485
diff changeset
513 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
514 scratch,
1302
1d3b02d1842b Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents: 1277
diff changeset
515 _("Ok"), FALSE, NULL, NULL);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
516
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
517 g_free(scratch);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
518
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
519 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
520 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
521 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
522
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
523 /**
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
524 * 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
525 * Taken from mpg123 plugin.
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
526 */
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
527 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
528 audmad_error(char *error, ...)
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
529 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
530 #ifndef NOGUI
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
531 if (!error_dialog) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
532 va_list args;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
533 char string[256];
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
534 va_start(args, error);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
535 vsnprintf(string, 256, error, args);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
536 va_end(args);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
537 GDK_THREADS_ENTER();
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
538 error_dialog =
1677
f6f5603a0954 xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents: 1485
diff changeset
539 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
540 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
541 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
542 &error_dialog);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
543 GDK_THREADS_LEAVE();
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
544 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
545 #endif /* !NOGUI */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
546 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
547
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
548 extern void audmad_configure();
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
549
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
550 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
551 __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
552 {
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
553 aud_tuple_associate_string(tuple, nfield, name, value);
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
554 g_free(value);
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
555 }
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
556
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
557 // 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
558 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
559 __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
560 {
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
561 Tuple *tuple = NULL;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
562 gchar *string = NULL;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
563
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
564 struct id3_file *id3file = NULL;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
565 struct id3_tag *tag = NULL;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
566
2205
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
567 struct mad_info_t myinfo;
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
568
1329
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
569 gboolean local_fd = FALSE;
2205
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
570 int length;
1329
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
571
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2207
diff changeset
572 #ifdef AUD_DEBUG
2050
2ffc6a69fcd1 string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents: 1995
diff changeset
573 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
574 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
575 g_free(string);
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
576 string = NULL;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
577 #endif
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
578
2205
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
579 /* isn't is obfuscated? --eugene */
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
580
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
581 if(info.remote && mad_timer_count(info.duration, MAD_UNITS_SECONDS) <= 0){
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
582 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
583 gchar *tmp = NULL;
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
584 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
585
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2207
diff changeset
586 #ifdef AUD_DEBUG
1328
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
587 if(info.playback)
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2241
diff changeset
588 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
589 #endif
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
590 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
591 if(tmp){
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
592 gchar *scratch;
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
593
2050
2ffc6a69fcd1 string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents: 1995
diff changeset
594 scratch = aud_str_to_utf8(tmp);
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
595 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
596 g_free(tmp);
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
597 g_free(scratch);
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
598
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
599 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
600 }
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
601 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
602 if(tmp){
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
603 gchar *scratch;
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
604
2050
2ffc6a69fcd1 string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents: 1995
diff changeset
605 scratch = aud_str_to_utf8(tmp);
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
606 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
607 g_free(tmp);
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
608 g_free(scratch);
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
609
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
610 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
611 }
1328
38fb3bb3e21e - make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1326
diff changeset
612
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2241
diff changeset
613 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
614 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
615 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1);
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
616 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
617 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
618 return tuple;
85a70ace8c02 [svn] - press F5 on not yet played stream no longer hangs.
yaz
parents: 612
diff changeset
619 }
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2241
diff changeset
620 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
621 } /* info.remote */
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
622
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
623 // 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
624 if(!fd) {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
625 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
626 if(!fd)
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
627 return NULL;
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
628 local_fd = TRUE;
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
629 }
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
630
2205
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
631 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
632 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
633 if (local_fd) aud_vfs_fclose(fd);
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
634 return NULL;
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
635 }
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
636
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
637 tuple = aud_tuple_new();
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
638 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
639
1329
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
640 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
641
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
642 if (id3file) {
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
643
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
644 tag = id3_file_tag(id3file);
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
645 if (tag) {
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1485
diff changeset
646 __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
647 __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
648 __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
649
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
650 // year
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
651 string = NULL;
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
652 string = input_id3_get_string(tag, ID3_FRAME_YEAR); //TDRC
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
653 if (!string)
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
654 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
655
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
656 if (string) {
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
657 aud_tuple_associate_int(tuple, FIELD_YEAR, NULL, atoi(string));
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
658 g_free(string);
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
659 string = NULL;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
660 }
2241
a5c96af75300 make use of aud_uri_to_display_*()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
661
a5c96af75300 make use of aud_uri_to_display_*()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
662 __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
663 __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
664 aud_tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, extname(filename));
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
665
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
666 // length
2205
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
667 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
668 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, length);
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
669
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
670 // track number
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
671 string = input_id3_get_string(tag, ID3_FRAME_TRACK);
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
672 if (string) {
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1738
diff changeset
673 aud_tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atoi(string));
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
674 g_free(string);
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
675 string = NULL;
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
676 }
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
677 // genre
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1485
diff changeset
678 __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
679 __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
680 AUDDBG("genre = %s\n", aud_tuple_get_string(tuple, FIELD_GENRE, NULL));
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
681 }
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
682 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
683 } // id3file
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
684 else { // no id3tag
2241
a5c96af75300 make use of aud_uri_to_display_*()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
685 __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
686 __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
687 aud_tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, extname(filename));
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
688 // length
2205
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
689 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
690 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
691 }
1329
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
692
2207
0b67fb27db58 get benefit of FIELD_BITRATE
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2206
diff changeset
693 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
694 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
695
2205
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
696 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
697 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
698 g_free(string);
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
699
2201
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2153
diff changeset
700 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
701
2faee266ea1e madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2203
diff changeset
702 input_term(&myinfo);
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1400
diff changeset
703
1329
4b07404814ca - reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1328
diff changeset
704 if(local_fd)
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
705 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
706
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2241
diff changeset
707 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
708 return tuple;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
709 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
710
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
711 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
712 audmad_get_song_tuple(char *filename)
1315
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
713 {
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
714 return __audmad_get_song_tuple(filename, NULL);
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
715 }
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
716
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
717 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
718 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
719 {
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
720 if (!audmad_is_our_fd(filename, fd))
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
721 return NULL;
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
722
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
723 aud_vfs_rewind(fd);
1326
e991d29a9c9a madplug: Fix ID3v1 tuple building.
William Pitcock <nenolod@atheme-project.org>
parents: 1324
diff changeset
724
1315
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
725 return __audmad_get_song_tuple(filename, fd);
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
726 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
727
2153
2f7eff0bc6eb madplug: add .bmu to extensions whitelist (closes bugzilla #49)
William Pitcock <nenolod@atheme.org>
parents: 2124
diff changeset
728 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
729
1065
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
730 InputPlugin mad_ip = {
2393
6d47059bce36 removed 'experimental' from description.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2392
diff changeset
731 .description = "MPEG Audio Plugin",
1065
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
732 .init = audmad_init,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
733 .about = audmad_about,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
734 .configure = audmad_configure,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
735 .play_file = audmad_play_file,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
736 .stop = audmad_stop,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
737 .pause = audmad_pause,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
738 .seek = audmad_seek,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
739 .cleanup = audmad_cleanup,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
740 .get_song_info = audmad_get_song_info,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
741 .get_song_tuple = audmad_get_song_tuple,
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
742 .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
743 .vfs_extensions = fmts,
1315
e3c991e485ed madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents: 1302
diff changeset
744 .mseek = audmad_mseek,
2201
df520f828dcf Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2153
diff changeset
745 .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
746 .update_song_tuple = audmad_update_song_tuple,
1065
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
747 };
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
748
1065
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
749 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
750
1400
fe0a9cf95642 make use of SIMPLE_INPUT_PLUGIN() as an example.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1395
diff changeset
751 SIMPLE_INPUT_PLUGIN(madplug, madplug_iplist);
1065
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
752
b3b02e58429f [svn] - convert madplug to plugin API v2
nenolod
parents: 1033
diff changeset
753 InputPlugin *mad_plugin = &mad_ip;