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