annotate src/wavpack/libwavpack.cxx @ 2642:c2603047a1a3

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