Mercurial > audlegacy-plugins
annotate src/madplug/plugin.c @ 2729:c56305e38520
Make things less nazi.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Sat, 28 Jun 2008 23:54:30 -0500 |
parents | 17da667fb14d |
children | 324f950774cb |
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 | 40 GMutex *mad_mutex; |
41 GMutex *pb_mutex; | |
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 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
54 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
|
55 { 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
|
56 { 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
|
57 { 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
|
58 { 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
|
59 { 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
|
60 }; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
61 |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
62 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
|
63 { 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
|
64 { -1, -1, -1, -1 }, /* Reserved */ |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
65 { 22050, 24000, 16000, -1 }, /* MPEG2 */ |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
66 { 44100, 48000, 32000, -1 } /* MPEG1 */ |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
67 }; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
68 |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
69 typedef struct { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
70 gint version, |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
71 layer, |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
72 bitRate, |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
73 sampleRate, |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
74 size, |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
75 lsf; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
76 gboolean hasCRC; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
77 } mp3_frame_t; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
78 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
79 /* |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
80 * Function extname (filename) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
81 * |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
82 * 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
|
83 * filename has no extension. |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
84 * |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
85 */ |
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
|
86 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
|
87 extname(const char *filename) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
88 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
89 gchar *ext = strrchr(filename, '.'); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
90 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
91 if (ext != NULL) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
92 ++ext; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
93 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
94 return ext; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
95 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
96 |
611 | 97 |
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
|
98 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
|
99 audmad_init() |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
100 { |
2523
769e17da93dd
Replaced s/ConfigDb/mcs_handle_t/g, as per changes in the core.
Matti Hamalainen <ccr@tnsp.org>
parents:
2497
diff
changeset
|
101 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
|
102 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
103 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
|
104 |
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
|
105 audmad_config->dither = TRUE; |
2460
a651657361d7
make force reopen audio default
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2393
diff
changeset
|
106 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
|
107 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
|
108 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
|
109 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
|
110 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
|
111 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
|
112 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
113 |
2124 | 114 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
|
115 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
|
116 //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
|
117 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
|
118 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
|
119 &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
|
120 |
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 //metadata |
2124 | 122 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
|
123 &audmad_config->fast_play_time_calc); |
2124 | 124 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
|
125 &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
|
126 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
|
127 |
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 //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
|
129 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
|
130 &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
|
131 |
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
|
132 //text |
2124 | 133 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
|
134 &audmad_config->title_override); |
2124 | 135 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
|
136 &audmad_config->id3_format); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
137 |
2124 | 138 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
|
139 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
140 |
611 | 141 mad_mutex = g_mutex_new(); |
142 pb_mutex = g_mutex_new(); | |
143 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
|
144 |
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
|
145 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
|
146 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
|
147 |
1995
47a7b26717d4
wow, only one plugin uses aud_mime API. that sucks! :D
William Pitcock <nenolod@atheme.org>
parents:
1979
diff
changeset
|
148 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
|
149 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
150 |
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
|
151 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
|
152 audmad_cleanup() |
610
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 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
|
155 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
|
156 |
802 | 157 g_cond_free(mad_cond); |
158 g_mutex_free(mad_mutex); | |
159 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
|
160 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
161 |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
162 /* Validate a MPEG Audio header and extract some information from it. |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
163 * References used: |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
164 * http://www.mp3-tech.org/programmer/frame_header.html |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
165 * http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
166 */ |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
167 static gint |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
168 mp3_head_validate(guint32 head, mp3_frame_t *frame) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
169 { |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
170 gint bitIndex, sampleIndex, padding; |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
171 |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
172 /* 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
|
173 if ((head & 0xffe00000) != 0xffe00000) |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
174 return -1; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
175 |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
176 /* check for LSF */ |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
177 if ((head >> 20) & 1) |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
178 frame->lsf = ((head >> 19) & 1) ? 0 : 1; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
179 else |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
180 frame->lsf = 1; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
181 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
182 /* check if layer bits (17-18) are good */ |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
183 frame->layer = (head >> 17) & 3; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
184 if (frame->layer == 0) |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
185 return -2; /* 00 = reserved */ |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
186 frame->layer = 4 - frame->layer; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
187 |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
188 /* check CRC bit. if set, a 16-bit CRC follows header (not counted in frameSize!) */ |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
189 frame->hasCRC = (head >> 16) & 1; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
190 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
191 /* 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
|
192 bitIndex = (head >> 12) & 0xf; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
193 |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
194 /* 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
|
195 if (bitIndex == 0xf || bitIndex == 0) |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
196 return -3; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
197 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
198 /* check samplerate index bits (10-11) */ |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
199 sampleIndex = (head >> 10) & 3; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
200 if (sampleIndex == 3) |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
201 return -4; |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
202 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
203 /* check version bits (19-20) and get bitRate */ |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
204 frame->version = (head >> 19) & 0x03; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
205 switch (frame->version) { |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
206 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
|
207 case 2: /* 10 = MPEG Version 2 */ |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
208 if (frame->layer == 1) |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
209 frame->bitRate = mp3_bitrate_table[3][bitIndex]; |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
210 else |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
211 frame->bitRate = mp3_bitrate_table[4][bitIndex]; |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
212 break; |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
213 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
214 case 1: /* 01 = reserved */ |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
215 return -5; |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
216 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
217 case 3: /* 11 = MPEG Version 1 */ |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
218 frame->bitRate = mp3_bitrate_table[frame->layer - 1][bitIndex]; |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
219 break; |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
220 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
221 default: |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
222 return -6; |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
223 } |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
224 |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
225 if (frame->bitRate < 0) |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
226 return -7; |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
227 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
228 /* check layer II restrictions vs. bitrate */ |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
229 if (frame->layer == 2) { |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
230 gint chanMode = (head >> 6) & 0x3; |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
231 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
232 if (chanMode == 0x3) { |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
233 /* single channel with bitrate > 192 */ |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
234 if (frame->bitRate > 192) |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
235 return -8; |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
236 } else { |
897 | 237 /* any other mode with bitrates 32-56 and 80. |
238 * NOTICE! this check is not entirely correct, but I think | |
239 * it is sufficient in most cases. | |
240 */ | |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
241 if (((frame->bitRate >= 32 && frame->bitRate <= 56) || frame->bitRate == 80)) |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
242 return -9; |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
243 } |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
244 } |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
245 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
246 /* calculate approx. frame size */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
247 padding = (head >> 9) & 1; |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
248 frame->sampleRate = mp3_samplerate_table[frame->version][sampleIndex]; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
249 if (frame->sampleRate < 0) |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
250 return -10; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
251 |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
252 switch (frame->layer) { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
253 case 1: |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
254 frame->size = ((12 * 1000 * frame->bitRate) / frame->sampleRate + padding) * 4; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
255 break; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
256 |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
257 case 2: |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
258 frame->size = (144 * 1000 * frame->bitRate) / frame->sampleRate + padding; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
259 break; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
260 |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
261 case 3: |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
262 default: |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
263 frame->size = (144 * 1000 * frame->bitRate) / (frame->sampleRate << frame->lsf) + padding; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
264 break; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
265 } |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
266 |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
267 return 0; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
268 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
269 |
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
|
270 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
|
271 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
|
272 { |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
273 return |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
274 ((guint32) hbuf[0] << 24) | |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
275 ((guint32) hbuf[1] << 16) | |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
276 ((guint32) hbuf[2] << 8) | |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
277 ((guint32) hbuf[3]); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
278 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
279 |
2729
c56305e38520
Make things less nazi.
William Pitcock <nenolod@atheme.org>
parents:
2688
diff
changeset
|
280 #if 1 |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
281 static gchar *mp3_ver_table[4] = { "2.5", "INVALID", "2", "1" }; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
282 #define LULZ(...) do { fprintf(stderr, "madprobe: "); fprintf(stderr, __VA_ARGS__); } while (0) |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
283 #define LOL(...) do { fprintf(stderr, __VA_ARGS__); } while (0) |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
284 #else |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
285 #define LULZ(...) do { } while(0) |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
286 #define LOL(...) do { } while(0) |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
287 #endif |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
288 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
289 // 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
|
290 static int |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
291 audmad_is_our_fd(gchar *filename, VFSFile *fin) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
292 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
293 gchar *ext = extname(filename); |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
294 guint32 head = 0; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
295 guchar chkbuf[2048]; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
296 gint state, |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
297 next = -1, |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
298 tries = 0, |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
299 chksize = 0, |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
300 chkpos = 0, |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
301 chkcount = 0, |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
302 res, resync_max = -1, |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
303 skip = 0; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
304 glong streampos = 0; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
305 mp3_frame_t frame, prev; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
306 |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
307 enum { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
308 STATE_HEADERS, |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
309 STATE_REBUFFER, |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
310 STATE_VALIDATE, |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
311 STATE_GOTO_NEXT, |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
312 STATE_GET_NEXT, |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
313 STATE_RESYNC, |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
314 STATE_RESYNC_DO, |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
315 STATE_FATAL |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
316 }; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
317 |
2291 | 318 info.remote = aud_vfs_is_remote(filename); |
612 | 319 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
320 /* 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
|
321 so let's exclude known non-mp3 filename extensions */ |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
322 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
|
323 (!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
|
324 !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
|
325 !strcasecmp("wma", ext) ) |
789 | 326 ) |
327 return 0; | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
328 |
789 | 329 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
|
330 g_message("fin = NULL for %s", filename); |
789 | 331 return 0; |
332 } | |
788 | 333 |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
334 state = STATE_REBUFFER; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
335 next = STATE_HEADERS; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
336 |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
337 /* Check stream data for frame header(s). We employ a simple |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
338 * state-machine approach here to find number of sequential |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
339 * valid MPEG frame headers (with similar attributes). |
2667
84d34cd6aa71
Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents:
2576
diff
changeset
|
340 */ |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
341 do { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
342 switch (state) { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
343 case STATE_HEADERS: |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
344 LULZ("check headers\n"); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
345 /* Check read size */ |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
346 if (chksize < 32) { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
347 LULZ("headers check failed, not enough data!\n"); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
348 state = STATE_FATAL; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
349 } else { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
350 state = STATE_GET_NEXT; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
351 |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
352 if (memcmp(&chkbuf[chkpos], "ID3", 3) == 0) { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
353 /* Skip ID3 header */ |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
354 guint tagsize = (chkbuf[chkpos+6] & 0x7f); tagsize <<= 7; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
355 tagsize |= (chkbuf[chkpos+7] & 0x7f); tagsize <<= 7; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
356 tagsize |= (chkbuf[chkpos+8] & 0x7f); tagsize <<= 7; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
357 tagsize |= (chkbuf[chkpos+9] & 0x7f); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
358 |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
359 LULZ("ID3 size = %08x\n", tagsize); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
360 state = STATE_GOTO_NEXT; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
361 skip = tagsize + 10; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
362 } else |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
363 if (memcmp(&chkbuf[chkpos], "OggS", 4) == 0) |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
364 return 0; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
365 else |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
366 if (memcmp(&chkbuf[chkpos], "RIFF", 4) == 0 && |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
367 memcmp(&chkbuf[chkpos+8], "RMP3", 4) == 0) |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
368 return 1; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
369 } |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
370 break; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
371 |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
372 case STATE_REBUFFER: |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
373 streampos = aud_vfs_ftell(fin); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
374 if ((chksize = aud_vfs_fread(chkbuf, 1, sizeof(chkbuf), fin)) == 0) |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
375 state = STATE_FATAL; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
376 else { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
377 chkpos = 0; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
378 state = next; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
379 } |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
380 LULZ("rebuffered = %d bytes\n", chksize); |
2667
84d34cd6aa71
Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents:
2576
diff
changeset
|
381 break; |
84d34cd6aa71
Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents:
2576
diff
changeset
|
382 |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
383 case STATE_VALIDATE: |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
384 LULZ("validate %08x .. ", head); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
385 /* Check for valid header */ |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
386 if ((res = mp3_head_validate(head, &frame)) >= 0) { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
387 LOL("[is MPEG%s/layer %d, %dHz, %dkbps]", |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
388 mp3_ver_table[frame.version], frame.layer, frame.sampleRate, frame.bitRate); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
389 state = STATE_GOTO_NEXT; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
390 skip = frame.size; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
391 chkcount++; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
392 if (chkcount > 1) { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
393 if (frame.sampleRate != prev.sampleRate || |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
394 frame.layer != prev.layer || |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
395 frame.version != prev.version) { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
396 /* Not similar frame... */ |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
397 LOL(" .. but does not match (%d)!\n", chkcount); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
398 state = STATE_RESYNC; |
2729
c56305e38520
Make things less nazi.
William Pitcock <nenolod@atheme.org>
parents:
2688
diff
changeset
|
399 } else if (chkcount >= 3) { |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
400 /* Okay, accept this stream */ |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
401 LOL(" .. accepted as mp3!!!\n"); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
402 return 1; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
403 } else { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
404 LOL(" .. match %d\n", chkcount); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
405 } |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
406 } else { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
407 /* First valid frame of sequence */ |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
408 memcpy(&prev, &frame, sizeof(mp3_frame_t)); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
409 LOL(" .. first synced\n"); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
410 } |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
411 } else { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
412 /* Nope, try (re)synchronizing */ |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
413 if (chkcount > 1) { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
414 LOL("no (%d), trying quick resync ..\n", res); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
415 state = STATE_RESYNC_DO; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
416 resync_max = 32; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
417 } else { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
418 LOL("no (%d)\n", res); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
419 state = STATE_RESYNC; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
420 } |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
421 } |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
422 break; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
423 |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
424 case STATE_GOTO_NEXT: |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
425 LULZ("goto next (%x :: %x < %x) ? ", chkpos, skip, chksize); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
426 /* Check if we have the next possible header in buffer? */ |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
427 gint tmppos = chkpos + skip + sizeof(guint32); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
428 if (tmppos < chksize) { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
429 LOL("[in buffer]\n"); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
430 chkpos += skip; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
431 state = STATE_GET_NEXT; |
2667
84d34cd6aa71
Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents:
2576
diff
changeset
|
432 } else { |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
433 /* No, re-fill buffer and try again .. */ |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
434 LOL("[rebuffering: %x, %x]\n", skip, chkpos + skip - chksize); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
435 aud_vfs_fseek(fin, chkpos + skip - chksize, SEEK_CUR); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
436 next = STATE_GET_NEXT; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
437 state = STATE_REBUFFER; |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
438 } |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
439 break; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
440 |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
441 case STATE_GET_NEXT: |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
442 /* Get a header */ |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
443 LULZ("get next @ bufpos=%08x, streampos=%08lx, realpos=%08lx\n", chkpos, streampos, streampos+chkpos); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
444 head = mp3_head_convert(&chkbuf[chkpos]); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
445 //chkpos += sizeof(guint32); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
446 state = STATE_VALIDATE; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
447 break; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
448 |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
449 case STATE_RESYNC: |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
450 LULZ("resyncing try #%d ..\n", tries); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
451 /* Re-synchronize aka try to find a valid header */ |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
452 head = 0; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
453 chkcount = 0; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
454 resync_max = -1; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
455 state = STATE_RESYNC_DO; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
456 tries++; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
457 break; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
458 |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
459 case STATE_RESYNC_DO: |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
460 /* Scan for valid frame header */ |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
461 for (; chkpos < chksize; chkpos++) { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
462 head <<= 8; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
463 head |= chkbuf[chkpos]; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
464 |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
465 if (mp3_head_validate(head, &frame) >= 0) { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
466 /* Found, exit resync */ |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
467 chkpos -= 3; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
468 LULZ("resync found @ %x\n", chkpos); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
469 state = STATE_VALIDATE; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
470 break; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
471 } |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
472 |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
473 /* Check for maximum bytes to search */ |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
474 if (resync_max > 0) { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
475 resync_max--; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
476 if (resync_max == 0) { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
477 state = STATE_RESYNC; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
478 break; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
479 } |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
480 } |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
481 } |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
482 if (state == STATE_RESYNC_DO) { |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
483 /* Not found, refill buffer */ |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
484 next = state; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
485 state = STATE_REBUFFER; |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
486 } |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
487 break; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
488 } |
2688
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
489 } while (state != STATE_FATAL && tries < 16); |
17da667fb14d
A completely rewritten approach for probing MPEG Audio files, using a
Matti Hamalainen <ccr@tnsp.org>
parents:
2687
diff
changeset
|
490 /* Give up after 16 failed resync attempts or fatal errors */ |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
491 |
2667
84d34cd6aa71
Experimental changes in MADPlug's probing function to lessen chance of misdetection
Matti Hamalainen <ccr@tnsp.org>
parents:
2576
diff
changeset
|
492 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
|
493 return 0; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
494 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
495 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
496 static void |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2340
diff
changeset
|
497 audmad_stop(InputPlayback *playback) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
498 { |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
499 AUDDBG("f: audmad_stop\n"); |
611 | 500 g_mutex_lock(mad_mutex); |
501 info.playback = playback; | |
502 g_mutex_unlock(mad_mutex); | |
503 | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
504 if (decode_thread) { |
611 | 505 |
506 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
|
507 info.playback->playing = 0; |
611 | 508 g_mutex_unlock(mad_mutex); |
509 g_cond_signal(mad_cond); | |
510 | |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
511 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
|
512 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
|
513 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
|
514 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
515 input_term(&info); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
516 decode_thread = NULL; |
611 | 517 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
518 } |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
519 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
|
520 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
521 |
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
|
522 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
|
523 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
|
524 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
525 gboolean rtn; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
526 gchar *url = playback->filename; |
2390
bd9673d8b7d5
converted to new sound engine scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2344
diff
changeset
|
527 ReplayGainInfo rg_info; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
528 |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2207
diff
changeset
|
529 #ifdef AUD_DEBUG |
799 | 530 { |
531 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
|
532 AUDDBG("playing %s\n", tmp); |
799 | 533 g_free(tmp); |
534 } | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
535 #endif /* DEBUG */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
536 |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1326
diff
changeset
|
537 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
|
538 g_message("error initialising input"); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
539 return; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
540 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
541 |
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
|
542 // 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
|
543 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
|
544 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
545 if (rtn == FALSE) { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
546 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
|
547 /* |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
548 * return; |
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
549 * 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
|
550 * 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
|
551 */ |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
552 } |
2390
bd9673d8b7d5
converted to new sound engine scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2344
diff
changeset
|
553 |
bd9673d8b7d5
converted to new sound engine scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2344
diff
changeset
|
554 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
|
555 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
|
556 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
|
557 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
|
558 AUDDBG("Replay Gain info:\n"); |
4ad6e7dfb389
imported 5298b10777b3 by Eugene Zagidullin.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2390
diff
changeset
|
559 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
|
560 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
|
561 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
|
562 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
|
563 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
|
564 |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
565 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
|
566 info.playback = playback; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
567 info.playback->playing = 1; |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
568 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
|
569 |
1342
ebded68de2dd
madplug: Update plugin for new threading model.
William Pitcock <nenolod@atheme-project.org>
parents:
1329
diff
changeset
|
570 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
|
571 playback->set_pb_ready(playback); |
1342
ebded68de2dd
madplug: Update plugin for new threading model.
William Pitcock <nenolod@atheme-project.org>
parents:
1329
diff
changeset
|
572 decode_loop(&info); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
573 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
574 |
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
|
575 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
|
576 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
|
577 { |
611 | 578 g_mutex_lock(pb_mutex); |
579 info.playback = playback; | |
580 g_mutex_unlock(pb_mutex); | |
581 playback->output->pause(paused); | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
582 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
583 |
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
|
584 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
|
585 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
|
586 { |
611 | 587 g_mutex_lock(pb_mutex); |
588 info.playback = playback; | |
807 | 589 info.seek = millisecond; |
611 | 590 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
|
591 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
592 |
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
|
593 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
|
594 audmad_seek(InputPlayback *playback, gint time) |
807 | 595 { |
596 audmad_mseek(playback, time * 1000); | |
597 } | |
598 | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
599 /** |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
600 * 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
|
601 * 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
|
602 */ |
611 | 603 static void |
604 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
|
605 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
606 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
|
607 #ifdef AUD_DEBUG |
799 | 608 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
|
609 AUDDBG("f: audmad_get_song_info: %s\n", tmp); |
799 | 610 g_free(tmp); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
611 #endif /* DEBUG */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
612 |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1326
diff
changeset
|
613 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
|
614 AUDDBG("error initialising input\n"); |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
615 return; |
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
616 } |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
617 |
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
|
618 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
|
619 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
|
620 *title = g_strdup(aud_tuple_get_string(myinfo.tuple, -1, "track-name")); |
611 | 621 else |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
622 *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
|
623 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
624 *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
|
625 if(*length == -1) |
738 | 626 *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
|
627 } |
611 | 628 else { |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
629 *title = g_strdup(url); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
630 *length = -1; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
631 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
632 input_term(&myinfo); |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
633 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
|
634 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
635 |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
636 static gboolean |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
637 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
|
638 { |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
639 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
|
640 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
|
641 |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
642 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
|
643 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
|
644 return FALSE; |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1326
diff
changeset
|
645 } |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
646 |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
647 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
|
648 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
|
649 } |
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1326
diff
changeset
|
650 |
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
|
651 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
|
652 audmad_about() |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
653 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
654 static GtkWidget *aboutbox; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
655 gchar *scratch; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
656 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
657 if (aboutbox != NULL) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
658 return; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
659 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
660 scratch = g_strdup_printf( |
1361
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
661 _("Audacious MPEG Audio Plugin\n" |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
662 "\n" |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
663 "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
|
664 "\n" |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
665 "Written by:\n" |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
666 " 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
|
667 " 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
|
668 "\n" |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
669 "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
|
670 " Sam Clegg\n" |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
671 "\n" |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
672 "ReplayGain support by:\n" |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
673 " Samuel Krempp"), |
f8b498451a84
- Fixed a bug that would crash Audacious when reloading plugins
mf0102 <0102@gmx.at>
parents:
1329
diff
changeset
|
674 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
|
675 MAD_VERSION_EXTRA); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
676 |
1677
f6f5603a0954
xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
677 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
|
678 scratch, |
1302
1d3b02d1842b
Guess... Yes, "i18n" stuff.
Stany HENRY <StrassBoy@gmail.com>
parents:
1277
diff
changeset
|
679 _("Ok"), FALSE, NULL, NULL); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
680 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
681 g_free(scratch); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
682 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
683 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
|
684 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
|
685 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
686 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
687 /** |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
688 * 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
|
689 * Taken from mpg123 plugin. |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
690 */ |
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
|
691 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
|
692 audmad_error(char *error, ...) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
693 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
694 #ifndef NOGUI |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
695 if (!error_dialog) { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
696 va_list args; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
697 char string[256]; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
698 va_start(args, error); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
699 vsnprintf(string, 256, error, args); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
700 va_end(args); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
701 GDK_THREADS_ENTER(); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
702 error_dialog = |
1677
f6f5603a0954
xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
703 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
|
704 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
|
705 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
|
706 &error_dialog); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
707 GDK_THREADS_LEAVE(); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
708 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
709 #endif /* !NOGUI */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
710 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
711 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
712 extern void audmad_configure(); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
713 |
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
|
714 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
|
715 __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
|
716 { |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
717 aud_tuple_associate_string(tuple, nfield, name, value); |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
718 g_free(value); |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
719 } |
611 | 720 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
721 // 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
|
722 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
|
723 __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
|
724 { |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
725 Tuple *tuple = NULL; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
726 gchar *string = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
727 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
728 struct id3_file *id3file = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
729 struct id3_tag *tag = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
730 |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
731 struct mad_info_t myinfo; |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
732 |
1329
4b07404814ca
- reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1328
diff
changeset
|
733 gboolean local_fd = FALSE; |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
734 int length; |
1329
4b07404814ca
- reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1328
diff
changeset
|
735 |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2207
diff
changeset
|
736 #ifdef AUD_DEBUG |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1995
diff
changeset
|
737 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
|
738 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
|
739 g_free(string); |
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
740 string = NULL; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
741 #endif |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
742 |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
743 /* isn't is obfuscated? --eugene */ |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
744 |
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
|
745 if(info.remote && mad_timer_count(info.duration, MAD_UNITS_SECONDS) <= 0){ |
1978 | 746 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
|
747 gchar *tmp = NULL; |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
748 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
|
749 |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2207
diff
changeset
|
750 #ifdef AUD_DEBUG |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1326
diff
changeset
|
751 if(info.playback) |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
752 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
|
753 #endif |
1978 | 754 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
|
755 if(tmp){ |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
756 gchar *scratch; |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
757 |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1995
diff
changeset
|
758 scratch = aud_str_to_utf8(tmp); |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
759 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
|
760 g_free(tmp); |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
761 g_free(scratch); |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
762 |
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
|
763 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
|
764 } |
1978 | 765 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
|
766 if(tmp){ |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
767 gchar *scratch; |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
768 |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1995
diff
changeset
|
769 scratch = aud_str_to_utf8(tmp); |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
770 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
|
771 g_free(tmp); |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
772 g_free(scratch); |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
773 |
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
|
774 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
|
775 } |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1326
diff
changeset
|
776 |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
777 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
|
778 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
|
779 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
780 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
|
781 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
|
782 return tuple; |
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
783 } |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
784 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
|
785 } /* info.remote */ |
611 | 786 |
1978 | 787 // 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
|
788 if(!fd) { |
1978 | 789 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
|
790 if(!fd) |
4b07404814ca
- reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1328
diff
changeset
|
791 return NULL; |
4b07404814ca
- reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1328
diff
changeset
|
792 local_fd = TRUE; |
4b07404814ca
- reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1328
diff
changeset
|
793 } |
4b07404814ca
- reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1328
diff
changeset
|
794 |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
795 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
|
796 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
|
797 if (local_fd) aud_vfs_fclose(fd); |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
798 return NULL; |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
799 } |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
800 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
801 tuple = aud_tuple_new(); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
802 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
|
803 |
1329
4b07404814ca
- reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1328
diff
changeset
|
804 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
|
805 |
773 | 806 if (id3file) { |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
807 |
773 | 808 tag = id3_file_tag(id3file); |
809 if (tag) { | |
1687
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
810 __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
|
811 __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
|
812 __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
|
813 |
773 | 814 // year |
815 string = NULL; | |
816 string = input_id3_get_string(tag, ID3_FRAME_YEAR); //TDRC | |
817 if (!string) | |
818 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
|
819 |
773 | 820 if (string) { |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
821 aud_tuple_associate_int(tuple, FIELD_YEAR, NULL, atoi(string)); |
773 | 822 g_free(string); |
823 string = NULL; | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
824 } |
2241
a5c96af75300
make use of aud_uri_to_display_*()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
825 |
a5c96af75300
make use of aud_uri_to_display_*()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
826 __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
|
827 __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
|
828 aud_tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, extname(filename)); |
773 | 829 |
611 | 830 // length |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
831 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
|
832 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, length); |
773 | 833 |
834 // track number | |
835 string = input_id3_get_string(tag, ID3_FRAME_TRACK); | |
836 if (string) { | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1738
diff
changeset
|
837 aud_tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atoi(string)); |
773 | 838 g_free(string); |
839 string = NULL; | |
840 } | |
841 // genre | |
1687
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
842 __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
|
843 __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
|
844 AUDDBG("genre = %s\n", aud_tuple_get_string(tuple, FIELD_GENRE, NULL)); |
611 | 845 } |
773 | 846 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
|
847 } // id3file |
773 | 848 else { // no id3tag |
2241
a5c96af75300
make use of aud_uri_to_display_*()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
849 __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
|
850 __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
|
851 aud_tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, extname(filename)); |
773 | 852 // length |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
853 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
|
854 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
|
855 } |
1329
4b07404814ca
- reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1328
diff
changeset
|
856 |
2207
0b67fb27db58
get benefit of FIELD_BITRATE
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2206
diff
changeset
|
857 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
|
858 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
|
859 |
2205
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
860 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
|
861 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
|
862 g_free(string); |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
863 |
2201
df520f828dcf
Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2153
diff
changeset
|
864 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
|
865 |
2faee266ea1e
madplug now provides more informative tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2203
diff
changeset
|
866 input_term(&myinfo); |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1400
diff
changeset
|
867 |
1329
4b07404814ca
- reduce the number of file open in loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1328
diff
changeset
|
868 if(local_fd) |
1978 | 869 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
|
870 |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2241
diff
changeset
|
871 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
|
872 return tuple; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
873 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
874 |
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
|
875 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
|
876 audmad_get_song_tuple(char *filename) |
1315
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
877 { |
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
878 return __audmad_get_song_tuple(filename, NULL); |
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
879 } |
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
880 |
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
|
881 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
|
882 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
|
883 { |
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
884 if (!audmad_is_our_fd(filename, fd)) |
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
885 return NULL; |
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
886 |
1978 | 887 aud_vfs_rewind(fd); |
1326
e991d29a9c9a
madplug: Fix ID3v1 tuple building.
William Pitcock <nenolod@atheme-project.org>
parents:
1324
diff
changeset
|
888 |
1315
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
889 return __audmad_get_song_tuple(filename, fd); |
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
890 } |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
891 |
2153
2f7eff0bc6eb
madplug: add .bmu to extensions whitelist (closes bugzilla #49)
William Pitcock <nenolod@atheme.org>
parents:
2124
diff
changeset
|
892 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
|
893 |
1065 | 894 InputPlugin mad_ip = { |
2393
6d47059bce36
removed 'experimental' from description.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2392
diff
changeset
|
895 .description = "MPEG Audio Plugin", |
1065 | 896 .init = audmad_init, |
897 .about = audmad_about, | |
898 .configure = audmad_configure, | |
899 .play_file = audmad_play_file, | |
900 .stop = audmad_stop, | |
901 .pause = audmad_pause, | |
902 .seek = audmad_seek, | |
903 .cleanup = audmad_cleanup, | |
904 .get_song_info = audmad_get_song_info, | |
905 .get_song_tuple = audmad_get_song_tuple, | |
906 .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
|
907 .vfs_extensions = fmts, |
1315
e3c991e485ed
madplug: Support probe for tuple instruction.
William Pitcock <nenolod@atheme-project.org>
parents:
1302
diff
changeset
|
908 .mseek = audmad_mseek, |
2201
df520f828dcf
Say goodbye to custom fileinfo dialog in madplug
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
2153
diff
changeset
|
909 .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
|
910 .update_song_tuple = audmad_update_song_tuple, |
1065 | 911 }; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
912 |
1065 | 913 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
|
914 |
1400
fe0a9cf95642
make use of SIMPLE_INPUT_PLUGIN() as an example.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1395
diff
changeset
|
915 SIMPLE_INPUT_PLUGIN(madplug, madplug_iplist); |
1065 | 916 |
917 InputPlugin *mad_plugin = &mad_ip; |