annotate Plugins/Input/mpg123/mpg123.c @ 1105:4be4d74db123 trunk

[svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
author yaz
date Sat, 27 May 2006 11:02:08 -0700
parents b5ae09a6c2f1
children c4063c84b797
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
1 #include "mpg123.h"
354
e2775c9b8b13 [svn] very rudementary http stream detection support for mpg123-clone.
nenolod
parents: 353
diff changeset
2 #include "common.h"
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
3
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
4 #include <glib.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
5 #include <glib/gi18n.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
6 #include <gtk/gtk.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
7 #include <stdlib.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
8 #include <string.h>
354
e2775c9b8b13 [svn] very rudementary http stream detection support for mpg123-clone.
nenolod
parents: 353
diff changeset
9 #include <unistd.h>
e2775c9b8b13 [svn] very rudementary http stream detection support for mpg123-clone.
nenolod
parents: 353
diff changeset
10
e2775c9b8b13 [svn] very rudementary http stream detection support for mpg123-clone.
nenolod
parents: 353
diff changeset
11 #include <fcntl.h>
e2775c9b8b13 [svn] very rudementary http stream detection support for mpg123-clone.
nenolod
parents: 353
diff changeset
12 #include <unistd.h>
e2775c9b8b13 [svn] very rudementary http stream detection support for mpg123-clone.
nenolod
parents: 353
diff changeset
13 #include <errno.h>
e2775c9b8b13 [svn] very rudementary http stream detection support for mpg123-clone.
nenolod
parents: 353
diff changeset
14 #include <sys/types.h>
e2775c9b8b13 [svn] very rudementary http stream detection support for mpg123-clone.
nenolod
parents: 353
diff changeset
15 #include <sys/socket.h>
e2775c9b8b13 [svn] very rudementary http stream detection support for mpg123-clone.
nenolod
parents: 353
diff changeset
16 #include <sys/time.h>
e2775c9b8b13 [svn] very rudementary http stream detection support for mpg123-clone.
nenolod
parents: 353
diff changeset
17 #include <netinet/in.h>
e2775c9b8b13 [svn] very rudementary http stream detection support for mpg123-clone.
nenolod
parents: 353
diff changeset
18 #include <arpa/inet.h>
e2775c9b8b13 [svn] very rudementary http stream detection support for mpg123-clone.
nenolod
parents: 353
diff changeset
19 #include <netdb.h>
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
20
957
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
21 #include "libaudacious/util.h"
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
22 #include "libaudacious/configdb.h"
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
23 #include "libaudacious/vfs.h"
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
24 #include "libaudacious/titlestring.h"
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
25 #include "audacious/util.h"
957
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
26 #include <tag_c.h>
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
27
354
e2775c9b8b13 [svn] very rudementary http stream detection support for mpg123-clone.
nenolod
parents: 353
diff changeset
28 #define BUFSIZE_X 2048
e2775c9b8b13 [svn] very rudementary http stream detection support for mpg123-clone.
nenolod
parents: 353
diff changeset
29
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
30 static struct frame fr, temp_fr;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
31
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
32 PlayerInfo *mpgdec_info = NULL;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
33 static GThread *decode_thread;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
34
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
35 static gboolean audio_error = FALSE, output_opened = FALSE, dopause = FALSE;
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
36 gint mpgdec_bitrate, mpgdec_frequency, mpgdec_length, mpgdec_layer,
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
37 mpgdec_lsf;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
38 gchar *mpgdec_title = NULL, *mpgdec_filename = NULL;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
39 static int disp_bitrate, skip_frames = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
40 static int cpu_fflags, cpu_efflags;
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
41 gboolean mpgdec_stereo, mpgdec_mpeg25;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
42 int mpgdec_mode;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
43
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
44 mpgdec_t *ins;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
45
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
46 gchar **mpgdec_id3_encoding_list = NULL;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
47
957
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
48 static TagLib_File *taglib_file;
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
49 static TagLib_Tag *taglib_tag;
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
50 static const TagLib_AudioProperties *taglib_ap;
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
51
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
52 const char *mpgdec_id3_genres[GENRE_MAX] = {
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
53 N_("Blues"), N_("Classic Rock"), N_("Country"), N_("Dance"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
54 N_("Disco"), N_("Funk"), N_("Grunge"), N_("Hip-Hop"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
55 N_("Jazz"), N_("Metal"), N_("New Age"), N_("Oldies"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
56 N_("Other"), N_("Pop"), N_("R&B"), N_("Rap"), N_("Reggae"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
57 N_("Rock"), N_("Techno"), N_("Industrial"), N_("Alternative"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
58 N_("Ska"), N_("Death Metal"), N_("Pranks"), N_("Soundtrack"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
59 N_("Euro-Techno"), N_("Ambient"), N_("Trip-Hop"), N_("Vocal"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
60 N_("Jazz+Funk"), N_("Fusion"), N_("Trance"), N_("Classical"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
61 N_("Instrumental"), N_("Acid"), N_("House"), N_("Game"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
62 N_("Sound Clip"), N_("Gospel"), N_("Noise"), N_("AlternRock"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
63 N_("Bass"), N_("Soul"), N_("Punk"), N_("Space"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
64 N_("Meditative"), N_("Instrumental Pop"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
65 N_("Instrumental Rock"), N_("Ethnic"), N_("Gothic"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
66 N_("Darkwave"), N_("Techno-Industrial"), N_("Electronic"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
67 N_("Pop-Folk"), N_("Eurodance"), N_("Dream"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
68 N_("Southern Rock"), N_("Comedy"), N_("Cult"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
69 N_("Gangsta Rap"), N_("Top 40"), N_("Christian Rap"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
70 N_("Pop/Funk"), N_("Jungle"), N_("Native American"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
71 N_("Cabaret"), N_("New Wave"), N_("Psychedelic"), N_("Rave"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
72 N_("Showtunes"), N_("Trailer"), N_("Lo-Fi"), N_("Tribal"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
73 N_("Acid Punk"), N_("Acid Jazz"), N_("Polka"), N_("Retro"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
74 N_("Musical"), N_("Rock & Roll"), N_("Hard Rock"), N_("Folk"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
75 N_("Folk/Rock"), N_("National Folk"), N_("Swing"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
76 N_("Fast-Fusion"), N_("Bebob"), N_("Latin"), N_("Revival"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
77 N_("Celtic"), N_("Bluegrass"), N_("Avantgarde"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
78 N_("Gothic Rock"), N_("Progressive Rock"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
79 N_("Psychedelic Rock"), N_("Symphonic Rock"), N_("Slow Rock"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
80 N_("Big Band"), N_("Chorus"), N_("Easy Listening"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
81 N_("Acoustic"), N_("Humour"), N_("Speech"), N_("Chanson"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
82 N_("Opera"), N_("Chamber Music"), N_("Sonata"), N_("Symphony"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
83 N_("Booty Bass"), N_("Primus"), N_("Porn Groove"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
84 N_("Satire"), N_("Slow Jam"), N_("Club"), N_("Tango"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
85 N_("Samba"), N_("Folklore"), N_("Ballad"), N_("Power Ballad"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
86 N_("Rhythmic Soul"), N_("Freestyle"), N_("Duet"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
87 N_("Punk Rock"), N_("Drum Solo"), N_("A Cappella"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
88 N_("Euro-House"), N_("Dance Hall"), N_("Goa"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
89 N_("Drum & Bass"), N_("Club-House"), N_("Hardcore"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
90 N_("Terror"), N_("Indie"), N_("BritPop"), N_("Negerpunk"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
91 N_("Polsk Punk"), N_("Beat"), N_("Christian Gangsta Rap"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
92 N_("Heavy Metal"), N_("Black Metal"), N_("Crossover"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
93 N_("Contemporary Christian"), N_("Christian Rock"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
94 N_("Merengue"), N_("Salsa"), N_("Thrash Metal"),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
95 N_("Anime"), N_("JPop"), N_("Synthpop")
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
96 };
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
97
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
98 double
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
99 mpgdec_compute_tpf(struct frame *fr)
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
100 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
101 const int bs[4] = { 0, 384, 1152, 1152 };
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
102 double tpf;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
103
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
104 tpf = bs[fr->lay];
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
105 tpf /= mpgdec_freqs[fr->sampling_frequency] << (fr->lsf);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
106 return tpf;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
107 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
108
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
109 static void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
110 set_synth_functions(struct frame *fr)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
111 {
970
0f294f2b0a9b [svn] - integer-mode decoding accuracy improvements
nenolod
parents: 969
diff changeset
112 typedef int (*func) (mpgdec_real *, int, unsigned char *, int *);
0f294f2b0a9b [svn] - integer-mode decoding accuracy improvements
nenolod
parents: 969
diff changeset
113 typedef int (*func_mono) (mpgdec_real *, unsigned char *, int *);
0f294f2b0a9b [svn] - integer-mode decoding accuracy improvements
nenolod
parents: 969
diff changeset
114 typedef void (*func_dct36) (mpgdec_real *, mpgdec_real *, mpgdec_real *, mpgdec_real *, mpgdec_real *);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
115
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
116 int ds = fr->down_sample;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
117 int p8 = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
118
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
119 static func funcs[][3] = {
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
120 {mpgdec_synth_1to1,
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
121 mpgdec_synth_2to1,
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
122 mpgdec_synth_4to1},
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
123 {mpgdec_synth_1to1_8bit,
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
124 mpgdec_synth_2to1_8bit,
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
125 mpgdec_synth_4to1_8bit},
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
126 };
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
127
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
128 static func_mono funcs_mono[2][4] = {
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
129 {mpgdec_synth_1to1_mono,
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
130 mpgdec_synth_2to1_mono,
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
131 mpgdec_synth_4to1_mono},
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
132 {mpgdec_synth_1to1_8bit_mono,
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
133 mpgdec_synth_2to1_8bit_mono,
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
134 mpgdec_synth_4to1_8bit_mono}
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
135 };
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
136
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
137 if (mpgdec_cfg.resolution == 8)
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
138 p8 = 1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
139 fr->synth = funcs[p8][ds];
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
140 fr->synth_mono = funcs_mono[p8][ds];
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
141 fr->synth_type = SYNTH_FPU;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
142
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
143 if (p8) {
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
144 mpgdec_make_conv16to8_table();
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
145 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
146 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
147
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
148 static void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
149 init(void)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
150 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
151 ConfigDb *db;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
152
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
153 ins = mpgdec_new();
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
154
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
155 memset(&mpgdec_cfg, 0, sizeof(mpgdec_cfg));
813
c8cf439179b8 [svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents: 778
diff changeset
156
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
157 mpgdec_cfg.resolution = 16;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
158 mpgdec_cfg.channels = 2;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
159 mpgdec_cfg.downsample = 0;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
160 mpgdec_cfg.http_buffer_size = 128;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
161 mpgdec_cfg.http_prebuffer = 25;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
162 mpgdec_cfg.proxy_port = 8080;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
163 mpgdec_cfg.proxy_use_auth = FALSE;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
164 mpgdec_cfg.proxy_user = NULL;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
165 mpgdec_cfg.proxy_pass = NULL;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
166 mpgdec_cfg.use_udp_channel = TRUE;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
167 mpgdec_cfg.title_override = FALSE;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
168 mpgdec_cfg.disable_id3v2 = FALSE;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
169 mpgdec_cfg.default_synth = SYNTH_AUTO;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
170
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
171 mpgdec_cfg.title_encoding_enabled = FALSE;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
172 mpgdec_cfg.title_encoding = NULL;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
173
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
174 db = bmp_cfg_db_open();
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
175
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
176 bmp_cfg_db_get_int(db, "MPG123", "resolution", &mpgdec_cfg.resolution);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
177 bmp_cfg_db_get_int(db, "MPG123", "channels", &mpgdec_cfg.channels);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
178 bmp_cfg_db_get_int(db, "MPG123", "downsample", &mpgdec_cfg.downsample);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
179 bmp_cfg_db_get_int(db, "MPG123", "http_buffer_size",
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
180 &mpgdec_cfg.http_buffer_size);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
181 bmp_cfg_db_get_int(db, "MPG123", "http_prebuffer",
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
182 &mpgdec_cfg.http_prebuffer);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
183 bmp_cfg_db_get_bool(db, "MPG123", "save_http_stream",
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
184 &mpgdec_cfg.save_http_stream);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
185 if (!bmp_cfg_db_get_string
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
186 (db, "MPG123", "save_http_path", &mpgdec_cfg.save_http_path))
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
187 mpgdec_cfg.save_http_path = g_strdup(g_get_home_dir());
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
188
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
189 bmp_cfg_db_get_bool(db, "MPG123", "use_udp_channel",
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
190 &mpgdec_cfg.use_udp_channel);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
191
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
192 bmp_cfg_db_get_bool(db, "MPG123", "title_override",
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
193 &mpgdec_cfg.title_override);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
194 bmp_cfg_db_get_bool(db, "MPG123", "disable_id3v2",
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
195 &mpgdec_cfg.disable_id3v2);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
196 if (!bmp_cfg_db_get_string
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
197 (db, "MPG123", "id3_format", &mpgdec_cfg.id3_format))
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
198 mpgdec_cfg.id3_format = g_strdup("%p - %t");
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
199 bmp_cfg_db_get_int(db, "MPG123", "default_synth",
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
200 &mpgdec_cfg.default_synth);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
201
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
202 bmp_cfg_db_get_bool(db, "MPG123", "title_encoding_enabled", &mpgdec_cfg.title_encoding_enabled);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
203 bmp_cfg_db_get_string(db, "MPG123", "title_encoding", &mpgdec_cfg.title_encoding);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
204 if (mpgdec_cfg.title_encoding_enabled)
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
205 mpgdec_id3_encoding_list = g_strsplit_set(mpgdec_cfg.title_encoding, ENCODING_SEPARATOR, 0);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
206
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
207 bmp_cfg_db_get_bool(db, NULL, "use_proxy", &mpgdec_cfg.use_proxy);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
208 bmp_cfg_db_get_string(db, NULL, "proxy_host", &mpgdec_cfg.proxy_host);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
209 bmp_cfg_db_get_int(db, NULL, "proxy_port", &mpgdec_cfg.proxy_port);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
210 bmp_cfg_db_get_bool(db, NULL, "proxy_use_auth", &mpgdec_cfg.proxy_use_auth);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
211 bmp_cfg_db_get_string(db, NULL, "proxy_user", &mpgdec_cfg.proxy_user);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
212 bmp_cfg_db_get_string(db, NULL, "proxy_pass", &mpgdec_cfg.proxy_pass);
1071
592ef16386aa [svn] - use global proxy configuration instead of individual configurations (chainsaw)
nenolod
parents: 997
diff changeset
213
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
214 bmp_cfg_db_close(db);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
215
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
216 if (mpgdec_cfg.resolution != 16 && mpgdec_cfg.resolution != 8)
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
217 mpgdec_cfg.resolution = 16;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
218
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
219 mpgdec_cfg.channels = CLAMP(mpgdec_cfg.channels, 0, 2);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
220 mpgdec_cfg.downsample = CLAMP(mpgdec_cfg.downsample, 0, 2);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
221 mpgdec_getcpuflags(&cpu_fflags, &cpu_efflags);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
222 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
223
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
224 static void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
225 cleanup(void)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
226 {
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
227 g_free(mpgdec_ip.description);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
228 mpgdec_ip.description = NULL;
813
c8cf439179b8 [svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents: 778
diff changeset
229
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
230 if (mpgdec_cfg.save_http_path) {
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
231 free(mpgdec_cfg.save_http_path);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
232 mpgdec_cfg.save_http_path = NULL;
813
c8cf439179b8 [svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents: 778
diff changeset
233 }
c8cf439179b8 [svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents: 778
diff changeset
234
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
235 if (mpgdec_cfg.proxy_host) {
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
236 free(mpgdec_cfg.proxy_host);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
237 mpgdec_cfg.proxy_host = NULL;
813
c8cf439179b8 [svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents: 778
diff changeset
238 }
c8cf439179b8 [svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents: 778
diff changeset
239
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
240 if (mpgdec_cfg.proxy_user) {
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
241 free(mpgdec_cfg.proxy_user);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
242 mpgdec_cfg.proxy_user = NULL;
813
c8cf439179b8 [svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents: 778
diff changeset
243 }
c8cf439179b8 [svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents: 778
diff changeset
244
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
245 if (mpgdec_cfg.proxy_pass) {
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
246 free(mpgdec_cfg.proxy_pass);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
247 mpgdec_cfg.proxy_pass = NULL;
813
c8cf439179b8 [svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents: 778
diff changeset
248 }
c8cf439179b8 [svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents: 778
diff changeset
249
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
250 if (mpgdec_cfg.id3_format) {
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
251 free(mpgdec_cfg.id3_format);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
252 mpgdec_cfg.id3_format = NULL;
813
c8cf439179b8 [svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents: 778
diff changeset
253 }
c8cf439179b8 [svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents: 778
diff changeset
254
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
255 if (mpgdec_cfg.title_encoding) {
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
256 free(mpgdec_cfg.title_encoding);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
257 mpgdec_cfg.title_encoding = NULL;
813
c8cf439179b8 [svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents: 778
diff changeset
258 }
c8cf439179b8 [svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
nenolod
parents: 778
diff changeset
259
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
260 g_strfreev(mpgdec_id3_encoding_list);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
261 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
262
994
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
263 static guint32
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
264 convert_to_header(guint8 * buf)
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
265 {
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
266 return (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + buf[3];
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
267 }
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
268
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
269
777
f3ee3610ca26 [svn] - do not use type/magic detection here
nenolod
parents: 776
diff changeset
270 #if 0
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
271 #define DET_BUF_SIZE 1024
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
272
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
273 static gboolean
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
274 mpgdec_detect_by_content(char *filename)
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
275 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
276 VFSFile *file;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
277 guchar tmp[4];
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
278 guint32 head;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
279 struct frame fr;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
280 guchar buf[DET_BUF_SIZE];
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
281 int in_buf, i;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
282 gboolean ret = FALSE;
775
d8e406227b9a [svn] - reinstate cyc-based checks intelligently
nenolod
parents: 773
diff changeset
283 guint cyc = 0;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
284
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
285 if ((file = vfs_fopen(filename, "rb")) == NULL)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
286 return FALSE;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
287 if (vfs_fread(tmp, 1, 4, file) != 4)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
288 goto done;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
289 head = convert_to_header(tmp);
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
290 while (!mpgdec_head_check(head)) {
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
291 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
292 * The mpeg-stream can start anywhere in the file,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
293 * so we check the entire file
762
a22aa7bfa108 [svn] - try to avoid a buffer overflow when detecting an MPEG stream
nenolod
parents: 761
diff changeset
294 *
771
0f0659a2d5fb [svn] ten iterations?
nenolod
parents: 766
diff changeset
295 * Incorrect! We give up past ten iterations of this
762
a22aa7bfa108 [svn] - try to avoid a buffer overflow when detecting an MPEG stream
nenolod
parents: 761
diff changeset
296 * code for safety's sake. Buffer overflows suck. --nenolod
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
297 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
298 /* Optimize this */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
299 in_buf = vfs_fread(buf, 1, DET_BUF_SIZE, file);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
300 if (in_buf == 0)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
301 goto done;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
302
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
303 for (i = 0; i < in_buf; i++) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
304 head <<= 8;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
305 head |= buf[i];
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
306 if (mpgdec_head_check(head)) {
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
307 vfs_fseek(file, i + 1 - in_buf, SEEK_CUR);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
308 break;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
309 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
310 }
775
d8e406227b9a [svn] - reinstate cyc-based checks intelligently
nenolod
parents: 773
diff changeset
311
d8e406227b9a [svn] - reinstate cyc-based checks intelligently
nenolod
parents: 773
diff changeset
312 if (++cyc > 20)
d8e406227b9a [svn] - reinstate cyc-based checks intelligently
nenolod
parents: 773
diff changeset
313 goto done;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
314 }
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
315 if (mpgdec_decode_header(&fr, head)) {
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
316 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
317 * We found something which looks like a MPEG-header.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
318 * We check the next frame too, to be sure
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
319 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
320
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
321 if (vfs_fseek(file, fr.framesize, SEEK_CUR) != 0)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
322 goto done;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
323 if (vfs_fread(tmp, 1, 4, file) != 4)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
324 goto done;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
325 head = convert_to_header(tmp);
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
326 if (mpgdec_head_check(head) && mpgdec_decode_header(&fr, head))
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
327 ret = TRUE;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
328 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
329
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
330 done:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
331 vfs_fclose(file);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
332 return ret;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
333 }
777
f3ee3610ca26 [svn] - do not use type/magic detection here
nenolod
parents: 776
diff changeset
334 #endif
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
335
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
336 static int
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
337 is_our_file(char *filename)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
338 {
653
97113126c7f9 [svn] - Fix mp3 detection properly.
nenolod
parents: 651
diff changeset
339 gchar *ext = strrchr(filename, '.');
97113126c7f9 [svn] - Fix mp3 detection properly.
nenolod
parents: 651
diff changeset
340
761
363f8644bce7 [svn] - sanity checks here
nenolod
parents: 685
diff changeset
341 if (!strncasecmp(filename, "http://", 7) && (ext && strncasecmp(ext, ".ogg", 4)))
684
d991052592f6 [svn] - Roll back broken HTTP-based stream detection code.
nenolod
parents: 653
diff changeset
342 return TRUE;
777
f3ee3610ca26 [svn] - do not use type/magic detection here
nenolod
parents: 776
diff changeset
343 else if (ext && (!strncasecmp(ext, ".mp3", 4)
f3ee3610ca26 [svn] - do not use type/magic detection here
nenolod
parents: 776
diff changeset
344 || !strncasecmp(ext, ".mp2", 4)
f3ee3610ca26 [svn] - do not use type/magic detection here
nenolod
parents: 776
diff changeset
345 || !strncasecmp(ext, ".mpg", 4)))
f3ee3610ca26 [svn] - do not use type/magic detection here
nenolod
parents: 776
diff changeset
346 return TRUE;
653
97113126c7f9 [svn] - Fix mp3 detection properly.
nenolod
parents: 651
diff changeset
347
778
69d3bb31aa49 [svn] lalala
nenolod
parents: 777
diff changeset
348 return FALSE;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
349 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
350
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
351 static void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
352 play_frame(struct frame *fr)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
353 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
354 if (fr->error_protection) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
355 bsi.wordpointer += 2;
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
356 /* mpgdec_getbits(16); *//* skip crc */
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
357 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
358 if (!fr->do_layer(fr)) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
359 skip_frames = 2;
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
360 mpgdec_info->output_audio = FALSE;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
361 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
362 else {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
363 if (!skip_frames)
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
364 mpgdec_info->output_audio = TRUE;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
365 else
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
366 skip_frames--;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
367 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
368 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
369
994
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
370 static const char *
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
371 get_id3_genre(unsigned char genre_code)
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
372 {
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
373 if (genre_code < GENRE_MAX)
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
374 return gettext(mpgdec_id3_genres[genre_code]);
994
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
375
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
376 return "";
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
377 }
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
378
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
379 guint
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
380 mpgdec_strip_spaces(char *src, size_t n)
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
381 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
382 gchar *space = NULL, /* last space in src */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
383 *start = src;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
384
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
385 while (n--)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
386 switch (*src++) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
387 case '\0':
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
388 n = 0; /* breaks out of while loop */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
389
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
390 src--;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
391 break;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
392 case ' ':
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
393 if (space == NULL)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
394 space = src - 1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
395 break;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
396 default:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
397 space = NULL; /* don't terminate intermediate spaces */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
398
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
399 break;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
400 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
401 if (space != NULL) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
402 src = space;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
403 *src = '\0';
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
404 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
405 return src - start;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
406 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
407
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
408 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
409 * Function extname (filename)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
410 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
411 * Return pointer within filename to its extenstion, or NULL if
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
412 * filename has no extension.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
413 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
414 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
415 static gchar *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
416 extname(const char *filename)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
417 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
418 gchar *ext = strrchr(filename, '.');
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
419
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
420 if (ext != NULL)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
421 ++ext;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
422
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
423 return ext;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
424 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
425
994
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
426 /*
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
427 * Function id3v1_to_id3v2 (v1, v2)
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
428 *
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
429 * Convert ID3v1 tag `v1' to ID3v2 tag `v2'.
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
430 *
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
431 */
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
432 void
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
433 mpgdec_id3v1_to_id3v2(struct id3v1tag_t *v1, struct id3tag_t *v2)
994
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
434 {
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
435 memset(v2, 0, sizeof(struct id3tag_t));
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
436 strncpy(v2->title, v1->title, 30);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
437 strncpy(v2->artist, v1->artist, 30);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
438 strncpy(v2->album, v1->album, 30);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
439 strncpy(v2->comment, v1->u.v1_0.comment, 30);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
440 strncpy(v2->genre, get_id3_genre(v1->genre), sizeof(v2->genre));
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
441 g_strstrip(v2->title);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
442 g_strstrip(v2->artist);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
443 g_strstrip(v2->album);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
444 g_strstrip(v2->comment);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
445 g_strstrip(v2->genre);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
446 {
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
447 char y[5];
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
448 memcpy(y, v1->year, 4); y[4]=0;
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
449 v2->year = atoi(y);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
450 }
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
451
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
452 /* Check for v1.1 tags. */
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
453 if (v1->u.v1_1.__zero == 0)
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
454 v2->track_number = v1->u.v1_1.track_number;
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
455 else
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
456 v2->track_number = 0;
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
457 }
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
458
974
fa6a2ad65e71 [svn] Remove nonexistant tags from TitleInput.
nenolod
parents: 970
diff changeset
459 #define REMOVE_NONEXISTANT_TAG(x) if (!*x) { x = NULL; }
fa6a2ad65e71 [svn] Remove nonexistant tags from TitleInput.
nenolod
parents: 970
diff changeset
460
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
461 /*
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
462 * Function mpgdec_format_song_title (tag, filename)
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
463 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
464 * Create song title according to `tag' and/or `filename' and
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
465 * return it. The title must be subsequently freed using g_free().
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
466 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
467 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
468 gchar *
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
469 mpgdec_format_song_title(TagLib_Tag *taglib_tag, gchar * filename)
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
470 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
471 gchar *title = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
472 TitleInput *input;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
473
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
474 input = bmp_title_input_new();
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
475
957
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
476 if (taglib_tag) {
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
477 input->performer = taglib_tag_artist(taglib_tag);
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
478 input->album_name = taglib_tag_album(taglib_tag);
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
479 input->track_name = taglib_tag_title(taglib_tag);
974
fa6a2ad65e71 [svn] Remove nonexistant tags from TitleInput.
nenolod
parents: 970
diff changeset
480
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
481 mpgdec_strip_spaces(input->performer,strlen(input->performer));
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
482 mpgdec_strip_spaces(input->album_name,strlen(input->album_name));
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
483 mpgdec_strip_spaces(input->track_name,strlen(input->track_name));
974
fa6a2ad65e71 [svn] Remove nonexistant tags from TitleInput.
nenolod
parents: 970
diff changeset
484
957
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
485 input->year = taglib_tag_year(taglib_tag);
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
486 input->track_number = taglib_tag_track(taglib_tag);
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
487 input->genre = taglib_tag_genre(taglib_tag);
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
488 input->comment = taglib_tag_comment(taglib_tag);
974
fa6a2ad65e71 [svn] Remove nonexistant tags from TitleInput.
nenolod
parents: 970
diff changeset
489
fa6a2ad65e71 [svn] Remove nonexistant tags from TitleInput.
nenolod
parents: 970
diff changeset
490 /* remove any blank tags, fucking taglib */
fa6a2ad65e71 [svn] Remove nonexistant tags from TitleInput.
nenolod
parents: 970
diff changeset
491 REMOVE_NONEXISTANT_TAG(input->performer);
fa6a2ad65e71 [svn] Remove nonexistant tags from TitleInput.
nenolod
parents: 970
diff changeset
492 REMOVE_NONEXISTANT_TAG(input->album_name);
fa6a2ad65e71 [svn] Remove nonexistant tags from TitleInput.
nenolod
parents: 970
diff changeset
493 REMOVE_NONEXISTANT_TAG(input->track_name);
fa6a2ad65e71 [svn] Remove nonexistant tags from TitleInput.
nenolod
parents: 970
diff changeset
494 REMOVE_NONEXISTANT_TAG(input->genre);
fa6a2ad65e71 [svn] Remove nonexistant tags from TitleInput.
nenolod
parents: 970
diff changeset
495 REMOVE_NONEXISTANT_TAG(input->comment);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
496 }
1105
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
497 if(input->performer)
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
498 input->performer = str_to_utf8(input->performer);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
499
1105
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
500 if(input->album_name)
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
501 input->album_name = str_to_utf8(input->album_name);
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
502
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
503 if(input->track_name)
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
504 input->track_name = str_to_utf8(input->track_name);
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
505
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
506 if(input->comment)
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
507 input->comment = str_to_utf8(input->comment);
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
508
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
509
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
510 input->file_name = g_path_get_basename(filename);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
511 input->file_path = g_path_get_dirname(filename);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
512 input->file_ext = extname(filename);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
513
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
514 title = xmms_get_titlestring(mpgdec_cfg.title_override ?
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
515 mpgdec_cfg.id3_format :
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
516 xmms_get_gentitle_format(), input);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
517
974
fa6a2ad65e71 [svn] Remove nonexistant tags from TitleInput.
nenolod
parents: 970
diff changeset
518 if (!title /* || strlen(input->track_name) == 0 */) {
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
519 /* Format according to filename. */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
520 title = g_path_get_basename(filename);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
521 if (extname(title))
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
522 *(extname(title) - 1) = '\0'; /* removes period */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
523 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
524
1105
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
525 if(input->performer)
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
526 g_free(input->performer);
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
527 if(input->album_name)
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
528 g_free(input->album_name);
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
529 if(input->track_name)
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
530 g_free(input->track_name);
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
531 if(input->comment)
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
532 g_free(input->comment);
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
533
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
534 g_free(input->file_path);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
535 g_free(input->file_name);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
536 g_free(input);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
537
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
538 return title;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
539 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
540
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
541 /*
957
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
542 * Function get_song_title (filename)
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
543 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
544 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
545 static gchar *
957
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
546 get_song_title(char *filename)
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
547 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
548 char *ret = NULL;
1105
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
549 #ifdef USE_CHARDET
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
550 taglib_set_strings_unicode(FALSE);
4be4d74db123 [svn] automatic character encoding detector for id3 metadata. --enable-chardet enables this feature.
yaz
parents: 1098
diff changeset
551 #endif
957
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
552 taglib_file = taglib_file_new(filename);
997
e64eb333b63f [svn] Properly nullify the tag pointer or we could be passing a stale one.
chainsaw
parents: 994
diff changeset
553 taglib_tag = NULL;
957
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
554 if(taglib_file) {
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
555 taglib_tag = taglib_file_tag(taglib_file);
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
556 taglib_ap = taglib_file_audioproperties(taglib_file);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
557 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
558
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
559 ret = mpgdec_format_song_title(taglib_tag, filename);
957
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
560
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
561 taglib_file_free(taglib_file);
12f57026da8f [svn] First attempt at introducing taglib here. Very rough, needs polishing. Please wear protective goggles before opening the file dialog. It *will* explode.
chainsaw
parents: 813
diff changeset
562 taglib_tag_free_strings();
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
563 return ret;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
564 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
565
994
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
566 static long
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
567 get_song_length(VFSFile * file)
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
568 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
569 int len;
994
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
570 char tmp[4];
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
571
994
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
572 vfs_fseek(file, 0, SEEK_END);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
573 len = vfs_ftell(file);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
574 vfs_fseek(file, -128, SEEK_END);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
575 vfs_fread(tmp, 1, 3, file);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
576 if (!strncmp(tmp, "TAG", 3))
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
577 len -= 128;
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
578 return len;
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
579 }
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
580
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
581
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
582 static guint
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
583 get_song_time(VFSFile * file)
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
584 {
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
585 guint32 head;
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
586 guchar tmp[4], *buf;
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
587 struct frame frm;
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
588 xing_header_t xing_header;
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
589 double tpf, bpf;
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
590 guint32 len;
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
591
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
592 if (!file)
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
593 return -1;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
594
994
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
595 vfs_fseek(file, 0, SEEK_SET);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
596 if (vfs_fread(tmp, 1, 4, file) != 4)
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
597 return 0;
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
598 head = convert_to_header(tmp);
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
599 while (!mpgdec_head_check(head)) {
994
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
600 head <<= 8;
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
601 if (vfs_fread(tmp, 1, 1, file) != 1)
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
602 return 0;
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
603 head |= tmp[0];
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
604 }
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
605 if (mpgdec_decode_header(&frm, head)) {
994
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
606 buf = g_malloc(frm.framesize + 4);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
607 vfs_fseek(file, -4, SEEK_CUR);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
608 vfs_fread(buf, 1, frm.framesize + 4, file);
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
609 tpf = mpgdec_compute_tpf(&frm);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
610 if (mpgdec_get_xing_header(&xing_header, buf)) {
994
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
611 g_free(buf);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
612 if (xing_header.bytes == 0)
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
613 xing_header.bytes = get_song_length(file);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
614 return (tpf * xing_header.frames * 1000);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
615 }
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
616 g_free(buf);
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
617 bpf = mpgdec_compute_bpf(&frm);
994
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
618 len = get_song_length(file);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
619 return ((guint) (len / bpf) * tpf * 1000);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
620 }
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
621 return 0;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
622 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
623
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
624 static void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
625 get_song_info(char *filename, char **title_real, int *len_real)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
626 {
994
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
627 VFSFile *file;
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
628
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
629 (*len_real) = -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
630 (*title_real) = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
631
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
632 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
633 * TODO: Getting song info from http streams.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
634 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
635 if (!strncasecmp(filename, "http://", 7))
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
636 return;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
637
994
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
638 if ((file = vfs_fopen(filename, "rb")) != NULL) {
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
639 (*len_real) = get_song_time(file);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
640 (*title_real) = get_song_title(filename);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
641 vfs_fclose(file);
3d2984564cb8 [svn] Taglib length determination veto by nenolod, reverting. Leaving fileinfo optimizations in place, though.
chainsaw
parents: 993
diff changeset
642 }
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
643 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
644
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
645 static int
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
646 open_output(void)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
647 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
648 int r;
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
649 AFormat fmt = mpgdec_cfg.resolution == 16 ? FMT_S16_NE : FMT_U8;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
650 int freq = mpgdec_freqs[fr.sampling_frequency] >> mpgdec_cfg.downsample;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
651 int channels = mpgdec_cfg.channels == 2 ? fr.stereo : 1;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
652 r = mpgdec_ip.output->open_audio(fmt, freq, channels);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
653
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
654 if (r && dopause) {
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
655 mpgdec_ip.output->pause(TRUE);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
656 dopause = FALSE;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
657 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
658
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
659 return r;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
660 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
661
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
662
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
663 static int
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
664 mpgdec_seek(struct frame *fr, xing_header_t * xh, gboolean vbr, int time)
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
665 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
666 int jumped = -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
667
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
668 if (xh) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
669 int percent = ((double) time * 100.0) /
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
670 (mpgdec_info->num_frames * mpgdec_info->tpf);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
671 int byte = mpgdec_seek_point(xh, percent);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
672 jumped = mpgdec_stream_jump_to_byte(fr, byte);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
673 }
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
674 else if (vbr && mpgdec_length > 0) {
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
675 int byte = ((guint64) time * 1000 * mpgdec_info->filesize) /
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
676 mpgdec_length;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
677 jumped = mpgdec_stream_jump_to_byte(fr, byte);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
678 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
679 else {
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
680 int frame = time / mpgdec_info->tpf;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
681 jumped = mpgdec_stream_jump_to_frame(fr, frame);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
682 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
683
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
684 return jumped;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
685 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
686
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
687
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
688 static void *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
689 decode_loop(void *arg)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
690 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
691 gboolean have_xing_header = FALSE, vbr = FALSE;
1096
9b4e9be457f0 [svn] - remove improper sampling rate change condition. Valid MP3s will not do this. Infact, I've never seen an MP3 that does this. Additionally, it doesn't even work with Shoutcast.
nenolod
parents: 1090
diff changeset
692 int disp_count = 0;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
693 char *filename = arg;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
694 xing_header_t xing_header;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
695
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
696 /* This is used by fileinfo on http streams */
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
697 mpgdec_bitrate = 0;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
698
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
699 mpgdec_pcm_sample = g_malloc0(32768);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
700 mpgdec_pcm_point = 0;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
701 mpgdec_filename = filename;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
702
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
703 mpgdec_read_frame_init();
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
704
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
705 mpgdec_open_stream(filename, -1);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
706
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
707 if (mpgdec_info->eof || !mpgdec_read_frame(&fr))
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
708 mpgdec_info->eof = TRUE;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
709
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
710 if (!mpgdec_info->eof && mpgdec_info->going) {
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
711 if (mpgdec_cfg.channels == 2)
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
712 fr.single = -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
713 else
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
714 fr.single = 3;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
715
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
716 fr.down_sample = mpgdec_cfg.downsample;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
717 fr.down_sample_sblimit = SBLIMIT >> mpgdec_cfg.downsample;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
718 set_synth_functions(&fr);
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
719 mpgdec_init_layer3(fr.down_sample_sblimit);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
720
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
721 mpgdec_info->tpf = mpgdec_compute_tpf(&fr);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
722 if (strncasecmp(filename, "http://", 7)) {
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
723 if (mpgdec_stream_check_for_xing_header(&fr, &xing_header)) {
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
724 mpgdec_info->num_frames = xing_header.frames;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
725 have_xing_header = TRUE;
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
726 mpgdec_read_frame(&fr);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
727 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
728 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
729
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
730 for (;;) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
731 memcpy(&temp_fr, &fr, sizeof(struct frame));
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
732 if (!mpgdec_read_frame(&temp_fr)) {
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
733 mpgdec_info->eof = TRUE;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
734 break;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
735 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
736 if (fr.lay != temp_fr.lay ||
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
737 fr.sampling_frequency != temp_fr.sampling_frequency ||
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
738 fr.stereo != temp_fr.stereo || fr.lsf != temp_fr.lsf)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
739 memcpy(&fr, &temp_fr, sizeof(struct frame));
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
740 else
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
741 break;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
742 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
743
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
744 if (!have_xing_header && strncasecmp(filename, "http://", 7))
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
745 mpgdec_info->num_frames = mpgdec_calc_numframes(&fr);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
746
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
747 memcpy(&fr, &temp_fr, sizeof(struct frame));
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
748 mpgdec_bitrate = tabsel_123[fr.lsf][fr.lay - 1][fr.bitrate_index];
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
749 disp_bitrate = mpgdec_bitrate;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
750 mpgdec_frequency = mpgdec_freqs[fr.sampling_frequency];
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
751 mpgdec_stereo = fr.stereo;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
752 mpgdec_layer = fr.lay;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
753 mpgdec_lsf = fr.lsf;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
754 mpgdec_mpeg25 = fr.mpeg25;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
755 mpgdec_mode = fr.mode;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
756
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
757 if (strncasecmp(filename, "http://", 7)) {
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
758 mpgdec_length = mpgdec_info->num_frames * mpgdec_info->tpf * 1000;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
759 if (!mpgdec_title)
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
760 mpgdec_title = get_song_title(filename);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
761 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
762 else {
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
763 if (!mpgdec_title)
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
764 mpgdec_title = mpgdec_http_get_title(filename);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
765 mpgdec_length = -1;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
766 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
767
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
768 mpgdec_ip.set_info(mpgdec_title, mpgdec_length,
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
769 mpgdec_bitrate * 1000,
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
770 mpgdec_freqs[fr.sampling_frequency], fr.stereo);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
771
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
772 output_opened = TRUE;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
773
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
774 if (!open_output()) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
775 audio_error = TRUE;
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
776 mpgdec_info->eof = TRUE;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
777 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
778 else
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
779 play_frame(&fr);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
780 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
781
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
782 mpgdec_info->first_frame = FALSE;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
783 while (mpgdec_info->going) {
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
784 if (mpgdec_info->jump_to_time != -1) {
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
785 void *xp = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
786 if (have_xing_header)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
787 xp = &xing_header;
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
788 if (mpgdec_seek(&fr, xp, vbr, mpgdec_info->jump_to_time) > -1) {
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
789 mpgdec_ip.output->flush(mpgdec_info->jump_to_time * 1000);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
790 mpgdec_info->eof = FALSE;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
791 }
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
792 mpgdec_info->jump_to_time = -1;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
793 }
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
794 if (!mpgdec_info->eof) {
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
795 if (mpgdec_read_frame(&fr) != 0) {
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
796 if (fr.lay != mpgdec_layer || fr.lsf != mpgdec_lsf) {
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
797 memcpy(&temp_fr, &fr, sizeof(struct frame));
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
798 if (mpgdec_read_frame(&temp_fr) != 0) {
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
799 if (fr.lay == temp_fr.lay && fr.lsf == temp_fr.lsf) {
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
800 mpgdec_layer = fr.lay;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
801 mpgdec_lsf = fr.lsf;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
802 memcpy(&fr, &temp_fr, sizeof(struct frame));
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
803 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
804 else {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
805 memcpy(&fr, &temp_fr, sizeof(struct frame));
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
806 skip_frames = 2;
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
807 mpgdec_info->output_audio = FALSE;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
808 continue;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
809 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
810
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
811 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
812 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
813
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
814 if (tabsel_123[fr.lsf][fr.lay - 1][fr.bitrate_index] !=
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
815 mpgdec_bitrate)
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
816 mpgdec_bitrate =
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
817 tabsel_123[fr.lsf][fr.lay - 1][fr.bitrate_index];
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
818
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
819 if (!disp_count) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
820 disp_count = 20;
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
821 if (mpgdec_bitrate != disp_bitrate) {
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
822 /* FIXME networks streams */
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
823 disp_bitrate = mpgdec_bitrate;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
824 if (!have_xing_header
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
825 && strncasecmp(filename, "http://", 7)) {
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
826 double rel = mpgdec_relative_pos();
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
827 if (rel) {
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
828 mpgdec_length =
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
829 mpgdec_ip.output->written_time() / rel;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
830 vbr = TRUE;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
831 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
832
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
833 if (rel == 0 || !(mpgdec_length > 0)) {
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
834 mpgdec_info->num_frames =
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
835 mpgdec_calc_numframes(&fr);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
836 mpgdec_info->tpf = mpgdec_compute_tpf(&fr);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
837 mpgdec_length =
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
838 mpgdec_info->num_frames *
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
839 mpgdec_info->tpf * 1000;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
840 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
841
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
842
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
843 }
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
844 mpgdec_ip.set_info(mpgdec_title, mpgdec_length,
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
845 mpgdec_bitrate * 1000,
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
846 mpgdec_frequency, mpgdec_stereo);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
847 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
848 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
849 else
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
850 disp_count--;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
851 play_frame(&fr);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
852 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
853 else {
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
854 mpgdec_ip.output->buffer_free();
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
855 mpgdec_ip.output->buffer_free();
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
856 mpgdec_info->eof = TRUE;
1097
03dbf5494d40 [svn] s:xmms_usleep:g_usleep:g
nenolod
parents: 1096
diff changeset
857 g_usleep(10000);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
858 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
859 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
860 else {
1097
03dbf5494d40 [svn] s:xmms_usleep:g_usleep:g
nenolod
parents: 1096
diff changeset
861 g_usleep(10000);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
862 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
863 }
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
864 g_free(mpgdec_title);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
865 mpgdec_title = NULL;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
866 mpgdec_stream_close();
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
867 if (output_opened && !audio_error)
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
868 mpgdec_ip.output->close_audio();
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
869 g_free(mpgdec_pcm_sample);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
870 mpgdec_filename = NULL;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
871 g_free(filename);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
872
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
873 return NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
874 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
875
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
876 static void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
877 play_file(char *filename)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
878 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
879 memset(&fr, 0, sizeof(struct frame));
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
880 memset(&temp_fr, 0, sizeof(struct frame));
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
881
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
882 mpgdec_info = g_malloc0(sizeof(PlayerInfo));
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
883 mpgdec_info->going = 1;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
884 mpgdec_info->first_frame = TRUE;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
885 mpgdec_info->output_audio = TRUE;
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
886 mpgdec_info->jump_to_time = -1;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
887 skip_frames = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
888 audio_error = FALSE;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
889 output_opened = FALSE;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
890 dopause = FALSE;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
891
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
892 decode_thread = g_thread_create(decode_loop, g_strdup(filename), TRUE,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
893 NULL);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
894 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
895
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
896 static void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
897 stop(void)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
898 {
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
899 if (mpgdec_info && mpgdec_info->going) {
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
900 mpgdec_info->going = FALSE;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
901 g_thread_join(decode_thread);
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
902 g_free(mpgdec_info);
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
903 mpgdec_info = NULL;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
904 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
905 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
906
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
907 static void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
908 seek(int time)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
909 {
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
910 mpgdec_info->jump_to_time = time;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
911
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
912 while (mpgdec_info->jump_to_time != -1)
1097
03dbf5494d40 [svn] s:xmms_usleep:g_usleep:g
nenolod
parents: 1096
diff changeset
913 g_usleep(10000);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
914 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
915
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
916 static void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
917 do_pause(short p)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
918 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
919 if (output_opened)
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
920 mpgdec_ip.output->pause(p);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
921 else
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
922 dopause = p;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
923 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
924
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
925 static int
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
926 get_time(void)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
927 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
928 if (audio_error)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
929 return -2;
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
930 if (!mpgdec_info)
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
931 return -1;
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
932 if (!mpgdec_info->going
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
933 || (mpgdec_info->eof && !mpgdec_ip.output->buffer_playing()))
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
934 return -1;
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
935 return mpgdec_ip.output->output_time();
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
936 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
937
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
938 static void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
939 aboutbox(void)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
940 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
941 static GtkWidget *aboutbox;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
942
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
943 if (aboutbox != NULL)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
944 return;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
945
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
946 aboutbox = xmms_show_message(_("About MPEG Audio Plugin"),
223
e7e9a86c0c01 [svn] Update credits on here reflecting audacious-decoder changes.
nenolod
parents: 177
diff changeset
947 _("Audacious decoding engine by William Pitcock <nenolod@nenolod.net>, derived from:\n"
e7e9a86c0c01 [svn] Update credits on here reflecting audacious-decoder changes.
nenolod
parents: 177
diff changeset
948 "mpg123 decoding engine by Michael Hipp <mh@mpg123.de>\n"
e7e9a86c0c01 [svn] Update credits on here reflecting audacious-decoder changes.
nenolod
parents: 177
diff changeset
949 "Derived partially from mpg123 0.59s.mc3 as well.\n"
129
ce9d4aa5889a [svn] Update the credits to note the code sync that occured.
nenolod
parents: 61
diff changeset
950 "Based on the original XMMS plugin."),
ce9d4aa5889a [svn] Update the credits to note the code sync that occured.
nenolod
parents: 61
diff changeset
951 _("Ok"),
ce9d4aa5889a [svn] Update the credits to note the code sync that occured.
nenolod
parents: 61
diff changeset
952 FALSE, NULL, NULL);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
953
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
954 g_signal_connect(G_OBJECT(aboutbox), "destroy",
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
955 G_CALLBACK(gtk_widget_destroyed), &aboutbox);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
956 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
957
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
958 InputPlugin mpgdec_ip = {
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
959 NULL,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
960 NULL,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
961 NULL, /* Description */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
962 init,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
963 aboutbox,
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
964 mpgdec_configure,
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
965 is_our_file,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
966 NULL,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
967 play_file,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
968 stop,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
969 do_pause,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
970 seek,
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
971 mpgdec_set_eq,
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
972 get_time,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
973 NULL, NULL,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
974 cleanup,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
975 NULL,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
976 NULL, NULL, NULL,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
977 get_song_info,
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
978 mpgdec_file_info_box, /* file_info_box */
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
979 NULL
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
980 };
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
981
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
982 InputPlugin *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
983 get_iplugin_info(void)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
984 {
1098
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
985 mpgdec_ip.description = g_strdup_printf(_("MPEG Audio Plugin"));
b5ae09a6c2f1 [svn] - prepare to split audacious code away from the actual decoder and use a highlevel API
nenolod
parents: 1097
diff changeset
986 return &mpgdec_ip;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
987 }