Mercurial > audlegacy-plugins
annotate src/wavpack/libwavpack.cxx @ 3052:95b34f46a231
Comment out MPEG2/MPEG4 determination using the variable id. It is not used anywhere. Code analysis run, unique ID 6nYoHM.
author | Tony Vroon <chainsaw@gentoo.org> |
---|---|
date | Sat, 18 Apr 2009 19:06:20 +0100 |
parents | 3134a0987162 |
children | 85a35e03b0c9 |
rev | line source |
---|---|
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
1 //#define AUD_DEBUG |
2233 | 2 |
1436
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
3 #include <string> |
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
4 |
109 | 5 #include <assert.h> |
6 #include <string.h> | |
7 #include <stdio.h> | |
8 #include <stdlib.h> | |
9 #include <unistd.h> | |
291
93c0da3f7a86
[svn] - make wavpack/wavpack.h include forced extern "C".
nenolod
parents:
284
diff
changeset
|
10 extern "C" { |
284
72f0de06bb56
[svn] - wavpack/wputils.h is deprecated, wavpack/wavpack.h should be used instead.
nenolod
parents:
264
diff
changeset
|
11 #include <wavpack/wavpack.h> |
2971
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2941
diff
changeset
|
12 #include <audlegacy/plugin.h> |
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2941
diff
changeset
|
13 #include <audlegacy/output.h> |
109 | 14 } |
15 #include <glib.h> | |
16 #include <gtk/gtk.h> | |
17 #include <math.h> | |
18 #include "tags.h" | |
434
7385182ae4b8
[svn] - add missing config.h inclusion for wavpack, null and metronom plugin
giacomo
parents:
372
diff
changeset
|
19 #include "../../config.h" |
109 | 20 #ifndef M_LN10 |
21 #define M_LN10 2.3025850929940456840179914546843642 | |
22 #endif | |
23 | |
24 #define BUFFER_SIZE 256 // read buffer size, in samples | |
2429
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
25 #define SAMPLE_SIZE(a) (a == 8 ? sizeof(guint8) : (a == 16 ? sizeof(guint16) : sizeof(guint32))) |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
26 #define SAMPLE_FMT(a) (a == 8 ? FMT_S8 : (a == 16 ? FMT_S16_NE : (a == 24 ? FMT_S24_NE : FMT_S32_NE))) |
109 | 27 |
28 static void wv_load_config(); | |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
29 static gint wv_is_our_fd(gchar *filename, VFSFile *file); |
1526
56b0d46a02f6
wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents:
1521
diff
changeset
|
30 static Tuple *wv_probe_for_tuple(gchar *filename, VFSFile *file); |
566 | 31 static void wv_play(InputPlayback *); |
32 static void wv_stop(InputPlayback *); | |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
33 static void wv_pause(InputPlayback *, gshort); |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
34 static void wv_seek(InputPlayback *, gint); |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
35 static gint wv_get_time(InputPlayback *); |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
36 static void wv_get_song_info(gchar *, gchar **, gint *); |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
37 static gchar *generate_title(const gchar *, WavpackContext *ctx); |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
38 static gint isSeek; |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
39 static gshort paused; |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
40 static gboolean killDecodeThread; |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
41 static gboolean AudioError; |
109 | 42 static GThread *thread_handle; |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
43 static Tuple *wv_get_song_tuple(gchar *); |
109 | 44 |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
45 // in ui.cxx |
109 | 46 void wv_configure(); |
47 void wv_about_box(void); | |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
48 void wv_file_info_box(gchar *); |
109 | 49 extern gboolean clipPreventionEnabled; |
50 extern gboolean dynBitrateEnabled; | |
51 extern gboolean replaygainEnabled; | |
52 extern gboolean albumReplaygainEnabled; | |
53 extern gboolean openedAudio; | |
54 | |
1044
b1128efde471
[svn] - get rid of all warnings gcc 4.2.0 emits with my build configuration.
yaz
parents:
566
diff
changeset
|
55 const gchar *wv_fmts[] = { "wv", NULL }; |
372
a157306caf03
[svn] - finalize the plugin-side of the extension-assist ABI
nenolod
parents:
368
diff
changeset
|
56 |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
57 InputPlugin wvpack = { |
109 | 58 NULL, //handle |
59 NULL, //filename | |
1185 | 60 (gchar *)"WavPack Audio Plugin", |
109 | 61 wv_load_config, |
1620
87a52bc00926
wavpack: I need a rewrite.
William Pitcock <nenolod@atheme.org>
parents:
1526
diff
changeset
|
62 NULL, |
109 | 63 wv_about_box, |
64 wv_configure, | |
1620
87a52bc00926
wavpack: I need a rewrite.
William Pitcock <nenolod@atheme.org>
parents:
1526
diff
changeset
|
65 FALSE, |
332
626f9f4d79a8
[svn] Remove old-style is_our_file() where a new-style is_our_fd() exists
kiyoshi
parents:
291
diff
changeset
|
66 NULL, |
109 | 67 NULL, //no use |
68 wv_play, | |
69 wv_stop, | |
70 wv_pause, | |
71 wv_seek, | |
72 wv_get_time, | |
73 NULL, //get volume | |
74 NULL, //set volume | |
75 NULL, //cleanup | |
76 NULL, //obsolete | |
77 NULL, //add_vis | |
78 NULL, | |
79 wv_get_song_info, | |
263 | 80 wv_file_info_box, //info box |
114 | 81 wv_get_song_tuple, |
253
ab24cfe495e0
[svn] Port to NewVFS file probe & add explicit cast to silence warning, thanks to spb.
chainsaw
parents:
247
diff
changeset
|
82 wv_is_our_fd, |
1044
b1128efde471
[svn] - get rid of all warnings gcc 4.2.0 emits with my build configuration.
yaz
parents:
566
diff
changeset
|
83 (gchar **)wv_fmts, |
1526
56b0d46a02f6
wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents:
1521
diff
changeset
|
84 NULL, // high precision seeking |
56b0d46a02f6
wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents:
1521
diff
changeset
|
85 wv_probe_for_tuple // probe for a tuple |
109 | 86 }; |
87 | |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
88 gint32 read_bytes (void *id, void *data, gint32 bcount) |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
89 { |
1978 | 90 return aud_vfs_fread (data, 1, bcount, (VFSFile *) id); |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
91 } |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
92 |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
93 guint32 get_pos (void *id) |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
94 { |
1978 | 95 return aud_vfs_ftell ((VFSFile *) id); |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
96 } |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
97 |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
98 gint set_pos_abs (void *id, guint32 pos) |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
99 { |
1978 | 100 return aud_vfs_fseek ((VFSFile *) id, pos, SEEK_SET); |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
101 } |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
102 |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
103 gint set_pos_rel (void *id, gint32 delta, gint mode) |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
104 { |
1978 | 105 return aud_vfs_fseek ((VFSFile *) id, delta, mode); |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
106 } |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
107 |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
108 gint push_back_byte (void *id, gint c) |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
109 { |
1978 | 110 return aud_vfs_ungetc (c, (VFSFile *) id); |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
111 } |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
112 |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
113 guint32 get_length (void *id) |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
114 { |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
115 VFSFile *file = (VFSFile *) id; |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
116 guint32 sz = 0; |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
117 |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
118 if (file == NULL) |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
119 return 0; |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
120 |
1978 | 121 aud_vfs_fseek(file, 0, SEEK_END); |
122 sz = aud_vfs_ftell(file); | |
123 aud_vfs_fseek(file, 0, SEEK_SET); | |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
124 |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
125 return sz; |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
126 } |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
127 |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
128 /* XXX streams?? */ |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
129 gint can_seek (void *id) |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
130 { |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
131 return 1; |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
132 } |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
133 |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
134 gint32 write_bytes (void *id, void *data, gint32 bcount) |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
135 { |
1978 | 136 return aud_vfs_fwrite (data, 1, bcount, (VFSFile *) id); |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
137 } |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
138 |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
139 WavpackStreamReader reader = { |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
140 read_bytes, get_pos, set_pos_abs, set_pos_rel, push_back_byte, get_length, can_seek, |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
141 write_bytes |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
142 }; |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
143 |
109 | 144 class WavpackDecoder |
145 { | |
146 public: | |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
147 InputPlugin *wvpack; |
2429
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
148 gint32 *input; |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
149 void *output; |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
150 gint sample_rate; |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
151 gint num_channels; |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
152 guint num_samples; |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
153 guint length; |
2429
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
154 gint bits_per_sample; |
109 | 155 WavpackContext *ctx; |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
156 gchar error_buff[80]; //string space is allocated by the caller and must be at least 80 chars |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
157 VFSFile *wv_Input, *wvc_Input; |
109 | 158 |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
159 WavpackDecoder(InputPlugin *wvpack) : wvpack(wvpack) |
109 | 160 { |
161 ctx = NULL; | |
162 input = NULL; | |
163 output = NULL; | |
1520
2ed7413c199a
wavpack fixes
William Pitcock <nenolod@atheme-project.org>
parents:
1501
diff
changeset
|
164 wv_Input = NULL; |
2ed7413c199a
wavpack fixes
William Pitcock <nenolod@atheme-project.org>
parents:
1501
diff
changeset
|
165 wvc_Input = NULL; |
109 | 166 } |
167 | |
168 ~WavpackDecoder() | |
169 { | |
170 if (input != NULL) { | |
171 free(input); | |
172 input = NULL; | |
173 } | |
174 if (output != NULL) { | |
175 free(output); | |
176 output = NULL; | |
177 } | |
178 if (ctx != NULL) { | |
1520
2ed7413c199a
wavpack fixes
William Pitcock <nenolod@atheme-project.org>
parents:
1501
diff
changeset
|
179 if (wv_Input) |
1978 | 180 aud_vfs_fclose(wv_Input); |
1520
2ed7413c199a
wavpack fixes
William Pitcock <nenolod@atheme-project.org>
parents:
1501
diff
changeset
|
181 |
2ed7413c199a
wavpack fixes
William Pitcock <nenolod@atheme-project.org>
parents:
1501
diff
changeset
|
182 if (wvc_Input) |
1978 | 183 aud_vfs_fclose(wvc_Input); |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
184 g_free(ctx); |
109 | 185 ctx = NULL; |
186 } | |
187 } | |
188 | |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
189 gboolean attach(const gchar *filename) |
109 | 190 { |
1978 | 191 wv_Input = aud_vfs_fopen(filename, "rb"); |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
192 |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
193 gchar *corrFilename = g_strconcat(filename, "c", NULL); |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
194 |
1978 | 195 wvc_Input = aud_vfs_fopen(corrFilename, "rb"); |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
196 |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
197 g_free(corrFilename); |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
198 |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
199 ctx = WavpackOpenFileInputEx(&reader, wv_Input, wvc_Input, error_buff, OPEN_TAGS | OPEN_WVC, 0); |
109 | 200 |
201 if (ctx == NULL) { | |
202 return false; | |
203 } | |
204 | |
237 | 205 return true; |
206 } | |
207 | |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
208 gboolean attach(gchar *filename, VFSFile *wvi) |
1501
04f8c7624ea3
Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents:
1465
diff
changeset
|
209 { |
1520
2ed7413c199a
wavpack fixes
William Pitcock <nenolod@atheme-project.org>
parents:
1501
diff
changeset
|
210 ctx = WavpackOpenFileInputEx(&reader, wvi, NULL, error_buff, OPEN_TAGS, 0); |
1501
04f8c7624ea3
Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents:
1465
diff
changeset
|
211 |
04f8c7624ea3
Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents:
1465
diff
changeset
|
212 if (ctx == NULL) |
04f8c7624ea3
Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents:
1465
diff
changeset
|
213 return false; |
04f8c7624ea3
Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents:
1465
diff
changeset
|
214 |
04f8c7624ea3
Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents:
1465
diff
changeset
|
215 return true; |
04f8c7624ea3
Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents:
1465
diff
changeset
|
216 } |
04f8c7624ea3
Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents:
1465
diff
changeset
|
217 |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
218 gboolean attach_to_play(InputPlayback *playback) |
237 | 219 { |
1989
1bd99632fc4d
wavpack: set_params()
William Pitcock <nenolod@atheme.org>
parents:
1978
diff
changeset
|
220 wv_Input = aud_vfs_fopen(playback->filename, "rb"); |
237 | 221 |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
222 gchar *corrFilename = g_strconcat(playback->filename, "c", NULL); |
237 | 223 |
1978 | 224 wvc_Input = aud_vfs_fopen(corrFilename, "rb"); |
237 | 225 |
226 g_free(corrFilename); | |
227 | |
228 ctx = WavpackOpenFileInputEx(&reader, wv_Input, wvc_Input, error_buff, OPEN_TAGS | OPEN_WVC, 0); | |
229 | |
1501
04f8c7624ea3
Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents:
1465
diff
changeset
|
230 if (ctx == NULL) |
237 | 231 return false; |
232 | |
109 | 233 sample_rate = WavpackGetSampleRate(ctx); |
234 num_channels = WavpackGetNumChannels(ctx); | |
2429
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
235 bits_per_sample = WavpackGetBitsPerSample(ctx); |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
236 num_samples = WavpackGetNumSamples(ctx); |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
237 length = num_samples / sample_rate; |
2429
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
238 input = (gint32 *) malloc(BUFFER_SIZE * num_channels * sizeof(guint32)); |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
239 output = malloc(BUFFER_SIZE * num_channels * SAMPLE_SIZE(bits_per_sample)); |
2001
aa8bd7b56cda
make wavpack compile again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1998
diff
changeset
|
240 playback->set_params(playback, generate_title(playback->filename, ctx), |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
241 length * 1000, |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
242 (gint) WavpackGetAverageBitrate(ctx, num_channels), |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
243 (gint) sample_rate, num_channels); |
109 | 244 return true; |
245 } | |
246 | |
2711
183bd24000c9
Use InputPlayback structure properly.
Matti Hamalainen <ccr@tnsp.org>
parents:
2709
diff
changeset
|
247 gboolean open_audio(InputPlayback *playback) |
109 | 248 { |
2711
183bd24000c9
Use InputPlayback structure properly.
Matti Hamalainen <ccr@tnsp.org>
parents:
2709
diff
changeset
|
249 return playback->output->open_audio(SAMPLE_FMT(bits_per_sample), sample_rate, num_channels); |
109 | 250 } |
251 | |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
252 void process_buffer(InputPlayback *playback, guint32 num_samples) |
109 | 253 { |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
254 guint32 i; |
2429
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
255 gint32* rp = input; |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
256 gint8* wp = reinterpret_cast<gint8*>(output); |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
257 gint16* wp2 = reinterpret_cast<gint16*>(output); |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
258 gint32* wp4 = reinterpret_cast<gint32*>(output); |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
259 |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
260 if (bits_per_sample % 8 != 0) { |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
261 AUDDBG("Can not convert to %d bps: not a multiple of 8\n", bits_per_sample); |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
262 } |
1501
04f8c7624ea3
Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents:
1465
diff
changeset
|
263 |
2429
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
264 if (bits_per_sample == 8) { |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
265 for (i=0; i<num_samples * num_channels; i++, wp++, rp++) { |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
266 *wp = *rp & 0xff; |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
267 } |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
268 } else if (bits_per_sample == 16) { |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
269 for (i=0; i<num_samples * num_channels; i++, wp2++, rp++) { |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
270 *wp2 = *rp & 0xffff; |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
271 } |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
272 } else if (bits_per_sample == 24 || bits_per_sample == 32) { /* 24bit value stored in lowest 3 bytes */ |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
273 for (i=0; i<num_samples * num_channels; i++, wp4++, rp++) { |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
274 *wp4 = *rp; |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
275 } |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
276 } |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
277 |
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
278 playback->pass_audio(playback, SAMPLE_FMT(bits_per_sample), |
111 | 279 num_channels, |
2429
b6f09d280f2c
Add support for 24-bit wavpack files. (Bugzilla #190)
Michał Lipski <tallica@o2.pl>
parents:
2233
diff
changeset
|
280 num_samples * num_channels * SAMPLE_SIZE(bits_per_sample), |
111 | 281 output, |
282 NULL); | |
109 | 283 } |
284 }; | |
285 | |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
286 InputPlugin *wv_iplist[] = { &wvpack, NULL }; |
1080 | 287 |
1395
761e17b23e0c
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
1354
diff
changeset
|
288 DECLARE_PLUGIN(wavpack, NULL, NULL, wv_iplist, NULL, NULL, NULL, NULL,NULL); |
109 | 289 |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
290 static gint |
253
ab24cfe495e0
[svn] Port to NewVFS file probe & add explicit cast to silence warning, thanks to spb.
chainsaw
parents:
247
diff
changeset
|
291 wv_is_our_fd(gchar *filename, VFSFile *file) |
109 | 292 { |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
293 WavpackDecoder d(&wvpack); |
1501
04f8c7624ea3
Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents:
1465
diff
changeset
|
294 |
04f8c7624ea3
Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents:
1465
diff
changeset
|
295 if (d.attach(filename, file)) |
253
ab24cfe495e0
[svn] Port to NewVFS file probe & add explicit cast to silence warning, thanks to spb.
chainsaw
parents:
247
diff
changeset
|
296 return TRUE; |
1501
04f8c7624ea3
Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents:
1465
diff
changeset
|
297 |
109 | 298 return FALSE; |
299 } | |
300 | |
301 void | |
302 load_tag(ape_tag *tag, WavpackContext *ctx) | |
303 { | |
304 memset(tag, 0, sizeof(ape_tag)); | |
305 WavpackGetTagItem(ctx, "Album", tag->album, sizeof(tag->album)); | |
306 WavpackGetTagItem(ctx, "Artist", tag->artist, sizeof(tag->artist)); | |
307 WavpackGetTagItem(ctx, "Comment", tag->comment, sizeof(tag->comment)); | |
308 WavpackGetTagItem(ctx, "Genre", tag->genre, sizeof(tag->genre)); | |
309 WavpackGetTagItem(ctx, "Title", tag->title, sizeof(tag->title)); | |
310 WavpackGetTagItem(ctx, "Track", tag->track, sizeof(tag->track)); | |
311 WavpackGetTagItem(ctx, "Year", tag->year, sizeof(tag->year)); | |
312 } | |
313 | |
314 static void * | |
315 end_thread() | |
316 { | |
317 return 0; | |
318 } | |
319 | |
320 static void * | |
1989
1bd99632fc4d
wavpack: set_params()
William Pitcock <nenolod@atheme.org>
parents:
1978
diff
changeset
|
321 DecodeThread(InputPlayback *playback) |
109 | 322 { |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
323 gint bps; |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
324 WavpackDecoder d(&wvpack); |
109 | 325 |
1989
1bd99632fc4d
wavpack: set_params()
William Pitcock <nenolod@atheme.org>
parents:
1978
diff
changeset
|
326 if (!d.attach_to_play(playback)) { |
109 | 327 killDecodeThread = true; |
328 return end_thread(); | |
329 } | |
330 bps = WavpackGetBytesPerSample(d.ctx) * d.num_channels; | |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
331 |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
332 AUDDBG("reading WavPack file, %dHz, %d channels and %dbits\n", d.sample_rate, d.num_channels, d.bits_per_sample); |
109 | 333 |
2711
183bd24000c9
Use InputPlayback structure properly.
Matti Hamalainen <ccr@tnsp.org>
parents:
2709
diff
changeset
|
334 if (!d.open_audio(playback)) { |
2233 | 335 AUDDBG("error opening audio channel\n"); |
109 | 336 killDecodeThread = true; |
337 AudioError = true; | |
338 openedAudio = false; | |
339 } | |
340 else { | |
2233 | 341 AUDDBG("opened audio channel\n"); |
109 | 342 openedAudio = true; |
343 } | |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
344 guint32 status; |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
345 guint samples_left; |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
346 |
109 | 347 while (!killDecodeThread) { |
348 if (isSeek != -1) { | |
2233 | 349 AUDDBG("seeking to position %d\n", isSeek); |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
350 WavpackSeekSample(d.ctx, (gint)(isSeek * d.sample_rate)); |
109 | 351 isSeek = -1; |
352 } | |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
353 |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
354 samples_left = d.num_samples-WavpackGetSampleIndex(d.ctx); |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
355 //AUDDBG("samples left: %d\n", samples_left); |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
356 if (paused == 0) { |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
357 status = WavpackUnpackSamples(d.ctx, d.input, BUFFER_SIZE); |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
358 if (status == (guint32) -1) { |
109 | 359 printf("wavpack: Error decoding file.\n"); |
360 break; | |
361 } | |
2711
183bd24000c9
Use InputPlayback structure properly.
Matti Hamalainen <ccr@tnsp.org>
parents:
2709
diff
changeset
|
362 else if (samples_left == 0 && playback->output->buffer_playing() == 0) { |
109 | 363 killDecodeThread = true; |
364 break; | |
365 } | |
366 else { | |
1998
8f3188746b64
chase last changeset in aud
William Pitcock <nenolod@atheme.org>
parents:
1989
diff
changeset
|
367 d.process_buffer(playback, status); |
109 | 368 } |
369 } | |
370 else { | |
1676
aee4ebea943a
xmms_usleep() was removed, use g_usleep()
Matti Hamalainen <ccr@tnsp.org>
parents:
1620
diff
changeset
|
371 g_usleep(10000); |
109 | 372 } |
373 } | |
374 return end_thread(); | |
375 } | |
376 | |
377 static void | |
566 | 378 wv_play(InputPlayback *data) |
109 | 379 { |
380 paused = 0; | |
381 isSeek = -1; | |
382 killDecodeThread = false; | |
383 AudioError = false; | |
1354
b670d1f3c2e4
wavpack: new threading model
William Pitcock <nenolod@atheme-project.org>
parents:
1185
diff
changeset
|
384 thread_handle = g_thread_self(); |
1447
195b5657303e
updated input plugins to use set_pb_ready to signal to the core that they're ready for playback
Giacomo Lozito <james@develia.org>
parents:
1445
diff
changeset
|
385 data->set_pb_ready(data); |
1989
1bd99632fc4d
wavpack: set_params()
William Pitcock <nenolod@atheme.org>
parents:
1978
diff
changeset
|
386 DecodeThread(data); |
109 | 387 return; |
388 } | |
389 | |
1436
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
390 static std::string |
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
391 WavpackPluginGetQualityString(WavpackContext *ctx) |
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
392 { |
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
393 int mode = WavpackGetMode(ctx); |
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
394 |
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
395 if (mode & MODE_LOSSLESS) |
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
396 return "lossless"; |
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
397 |
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
398 if (mode & MODE_HYBRID) |
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
399 return "lossy (hybrid)"; |
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
400 |
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
401 return "lossy"; |
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
402 } |
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
403 |
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
404 static Tuple * |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
405 aud_tuple_from_WavpackContext(const gchar *fn, WavpackContext *ctx) |
114 | 406 { |
407 ape_tag tag; | |
1436
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
408 Tuple *ti; |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
409 gint sample_rate = WavpackGetSampleRate(ctx); |
114 | 410 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1699
diff
changeset
|
411 ti = aud_tuple_new_from_filename(fn); |
114 | 412 |
413 load_tag(&tag, ctx); | |
414 | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1699
diff
changeset
|
415 aud_tuple_associate_string(ti, FIELD_TITLE, NULL, tag.title); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1699
diff
changeset
|
416 aud_tuple_associate_string(ti, FIELD_ARTIST, NULL, tag.artist); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1699
diff
changeset
|
417 aud_tuple_associate_string(ti, FIELD_ALBUM, NULL, tag.album); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1699
diff
changeset
|
418 aud_tuple_associate_string(ti, FIELD_GENRE, NULL, tag.genre); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1699
diff
changeset
|
419 aud_tuple_associate_string(ti, FIELD_COMMENT, NULL, tag.comment); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1699
diff
changeset
|
420 aud_tuple_associate_string(ti, FIELD_DATE, NULL, tag.year); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1699
diff
changeset
|
421 aud_tuple_associate_string(ti, FIELD_QUALITY, NULL, WavpackPluginGetQualityString(ctx).c_str()); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1699
diff
changeset
|
422 aud_tuple_associate_string(ti, FIELD_CODEC, NULL, "WavPack"); |
1436
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
423 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1699
diff
changeset
|
424 aud_tuple_associate_int(ti, FIELD_TRACK_NUMBER, NULL, atoi(tag.track)); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1699
diff
changeset
|
425 aud_tuple_associate_int(ti, FIELD_YEAR, NULL, atoi(tag.year)); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1699
diff
changeset
|
426 aud_tuple_associate_int(ti, FIELD_LENGTH, NULL, (int)(WavpackGetNumSamples(ctx) / sample_rate) * 1000); |
114 | 427 |
428 return ti; | |
429 } | |
430 | |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
431 static gchar * |
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
432 generate_title(const gchar *fn, WavpackContext *ctx) |
109 | 433 { |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
434 static gchar *displaytitle = NULL; |
1436
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
435 Tuple *ti; |
109 | 436 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1699
diff
changeset
|
437 ti = aud_tuple_from_WavpackContext(fn, ctx); |
109 | 438 |
2059
70b1f1fc4804
use aud_cfg in some places
William Pitcock <nenolod@atheme.org>
parents:
2001
diff
changeset
|
439 displaytitle = aud_tuple_formatter_make_title_string(ti, aud_get_gentitle_format()); |
115
2e77e3fdd3c1
[svn] - make sure the tuple data is copied, not referenced (oops)
nenolod
parents:
114
diff
changeset
|
440 if (!displaytitle || *displaytitle == '\0') |
2e77e3fdd3c1
[svn] - make sure the tuple data is copied, not referenced (oops)
nenolod
parents:
114
diff
changeset
|
441 displaytitle = g_strdup(fn); |
114 | 442 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1699
diff
changeset
|
443 aud_tuple_free((void *) ti); |
109 | 444 |
445 return displaytitle; | |
446 } | |
447 | |
1436
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
448 static Tuple * |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
449 wv_get_song_tuple(gchar *filename) |
114 | 450 { |
1436
0ff7d08693f6
wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
451 Tuple *ti; |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
452 WavpackDecoder d(&wvpack); |
114 | 453 |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
454 if (!d.attach(filename)) { |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
455 printf("wavpack: Error opening file: \"%s\"\n", filename); |
114 | 456 return NULL; |
457 } | |
458 | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1699
diff
changeset
|
459 ti = aud_tuple_from_WavpackContext(filename, d.ctx); |
114 | 460 |
461 return ti; | |
462 } | |
463 | |
1526
56b0d46a02f6
wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents:
1521
diff
changeset
|
464 static Tuple * |
56b0d46a02f6
wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents:
1521
diff
changeset
|
465 wv_probe_for_tuple(gchar *filename, VFSFile *file) |
56b0d46a02f6
wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents:
1521
diff
changeset
|
466 { |
56b0d46a02f6
wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents:
1521
diff
changeset
|
467 Tuple *ti; |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
468 WavpackDecoder d(&wvpack); |
1526
56b0d46a02f6
wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents:
1521
diff
changeset
|
469 |
56b0d46a02f6
wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents:
1521
diff
changeset
|
470 if (!d.attach(filename, file)) |
56b0d46a02f6
wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents:
1521
diff
changeset
|
471 return NULL; |
56b0d46a02f6
wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents:
1521
diff
changeset
|
472 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1699
diff
changeset
|
473 ti = aud_tuple_from_WavpackContext(filename, d.ctx); |
1526
56b0d46a02f6
wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents:
1521
diff
changeset
|
474 |
56b0d46a02f6
wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents:
1521
diff
changeset
|
475 return ti; |
56b0d46a02f6
wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents:
1521
diff
changeset
|
476 } |
56b0d46a02f6
wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents:
1521
diff
changeset
|
477 |
109 | 478 static void |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
479 wv_get_song_info(gchar *filename, gchar **title, gint *length) |
109 | 480 { |
481 assert(filename != NULL); | |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
482 WavpackDecoder d(&wvpack); |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
483 |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
484 if (!d.attach(filename)) { |
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
485 printf("wavpack: Error opening file: \"%s\"\n", filename); |
109 | 486 return; |
487 } | |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
488 |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
489 gint sample_rate = WavpackGetSampleRate(d.ctx); |
2233 | 490 #ifdef AUD_DEBUG |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
491 gint num_channels = WavpackGetNumChannels(d.ctx); |
2233 | 492 #endif |
493 AUDDBG("reading %s at %d rate with %d channels\n", filename, sample_rate, num_channels); | |
109 | 494 |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
495 *length = (gint)(WavpackGetNumSamples(d.ctx) / sample_rate) * 1000, |
233
7b7660c9f31c
[svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents:
130
diff
changeset
|
496 *title = generate_title(filename, d.ctx); |
2233 | 497 AUDDBG("title for %s = %s\n", filename, *title); |
109 | 498 } |
499 | |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
500 static gint |
566 | 501 wv_get_time(InputPlayback *data) |
109 | 502 { |
566 | 503 if (data->output == NULL) |
109 | 504 return -1; |
505 if (AudioError) | |
506 return -2; | |
566 | 507 if (killDecodeThread && !data->output->buffer_playing()) |
109 | 508 return -1; |
566 | 509 return data->output->output_time(); |
109 | 510 } |
511 | |
512 static void | |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
513 wv_seek(InputPlayback *data, gint sec) |
109 | 514 { |
566 | 515 isSeek = sec; |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
516 data->output->flush((gint) (1000 * isSeek)); |
109 | 517 } |
518 | |
519 static void | |
2430
99864aafd655
fix cutoff in wavpack plugin. (Bugzilla #194)
Michal Lipski <tallica@o2.pl>
parents:
2429
diff
changeset
|
520 wv_pause(InputPlayback *data, gshort pause) |
566 | 521 { |
522 data->output->pause(paused = pause); | |
523 } | |
524 | |
525 static void | |
526 wv_stop(InputPlayback *data) | |
109 | 527 { |
528 killDecodeThread = true; | |
529 if (thread_handle != 0) { | |
530 g_thread_join(thread_handle); | |
531 if (openedAudio) { | |
2711
183bd24000c9
Use InputPlayback structure properly.
Matti Hamalainen <ccr@tnsp.org>
parents:
2709
diff
changeset
|
532 data->output->buffer_free(); |
183bd24000c9
Use InputPlayback structure properly.
Matti Hamalainen <ccr@tnsp.org>
parents:
2709
diff
changeset
|
533 data->output->close_audio(); |
109 | 534 } |
535 openedAudio = false; | |
536 if (AudioError) | |
537 printf("Could not open Audio\n"); | |
538 } | |
539 | |
540 } | |
541 | |
542 static void | |
543 wv_load_config() | |
544 { | |
2523
769e17da93dd
Replaced s/ConfigDb/mcs_handle_t/g, as per changes in the core.
Matti Hamalainen <ccr@tnsp.org>
parents:
2499
diff
changeset
|
545 mcs_handle_t *cfg; |
109 | 546 |
2124 | 547 cfg = aud_cfg_db_open(); |
109 | 548 |
2124 | 549 aud_cfg_db_get_bool(cfg, "wavpack", "clip_prevention", |
109 | 550 &clipPreventionEnabled); |
2124 | 551 aud_cfg_db_get_bool(cfg, "wavpack", "album_replaygain", |
109 | 552 &albumReplaygainEnabled); |
2124 | 553 aud_cfg_db_get_bool(cfg, "wavpack", "dyn_bitrate", &dynBitrateEnabled); |
554 aud_cfg_db_get_bool(cfg, "wavpack", "replaygain", &replaygainEnabled); | |
555 aud_cfg_db_close(cfg); | |
109 | 556 |
557 openedAudio = false; | |
558 } |