annotate src/madplug/decoder.c @ 2341:59addab003d7

- reworked replaygain to use individual pre-gain for the files with RG info and the rest. - default pre-gain have been changed to +6dB for with RG, +0dB for the rest. - new clipping prevention feature using track peak information has been implemented. - reworked preferences dialog. widgets have been categorized by function and all changes will take effect immediately. and also, cancel button can reverts all changes have been done in the current session. - some keys in preferences have been changed.
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Thu, 31 Jan 2008 15:22:15 +0900
parents 47d7a45b26a0
children f40f4ae3d5eb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
1 /*
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
2 * mad plugin for audacious
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
3 * Copyright (C) 2005-2007 William Pitcock, Yoshiki Yazawa
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
4 *
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
5 * Portions derived from xmms-mad:
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
6 * Copyright (C) 2001-2002 Sam Clegg - See COPYING
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
7 *
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
10 * the Free Software Foundation; under version 2 of the License.
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
11 *
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
15 * GNU General Public License for more details.
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
16 *
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
20 */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
21
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
22 /* #define AUD_DEBUG 1 */
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
23
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
24 #include <math.h>
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
25 #include <assert.h>
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
26 #include <pthread.h>
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
27 #include <signal.h>
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
28
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
29 #include <audacious/plugin.h>
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
30 #include <audacious/output.h>
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
31 #include <audacious/util.h>
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
32 #include <sys/time.h>
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
33 #include "plugin.h"
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
34 #include "input.h"
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 #define BUFFER_SIZE 16*1024
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
37 #define N_AVERAGE_FRAMES 10
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
38
924
f931c9d744a5 [svn] -adjust size of variable in dither code.
yaz
parents: 916
diff changeset
39 extern int triangular_dither_noise(int nbits);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
40
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
41 /**
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
42 * Scale PCM data
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 static inline signed int
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
45 scale(mad_fixed_t sample, struct mad_info_t *file_info)
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 gdouble scale = -1;
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
48 static int i = 0;
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
49
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
50 if (audmad_config->replaygain.enable) {
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
51 if (file_info->has_replaygain) {
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
52 // apply track gain if it is available and track mode is specified
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
53 if(file_info->replaygain_track_scale != -1) {
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
54 scale = file_info->replaygain_track_scale;
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
55 }
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
56 // apply album gain if available
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
57 if(!audmad_config->replaygain.track_mode &&
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
58 file_info->replaygain_album_scale != -1) {
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
59 scale = file_info->replaygain_album_scale;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
60 }
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
61
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
62 // apply preamp1
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
63 scale *= audmad_config->replaygain.preamp1_scale;
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
64
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
65 if (audmad_config->replaygain.anti_clip) {
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
66 if(i%100000 == 0)
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
67 AUDDBG("track_peak = %f\n", file_info->replaygain_track_peak);
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
68 if(scale * file_info->replaygain_track_peak >= 1.0)
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
69 scale = 1.0 / file_info->replaygain_track_peak;
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
70 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
71 }
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
72 else {
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
73 // apply preamp2 for files without RG info
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
74 scale = audmad_config->replaygain.preamp2_scale;
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
75 }
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
76 }
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
77 else {
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
78 scale = 1.0;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
79 }
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
80
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
81 // apply global gain
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
82 if (audmad_config->replaygain.preamp0_scale != 1)
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
83 scale = scale * audmad_config->replaygain.preamp0_scale;
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
84
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
85 if(i%100000 == 0) {
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
86 AUDDBG("scale = %f\n", scale);
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
87 }
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 /* hard-limit (clipping-prevention) */
2341
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
90 if (audmad_config->replaygain.hard_limit) {
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
91
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
92 if(i%100000 == 0) {
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
93 AUDDBG("hard_limit\n");
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
94 }
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
95
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
96 /* convert to double before computation, to avoid mad_fixed_t wrapping */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
97 double x = mad_f_todouble(sample) * scale;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
98 static const double k = 0.5; // -6dBFS
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
99 if (x > k) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
100 x = tanh((x - k) / (1 - k)) * (1 - k) + k;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
101 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
102 else if (x < -k) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
103 x = tanh((x + k) / (1 - k)) * (1 - k) - k;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
104 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
105 sample = x * (MAD_F_ONE);
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
106
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 if(i%100000 == 0) {
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
108 AUDDBG("x = %f sample = %d\n", x, sample);
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 }
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
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
111 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
112 else
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
113 sample *= scale;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
114
2341
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
115 i++;
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
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
117 int n_bits_to_loose = MAD_F_FRACBITS + 1 - 16;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
118
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
119 /* round */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
120 /* add half of the bits_to_loose range to round */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
121 sample += (1L << (n_bits_to_loose - 1));
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
122
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
123 #ifdef DEBUG_DITHER
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
124 mad_fixed_t no_dither = sample;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
125 #endif
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
126
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
127 /* dither one bit of actual output */
2341
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
128 if (audmad_config->dither) {
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
129 int dither = triangular_dither_noise(n_bits_to_loose + 1);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
130 sample += dither;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
131 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
132
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
133 /* clip */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
134 /* make sure we are between -1 and 1 */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
135 if (sample >= MAD_F_ONE) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
136 sample = MAD_F_ONE - 1;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
137 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
138 else if (sample < -MAD_F_ONE) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
139 sample = -MAD_F_ONE;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
140 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
141
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
142 /* quantize */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
143 /*
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
144 * Turn our mad_fixed_t into an integer.
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
145 * Shift all but 16-bits of the fractional part
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
146 * off the right hand side and shift an extra place
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
147 * to get the sign bit.
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
148 */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
149 sample >>= n_bits_to_loose;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
150 #ifdef DEBUG_DITHER
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
151 static int n_zeros = 0;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
152 no_dither >>= n_bits_to_loose;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
153 if (no_dither - sample == 0)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
154 n_zeros++;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
155 else {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
156 g_message("dither: %d %d", n_zeros, no_dither - sample);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
157 n_zeros = 0;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
158 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
159 #endif
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
160 return sample;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
161 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
162
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
163 void
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
164 write_output(struct mad_info_t *info, struct mad_pcm *pcm,
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
165 struct mad_header *header)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
166 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
167 unsigned int nsamples;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
168 mad_fixed_t const *left_ch, *right_ch;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
169 char *output;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
170 int olen = 0;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
171 int pos = 0;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
172
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
173 nsamples = pcm->length;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
174 left_ch = pcm->samples[0];
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
175 right_ch = pcm->samples[1];
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
176 olen = nsamples * MAD_NCHANNELS(header) * 2;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
177 output = (char *) g_malloc(olen * sizeof(char));
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
178
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
179 while (nsamples--) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
180 signed int sample;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
181 /* output sample(s) in 16-bit signed little-endian PCM */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
182 sample = scale(*left_ch++, info);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
183 output[pos++] = (sample >> 0) & 0xff;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
184 output[pos++] = (sample >> 8) & 0xff;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
185
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
186 if (MAD_NCHANNELS(header) == 2) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
187 sample = scale(*right_ch++, info);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
188 output[pos++] = (sample >> 0) & 0xff;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
189 output[pos++] = (sample >> 8) & 0xff;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
190 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
191 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
192 assert(pos == olen);
2287
2421c87fb855 Fix memory leak in mad plugin when changing songs and writing output. (Bugzilla #82)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2276
diff changeset
193 if (!info->playback->playing) {
2421c87fb855 Fix memory leak in mad plugin when changing songs and writing output. (Bugzilla #82)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2276
diff changeset
194 g_free(output);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
195 return;
2287
2421c87fb855 Fix memory leak in mad plugin when changing songs and writing output. (Bugzilla #82)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2276
diff changeset
196 }
1998
8f3188746b64 chase last changeset in aud
William Pitcock <nenolod@atheme.org>
parents: 1985
diff changeset
197 info->playback->pass_audio(info->playback,
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
198 FMT_S16_LE, MAD_NCHANNELS(header), olen, output, &(info->playback->playing));
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
199 g_free(output);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
200 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
201
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
202 /**
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
203 * Decode all headers in the file and fill in stats
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
204 * @return FALSE if scan failed.
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
205 */
2341
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
206 gboolean
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
207 scan_file(struct mad_info_t * info, gboolean fast)
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
208 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
209 struct mad_stream stream;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
210 struct mad_header header;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
211 int remainder = 0;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
212 int data_used = 0;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
213 int len = 0;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
214 int tagsize = 0;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
215 unsigned char buffer[BUFFER_SIZE];
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
216 struct mad_frame frame; /* to read xing data */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
217 gboolean has_xing = FALSE;
1162
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
218 guint bitrate_frames = 0;
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
219 double xing_bitrate = 0.0;
980
6ba4a4bfd127 [svn] - fix overflow when calculates bitrate with non-fast scan on a huge sized file.
yaz
parents: 959
diff changeset
220 double accum_bitrate = 0.0;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
221
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
222 mad_stream_init(&stream);
980
6ba4a4bfd127 [svn] - fix overflow when calculates bitrate with non-fast scan on a huge sized file.
yaz
parents: 959
diff changeset
223 mad_stream_options(&stream, 0); // check CRC
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
224 mad_header_init(&header);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
225 mad_frame_init(&frame);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
226 xing_init(&info->xing);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
227
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
228 info->bitrate = 0;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
229 info->pos = mad_timer_zero;
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
230 info->duration = mad_timer_zero; // should be cleared before loop, if we use it as break condition.
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
231
997
e46b98155d5d [svn] - fix a bug which counts number of frames twice in handling xing header.
yaz
parents: 980
diff changeset
232 if(info->fileinfo_request == TRUE) {
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1687
diff changeset
233 aud_tuple_associate_int(info->tuple, FIELD_LENGTH, NULL, -1);
997
e46b98155d5d [svn] - fix a bug which counts number of frames twice in handling xing header.
yaz
parents: 980
diff changeset
234 info->fileinfo_request = FALSE;
e46b98155d5d [svn] - fix a bug which counts number of frames twice in handling xing header.
yaz
parents: 980
diff changeset
235 }
e46b98155d5d [svn] - fix a bug which counts number of frames twice in handling xing header.
yaz
parents: 980
diff changeset
236
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
237 AUDDBG("f: scan_file\n");
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
238 AUDDBG("scan_file frames = %d\n", info->frames);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
239
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
240 while (1) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
241 remainder = stream.bufend - stream.next_frame;
789
354c69a939bc [svn] revising vfs_fread() check code.
yaz
parents: 788
diff changeset
242
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
243 /*
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
244 if (remainder >= BUFFER_SIZE)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
245 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
246 printf("oh dear.. remainder = %d\n", remainder);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
247 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
248 */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
249
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
250 memcpy(buffer, stream.this_frame, remainder);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
251 len = input_get_data(info, buffer + remainder,
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
252 BUFFER_SIZE - remainder);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
253
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
254 if (len <= 0) {
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
255 AUDDBG("scan_file: len <= 0 len = %d\n", len);
792
2b2313fc1ddc [svn] - I was noticed vfs_fread check still causes problem. disable for now.
yaz
parents: 789
diff changeset
256 break;
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
257 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
258
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
259 mad_stream_buffer(&stream, buffer, len + remainder);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
260
674
fadf4c18a1cf [svn] madplug bug fix:
yaz
parents: 673
diff changeset
261 while (!fast || (fast && info->frames < N_AVERAGE_FRAMES)) {
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
262 if (mad_header_decode(&header, &stream) == -1) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
263 if (stream.error == MAD_ERROR_BUFLEN) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
264 break;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
265 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
266 if (!MAD_RECOVERABLE(stream.error)) {
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
267 AUDDBG("(fatal) error decoding header %d: %s\n",
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
268 info->frames, mad_stream_errorstr(&stream));
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
269 AUDDBG("remainder = %d\n", remainder);
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
270 AUDDBG("len = %d\n", len);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
271 break;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
272 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
273 if (stream.error == MAD_ERROR_LOSTSYNC) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
274 /* ignore LOSTSYNC due to ID3 tags */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
275 tagsize = id3_tag_query(stream.this_frame,
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
276 stream.bufend -
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
277 stream.this_frame);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
278 if (tagsize > 0) {
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
279 AUDDBG("skipping id3_tag: %d\n", tagsize);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
280 mad_stream_skip(&stream, tagsize);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
281 continue;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
282 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
283 }
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
284
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
285 AUDDBG("(recovered) error decoding header %d: %s\n",
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
286 info->frames, mad_stream_errorstr(&stream));
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
287 AUDDBG("remainder = %d\n", remainder);
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
288 AUDDBG("len = %d\n", len);
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
289
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
290 continue;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
291 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
292 info->frames++;
674
fadf4c18a1cf [svn] madplug bug fix:
yaz
parents: 673
diff changeset
293
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
294 #ifdef DEBUG_INTENSIVELY
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
295 AUDDBG("header bitrate = %ld\n", header.bitrate);
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
296 AUDDBG("duration = %ul\n",
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
297 mad_timer_count(header.duration,
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
298 MAD_UNITS_MILLISECONDS));
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
299 AUDDBG("size = %d\n", stream.next_frame - stream.this_frame);
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
300 #endif
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1687
diff changeset
301 if(aud_tuple_get_int(info->tuple, FIELD_LENGTH, NULL) == -1)
738
6ea974a229a8 [svn] - add read/write support for TLEN frame.
yaz
parents: 676
diff changeset
302 mad_timer_add(&info->duration, header.duration);
6ea974a229a8 [svn] - add read/write support for TLEN frame.
yaz
parents: 676
diff changeset
303 else {
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1687
diff changeset
304 gint length = aud_tuple_get_int(info->tuple, FIELD_LENGTH, NULL);
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1344
diff changeset
305
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1344
diff changeset
306 info->duration.seconds = length / 1000;
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1344
diff changeset
307 info->duration.fraction = length % 1000;
738
6ea974a229a8 [svn] - add read/write support for TLEN frame.
yaz
parents: 676
diff changeset
308 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
309 data_used += stream.next_frame - stream.this_frame;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
310 if (info->frames == 1) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
311 /* most of these *should* remain constant */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
312 info->bitrate = header.bitrate;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
313 info->freq = header.samplerate;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
314 info->channels = MAD_NCHANNELS(&header);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
315 info->mpeg_layer = header.layer;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
316 info->mode = header.mode;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
317
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
318 if (audmad_config->use_xing) {
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
319 frame.header = header;
674
fadf4c18a1cf [svn] madplug bug fix:
yaz
parents: 673
diff changeset
320 if (mad_frame_decode(&frame, &stream) == -1) {
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
321 AUDDBG("xing frame decode failed\n");
674
fadf4c18a1cf [svn] madplug bug fix:
yaz
parents: 673
diff changeset
322 goto no_xing;
fadf4c18a1cf [svn] madplug bug fix:
yaz
parents: 673
diff changeset
323 }
980
6ba4a4bfd127 [svn] - fix overflow when calculates bitrate with non-fast scan on a huge sized file.
yaz
parents: 959
diff changeset
324 if (xing_parse(&info->xing, stream.anc_ptr, stream.anc_bitlen) == 0) {
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
325 AUDDBG("xing header found\n");
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
326 has_xing = TRUE;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
327 info->vbr = TRUE; /* otherwise xing header would have been 'Info' */
1162
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
328
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
329 AUDDBG("xing: bytes = %ld frames = %ld\n", info->xing.bytes, info->xing.frames);
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
330
1162
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
331 /* we have enough info to calculate bitrate and duration */
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
332 if(info->xing.bytes && info->xing.frames) {
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
333 xing_bitrate = 8 * (double)info->xing.bytes * 38 / (double)info->xing.frames; //38fps in MPEG1.
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
334 #ifdef AUD_DEBUG
1162
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
335 {
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
336 gint tmp = (gint)(info->xing.bytes * 8 / xing_bitrate);
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
337 AUDDBG("xing: bitrate = %4.1f kbps\n", xing_bitrate / 1000);
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
338 AUDDBG("xing: duration = %d:%02d\n", tmp / 60, tmp % 60);
1162
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
339 }
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
340 #endif
738
6ea974a229a8 [svn] - add read/write support for TLEN frame.
yaz
parents: 676
diff changeset
341 }
959
b2fbf53360cf [svn] bug fix for #897
yaz
parents: 925
diff changeset
342 continue;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
343 }
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
344 #ifdef AUD_DEBUG
980
6ba4a4bfd127 [svn] - fix overflow when calculates bitrate with non-fast scan on a huge sized file.
yaz
parents: 959
diff changeset
345 else {
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
346 AUDDBG("no usable xing header\n");
980
6ba4a4bfd127 [svn] - fix overflow when calculates bitrate with non-fast scan on a huge sized file.
yaz
parents: 959
diff changeset
347 continue;
6ba4a4bfd127 [svn] - fix overflow when calculates bitrate with non-fast scan on a huge sized file.
yaz
parents: 959
diff changeset
348 }
6ba4a4bfd127 [svn] - fix overflow when calculates bitrate with non-fast scan on a huge sized file.
yaz
parents: 959
diff changeset
349 #endif
6ba4a4bfd127 [svn] - fix overflow when calculates bitrate with non-fast scan on a huge sized file.
yaz
parents: 959
diff changeset
350 } /* xing */
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
351
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
352 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
353 else {
980
6ba4a4bfd127 [svn] - fix overflow when calculates bitrate with non-fast scan on a huge sized file.
yaz
parents: 959
diff changeset
354 /* perhaps we have a VBR file */
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
355 if (info->bitrate != header.bitrate)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
356 info->vbr = TRUE;
673
8ed0af226d0e [svn] - calculate vbr bitrate properly.
yaz
parents: 627
diff changeset
357 if (info->vbr) {
980
6ba4a4bfd127 [svn] - fix overflow when calculates bitrate with non-fast scan on a huge sized file.
yaz
parents: 959
diff changeset
358 accum_bitrate += (double)header.bitrate;
673
8ed0af226d0e [svn] - calculate vbr bitrate properly.
yaz
parents: 627
diff changeset
359 bitrate_frames++;
8ed0af226d0e [svn] - calculate vbr bitrate properly.
yaz
parents: 627
diff changeset
360 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
361 /* check for changin layer/samplerate/channels */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
362 if (info->mpeg_layer != header.layer)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
363 g_warning("layer varies!!");
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
364 if (info->freq != header.samplerate)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
365 g_warning("samplerate varies!!");
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
366 if (info->channels != MAD_NCHANNELS(&header))
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
367 g_warning("number of channels varies!!");
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
368 }
674
fadf4c18a1cf [svn] madplug bug fix:
yaz
parents: 673
diff changeset
369 no_xing:
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
370 if (fast && info->frames >= N_AVERAGE_FRAMES) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
371 float frame_size = ((double) data_used) / N_AVERAGE_FRAMES;
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
372
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
373 AUDDBG("bitrate = %ld samplerate = %d\n", header.bitrate, header.samplerate);
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
374 AUDDBG("data_used = %d info->frames = %d info->size = %d tagsize = %d frame_size = %lf\n",
980
6ba4a4bfd127 [svn] - fix overflow when calculates bitrate with non-fast scan on a huge sized file.
yaz
parents: 959
diff changeset
375 data_used, info->frames, info->size, tagsize, frame_size);
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
376
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
377 if(info->size != 0)
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
378 info->frames = (info->size - tagsize) / frame_size;
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
379
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
380 AUDDBG("info->frames = %d\n", info->frames);
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
381
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1687
diff changeset
382 if(aud_tuple_get_int(info->tuple, FIELD_LENGTH, NULL) == -1) {
1162
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
383 if(xing_bitrate > 0.0) {
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
384 /* calc duration with xing info */
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
385 double tmp = 8 * (double)info->xing.bytes * 1000 / xing_bitrate;
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
386 info->duration.seconds = (guint)(tmp / 1000);
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
387 info->duration.fraction = (guint)(tmp - info->duration.seconds * 1000);
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
388 }
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
389 else {
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
390 info->duration.seconds /= N_AVERAGE_FRAMES;
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
391 info->duration.fraction /= N_AVERAGE_FRAMES;
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
392 mad_timer_multiply(&info->duration, info->frames);
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
393 }
738
6ea974a229a8 [svn] - add read/write support for TLEN frame.
yaz
parents: 676
diff changeset
394 }
6ea974a229a8 [svn] - add read/write support for TLEN frame.
yaz
parents: 676
diff changeset
395 else {
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1687
diff changeset
396 gint length = aud_tuple_get_int(info->tuple, FIELD_LENGTH, NULL);
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1344
diff changeset
397
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1344
diff changeset
398 info->duration.seconds = length / 1000;
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1344
diff changeset
399 info->duration.fraction = length % 1000;
738
6ea974a229a8 [svn] - add read/write support for TLEN frame.
yaz
parents: 676
diff changeset
400 }
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
401 #ifdef AUD_DEBUG
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
402 AUDDBG("using fast playtime calculation\n");
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
403 AUDDBG("data used = %d [tagsize=%d framesize=%f]\n",
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
404 data_used, tagsize, frame_size);
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
405 AUDDBG("frames = %d, frequency = %d, channels = %d\n",
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
406 info->frames, info->freq, info->channels);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
407 long millis = mad_timer_count(info->duration,
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
408 MAD_UNITS_MILLISECONDS);
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
409 AUDDBG("duration = %ld:%02ld\n", millis / 1000 / 60, (millis / 1000) % 60);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
410 #endif /* DEBUG */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
411 break;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
412 }
980
6ba4a4bfd127 [svn] - fix overflow when calculates bitrate with non-fast scan on a huge sized file.
yaz
parents: 959
diff changeset
413 } /* while */
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
414 if (stream.error != MAD_ERROR_BUFLEN)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
415 break;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
416 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
417
997
e46b98155d5d [svn] - fix a bug which counts number of frames twice in handling xing header.
yaz
parents: 980
diff changeset
418 if (info->xing.frames)
e46b98155d5d [svn] - fix a bug which counts number of frames twice in handling xing header.
yaz
parents: 980
diff changeset
419 info->frames = info->xing.frames;
e46b98155d5d [svn] - fix a bug which counts number of frames twice in handling xing header.
yaz
parents: 980
diff changeset
420
980
6ba4a4bfd127 [svn] - fix overflow when calculates bitrate with non-fast scan on a huge sized file.
yaz
parents: 959
diff changeset
421 if (info->vbr && xing_bitrate != 0) {
1162
29519d604e8c [svn] - revise bitrate calculation with xing header. if number of bytes and number of frames are available in xing header, fast play time calculation yields almost appropriate duration upon a vbr file.
yaz
parents: 997
diff changeset
422 info->bitrate = (guint)xing_bitrate;
980
6ba4a4bfd127 [svn] - fix overflow when calculates bitrate with non-fast scan on a huge sized file.
yaz
parents: 959
diff changeset
423 }
6ba4a4bfd127 [svn] - fix overflow when calculates bitrate with non-fast scan on a huge sized file.
yaz
parents: 959
diff changeset
424 else if (info->vbr && xing_bitrate == 0 && bitrate_frames != 0) {
6ba4a4bfd127 [svn] - fix overflow when calculates bitrate with non-fast scan on a huge sized file.
yaz
parents: 959
diff changeset
425 info->bitrate = accum_bitrate / bitrate_frames;
959
b2fbf53360cf [svn] bug fix for #897
yaz
parents: 925
diff changeset
426 }
2340
47d7a45b26a0 fixed ${bitrate} in title string
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2287
diff changeset
427
47d7a45b26a0 fixed ${bitrate} in title string
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2287
diff changeset
428 aud_tuple_associate_int(info->tuple, FIELD_BITRATE, NULL, info->bitrate / 1000);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
429
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
430 mad_frame_finish(&frame);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
431 mad_header_finish(&header);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
432 mad_stream_finish(&stream);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
433 xing_finish(&info->xing);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
434
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
435 AUDDBG("scan_file: info->frames = %d\n", info->frames);
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
436 AUDDBG("e: scan_file\n");
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
437
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
438 return (info->frames != 0 || info->remote == TRUE);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
439 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
440
980
6ba4a4bfd127 [svn] - fix overflow when calculates bitrate with non-fast scan on a huge sized file.
yaz
parents: 959
diff changeset
441 /* sanity check for audio open parameters */
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
442 static gboolean
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
443 check_audio_param(struct mad_info_t *info)
896
f0846bdd9de6 [svn] - small cleanups.
yaz
parents: 807
diff changeset
444 {
f0846bdd9de6 [svn] - small cleanups.
yaz
parents: 807
diff changeset
445 if(info->fmt < FMT_U8 || info->fmt > FMT_S16_NE)
f0846bdd9de6 [svn] - small cleanups.
yaz
parents: 807
diff changeset
446 return FALSE;
f0846bdd9de6 [svn] - small cleanups.
yaz
parents: 807
diff changeset
447 if(info->freq < 0) // not sure about maximum frequency. --yaz
f0846bdd9de6 [svn] - small cleanups.
yaz
parents: 807
diff changeset
448 return FALSE;
f0846bdd9de6 [svn] - small cleanups.
yaz
parents: 807
diff changeset
449 if(info->channels < 1 || info->channels > 2)
f0846bdd9de6 [svn] - small cleanups.
yaz
parents: 807
diff changeset
450 return FALSE;
f0846bdd9de6 [svn] - small cleanups.
yaz
parents: 807
diff changeset
451
f0846bdd9de6 [svn] - small cleanups.
yaz
parents: 807
diff changeset
452 return TRUE;
f0846bdd9de6 [svn] - small cleanups.
yaz
parents: 807
diff changeset
453 }
f0846bdd9de6 [svn] - small cleanups.
yaz
parents: 807
diff changeset
454
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
455 gpointer
59addab003d7 - reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2340
diff changeset
456 decode_loop(gpointer arg)
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
457 {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
458 unsigned char buffer[BUFFER_SIZE];
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
459 int len;
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
460 gboolean seek_skip = FALSE;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
461 int remainder = 0;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
462 gint tlen;
673
8ed0af226d0e [svn] - calculate vbr bitrate properly.
yaz
parents: 627
diff changeset
463 unsigned int iteration = 0;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
464
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
465 /* mad structs */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
466 struct mad_stream stream;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
467 struct mad_frame frame;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
468 struct mad_synth synth;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
469
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
470 /* track info is passed in as thread argument */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
471 struct mad_info_t *info = (struct mad_info_t *) arg;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
472
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
473 AUDDBG("f: decode\n");
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
474
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
475 /* init mad stuff */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
476 mad_frame_init(&frame);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
477 mad_stream_init(&stream);
925
3673bbab7372 [svn] - make madplug ignore crc error. closes #884.
yaz
parents: 924
diff changeset
478 mad_stream_options(&stream, MAD_OPTION_IGNORECRC);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
479 mad_synth_init(&synth);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
480
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
481 if(!info->playback){
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
482 AUDDBG("decode: playback == NULL\n");
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
483 return NULL;
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
484 }
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
485
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
486 AUDDBG("decode: fmt = %d freq = %d channels = %d\n", info->fmt, info->freq, info->channels);
896
f0846bdd9de6 [svn] - small cleanups.
yaz
parents: 807
diff changeset
487
f0846bdd9de6 [svn] - small cleanups.
yaz
parents: 807
diff changeset
488 if(check_audio_param(info) == FALSE)
793
98cdc39031f9 [svn] - add sanity check for open audio parameters.
yaz
parents: 792
diff changeset
489 return NULL;
896
f0846bdd9de6 [svn] - small cleanups.
yaz
parents: 807
diff changeset
490
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
491 if (!info->playback->output->open_audio(info->fmt, info->freq, info->channels)) {
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
492 g_mutex_lock(pb_mutex);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
493 info->playback->error = TRUE;
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
494 info->playback->eof = 1;
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
495 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
496 g_message("failed to open audio output: %s",
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
497 info->playback->output->description);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
498 return NULL;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
499 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
500
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
501 /* set mainwin title */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
502 if (info->title)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
503 g_free(info->title);
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
504 info->title = aud_tuple_formatter_make_title_string(info->tuple, audmad_config->title_override == 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
505 audmad_config->id3_format : aud_get_gentitle_format());
1428
4993976d7ed0 madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents: 1344
diff changeset
506
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
507 tlen = (gint) mad_timer_count(info->duration, MAD_UNITS_MILLISECONDS),
1985
a260bd1beef0 use set_params() in madplug
William Pitcock <nenolod@atheme.org>
parents: 1978
diff changeset
508 info->playback->set_params(info->playback, info->title,
778
209b08a3eff6 [svn] - hide seek bar for unseekable (info->size = 0) stream.
yaz
parents: 773
diff changeset
509 (tlen == 0 || info->size <= 0) ? -1 : tlen,
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
510 info->bitrate, info->freq, info->channels);
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
511
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
512 AUDDBG("decode: tlen = %d\n", tlen);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
513
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
514 /* main loop */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
515 do {
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
516 if (!info->playback->playing) {
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
517 AUDDBG("decode: stop signaled\n");
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
518 break;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
519 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
520 if (seek_skip)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
521 remainder = 0;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
522 else {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
523 remainder = stream.bufend - stream.next_frame;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
524 memcpy(buffer, stream.this_frame, remainder);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
525 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
526 len = input_get_data(info, buffer + remainder,
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
527 BUFFER_SIZE - remainder);
773
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
528
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
529 input_process_remote_metadata(info);
22c82f3c0411 [svn] - reduce connection latency to http stream.
yaz
parents: 768
diff changeset
530
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
531 if (len <= 0) {
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
532 AUDDBG("finished decoding\n");
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
533 break;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
534 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
535 len += remainder;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
536 if (len < MAD_BUFFER_GUARD) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
537 int i;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
538 for (i = len; i < MAD_BUFFER_GUARD; i++)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
539 buffer[i] = 0;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
540 len = MAD_BUFFER_GUARD;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
541 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
542
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
543 mad_stream_buffer(&stream, buffer, len);
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 (seek_skip) {
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
546
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
547 AUDDBG("skipping: %d\n", seek_skip);
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
548
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
549 int skip = 2;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
550 do {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
551 if (mad_frame_decode(&frame, &stream) == 0) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
552 mad_timer_add(&info->pos, frame.header.duration);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
553 if (--skip == 0)
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
554 mad_synth_frame(&synth, &frame);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
555 }
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
556 else if (!MAD_RECOVERABLE(stream.error)) {
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
557 g_mutex_lock(pb_mutex);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
558 info->playback->error = TRUE;
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
559 info->playback->eof = 1;
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
560 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
561 break;
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
562 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
563 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
564 while (skip);
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
565 seek_skip = FALSE;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
566 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
567
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
568 while (info->playback->playing) {
778
209b08a3eff6 [svn] - hide seek bar for unseekable (info->size = 0) stream.
yaz
parents: 773
diff changeset
569 if (info->seek != -1 && info->size > 0) {
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
570
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
571 AUDDBG("seeking: %ld\n", info->seek);
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
572
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
573 int new_position;
807
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 794
diff changeset
574 gulong milliseconds =
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 794
diff changeset
575 mad_timer_count(info->duration, MAD_UNITS_MILLISECONDS);
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 794
diff changeset
576 if (info->seek >= milliseconds)
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 794
diff changeset
577 info->seek = milliseconds;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
578
807
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 794
diff changeset
579 mad_timer_set(&info->pos, 0, info->seek, 1000); // in millisecond
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
580 new_position =
807
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 794
diff changeset
581 ((double) info->seek / (double) milliseconds) * info->size;
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
582
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
583 if(new_position < 0)
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
584 new_position = 0;
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
585
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
586 AUDDBG("seeking to: %d bytes\n", new_position);
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
587
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
588 if (aud_vfs_fseek(info->infile, new_position, SEEK_SET) == -1)
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
589 audmad_error("failed to seek to: %d", new_position);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
590 mad_frame_mute(&frame);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
591 mad_synth_mute(&synth);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
592 stream.error = MAD_ERROR_BUFLEN;
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
593 info->playback->output->flush(mad_timer_count(info->pos, MAD_UNITS_MILLISECONDS));
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
594 stream.sync = 0;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
595 info->seek = -1;
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
596 seek_skip = TRUE;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
597 break;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
598 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
599
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
600 if (mad_header_decode(&frame.header, &stream) == -1) {
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
601 if (!MAD_RECOVERABLE(stream.error)) {
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
602 break;
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
603 }
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
604 if (stream.error == MAD_ERROR_LOSTSYNC) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
605 /* ignore LOSTSYNC due to ID3 tags */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
606 int tagsize = id3_tag_query(stream.this_frame,
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
607 stream.bufend -
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
608 stream.this_frame);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
609 if (tagsize > 0) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
610 mad_stream_skip(&stream, tagsize);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
611 continue;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
612 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
613 }
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
614
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
615 AUDDBG("(recovered) error decoding header %d: %s\n",
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
616 info->current_frame,
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
617 mad_stream_errorstr(&stream));
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
618
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
619 continue;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
620 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
621
673
8ed0af226d0e [svn] - calculate vbr bitrate properly.
yaz
parents: 627
diff changeset
622 info->bitrate = frame.header.bitrate;
8ed0af226d0e [svn] - calculate vbr bitrate properly.
yaz
parents: 627
diff changeset
623
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
624 if (!audmad_config->show_avg_vbr_bitrate && info->vbr && (iteration % 40 == 0)) {
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
625
784
5ddfe9eac8ee [svn] - fix read_replaygain(). necessary fseek was missing in reuse fd code. closes #843.
yaz
parents: 783
diff changeset
626 #ifdef DEBUG_INTENSIVELY
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
627 AUDDBG("decode vbr tlen = %d\n", tlen);
784
5ddfe9eac8ee [svn] - fix read_replaygain(). necessary fseek was missing in reuse fd code. closes #843.
yaz
parents: 783
diff changeset
628 #endif
1985
a260bd1beef0 use set_params() in madplug
William Pitcock <nenolod@atheme.org>
parents: 1978
diff changeset
629 info->playback->set_params(info->playback, info->title,
778
209b08a3eff6 [svn] - hide seek bar for unseekable (info->size = 0) stream.
yaz
parents: 773
diff changeset
630 (tlen == 0 || info->size <= 0) ? -1 : tlen,
673
8ed0af226d0e [svn] - calculate vbr bitrate properly.
yaz
parents: 627
diff changeset
631 info->bitrate, info->freq, info->channels);
8ed0af226d0e [svn] - calculate vbr bitrate properly.
yaz
parents: 627
diff changeset
632 }
8ed0af226d0e [svn] - calculate vbr bitrate properly.
yaz
parents: 627
diff changeset
633 iteration++;
8ed0af226d0e [svn] - calculate vbr bitrate properly.
yaz
parents: 627
diff changeset
634
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
635 if (mad_frame_decode(&frame, &stream) == -1) {
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
636 if (!MAD_RECOVERABLE(stream.error))
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
637 break;
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
638
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
639 AUDDBG("(recovered) error decoding frame %d: %s\n",
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
640 info->current_frame,
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
641 mad_stream_errorstr(&stream));
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
642
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
643 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
644
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
645 info->current_frame++;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
646
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
647 if (info->freq != frame.header.samplerate
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
648 || info->channels !=
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
649 (guint) MAD_NCHANNELS(&frame.header)) {
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
650
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
651 AUDDBG("change in audio type detected\n");
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
652 AUDDBG("old: frequency = %d, channels = %d\n", info->freq,
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
653 info->channels);
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
654 AUDDBG("new: frequency = %d, channels = %d\n",
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
655 frame.header.samplerate,
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
656 (guint) MAD_NCHANNELS(&frame.header));
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
657
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
658 info->freq = frame.header.samplerate;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
659 info->channels = MAD_NCHANNELS(&frame.header);
794
93dbfe1f0cd0 [svn] - same sanity check on rarely executed part.
yaz
parents: 793
diff changeset
660
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
661 if(audmad_config->force_reopen_audio && check_audio_param(info)) {
916
a8494c2a87eb [svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
yaz
parents: 896
diff changeset
662 gint current_time = info->playback->output->output_time();
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
663
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
664 AUDDBG("re-opening audio due to change in audio type\n");
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
665
916
a8494c2a87eb [svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
yaz
parents: 896
diff changeset
666 info->playback->output->close_audio();
a8494c2a87eb [svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
yaz
parents: 896
diff changeset
667 if (!info->playback->output->open_audio(info->fmt, info->freq,
a8494c2a87eb [svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
yaz
parents: 896
diff changeset
668 info->channels)) {
a8494c2a87eb [svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
yaz
parents: 896
diff changeset
669 g_mutex_lock(pb_mutex);
a8494c2a87eb [svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
yaz
parents: 896
diff changeset
670 info->playback->error = TRUE;
a8494c2a87eb [svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
yaz
parents: 896
diff changeset
671 info->playback->eof = 1;
a8494c2a87eb [svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
yaz
parents: 896
diff changeset
672 g_mutex_unlock(pb_mutex);
a8494c2a87eb [svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
yaz
parents: 896
diff changeset
673 g_message("failed to re-open audio output: %s",
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
674 info->playback->output->description);
916
a8494c2a87eb [svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
yaz
parents: 896
diff changeset
675 return NULL;
a8494c2a87eb [svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
yaz
parents: 896
diff changeset
676 }
a8494c2a87eb [svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
yaz
parents: 896
diff changeset
677 // restore time and advance 0.5sec
a8494c2a87eb [svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
yaz
parents: 896
diff changeset
678 info->seek = current_time + 500;
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
679 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
680 }
916
a8494c2a87eb [svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
yaz
parents: 896
diff changeset
681
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
682 if (!info->playback->playing)
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
683 break;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
684 mad_synth_frame(&synth, &frame);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
685 mad_stream_sync(&stream);
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
686
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
687 write_output(info, &synth.pcm, &frame.header);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
688 mad_timer_add(&info->pos, frame.header.duration);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
689 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
690 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
691 while (stream.error == MAD_ERROR_BUFLEN);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
692
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
693 /* free mad stuff */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
694 mad_frame_finish(&frame);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
695 mad_stream_finish(&stream);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
696 mad_synth_finish(&synth);
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
697
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
698 if (info->playback->playing) {
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
699 GTimeVal sleeptime;
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
700
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
701 info->playback->output->buffer_free();
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
702 info->playback->output->buffer_free();
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
703 while (info->playback->output->buffer_playing()) {
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
704
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
705 AUDDBG("f: buffer_playing=%d\n", info->playback->output->buffer_playing());
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
706
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
707 g_get_current_time(&sleeptime);
807
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 794
diff changeset
708 g_time_val_add(&sleeptime, 500000);
0f9c8d4d3ac4 [svn] - make use of new millisecond seek API.
yaz
parents: 794
diff changeset
709
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
710 g_mutex_lock(mad_mutex);
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
711 g_cond_timed_wait(mad_cond, mad_mutex, &sleeptime);
896
f0846bdd9de6 [svn] - small cleanups.
yaz
parents: 807
diff changeset
712 g_mutex_unlock(mad_mutex);
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
713 if (!info->playback->playing) {
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
714 break;
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
715 }
896
f0846bdd9de6 [svn] - small cleanups.
yaz
parents: 807
diff changeset
716
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
717 }
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
718 }
2214
9a869d4bb0d3 make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2055
diff changeset
719
2276
d25cd7e7eddb append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2214
diff changeset
720 AUDDBG("e: decode\n");
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
721
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1687
diff changeset
722 aud_tuple_free(info->tuple);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
723 info->tuple = NULL;
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
724
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
725 info->playback->output->close_audio();
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
726 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
727 info->playback->playing = 0;
611
3f7a52adfe0e [svn] merge recent changes from yaz's branch.
yaz
parents: 610
diff changeset
728 g_mutex_unlock(mad_mutex);
610
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
729 return NULL; /* dummy */
862190d39e00 [svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff changeset
730 }