annotate src/wavpack/libwavpack.cxx @ 2059:70b1f1fc4804

use aud_cfg in some places
author William Pitcock <nenolod@atheme.org>
date Sat, 13 Oct 2007 23:48:00 -0500
parents aa8bd7b56cda
children b8da6a0b0da2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1436
0ff7d08693f6 wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
1 #include <string>
0ff7d08693f6 wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
2
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
3 #include <assert.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
4 #include <string.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
5 #include <stdio.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
6 #include <stdlib.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
7 #include <unistd.h>
291
93c0da3f7a86 [svn] - make wavpack/wavpack.h include forced extern "C".
nenolod
parents: 284
diff changeset
8 extern "C" {
284
72f0de06bb56 [svn] - wavpack/wputils.h is deprecated, wavpack/wavpack.h should be used instead.
nenolod
parents: 264
diff changeset
9 #include <wavpack/wavpack.h>
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
10 #include <audacious/plugin.h>
111
5745352e0c88 [svn] - hey, this compiles now. neat :P
nenolod
parents: 109
diff changeset
11 #include <audacious/output.h>
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
12 #include <audacious/configdb.h>
1436
0ff7d08693f6 wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
13 #include <audacious/main.h>
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
14 #include <audacious/util.h>
233
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
15 #include <audacious/vfs.h>
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
16 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
17 #include <glib.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
18 #include <gtk/gtk.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
19 #include <iconv.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
20 #include <math.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
21 #include "tags.h"
434
7385182ae4b8 [svn] - add missing config.h inclusion for wavpack, null and metronom plugin
giacomo
parents: 372
diff changeset
22 #include "../../config.h"
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
23 #ifndef M_LN10
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
24 #define M_LN10 2.3025850929940456840179914546843642
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
25 #endif
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
26
112
5755fb99ddab [svn] - make debugging notices optional
nenolod
parents: 111
diff changeset
27 #ifdef DEBUG
5755fb99ddab [svn] - make debugging notices optional
nenolod
parents: 111
diff changeset
28 # define DBG(format, args...) fprintf(stderr, format, ## args)
5755fb99ddab [svn] - make debugging notices optional
nenolod
parents: 111
diff changeset
29 #else
5755fb99ddab [svn] - make debugging notices optional
nenolod
parents: 111
diff changeset
30 # define DBG(format, args...)
5755fb99ddab [svn] - make debugging notices optional
nenolod
parents: 111
diff changeset
31 #endif
5755fb99ddab [svn] - make debugging notices optional
nenolod
parents: 111
diff changeset
32
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
33 #define BUFFER_SIZE 256 // read buffer size, in samples
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
34
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
35 static void wv_load_config();
253
ab24cfe495e0 [svn] Port to NewVFS file probe & add explicit cast to silence warning, thanks to spb.
chainsaw
parents: 247
diff changeset
36 static int 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
37 static Tuple *wv_probe_for_tuple(gchar *filename, VFSFile *file);
566
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
38 static void wv_play(InputPlayback *);
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
39 static void wv_stop(InputPlayback *);
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
40 static void wv_pause(InputPlayback *, short);
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
41 static void wv_seek(InputPlayback *, int);
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
42 static int wv_get_time(InputPlayback *);
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
43 static void wv_get_song_info(char *, char **, int *);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
44 static char *generate_title(const char *, WavpackContext *ctx);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
45 static double isSeek;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
46 static short paused;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
47 static bool killDecodeThread;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
48 static bool AudioError;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
49 static GThread *thread_handle;
1436
0ff7d08693f6 wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
50 static Tuple *wv_get_song_tuple(char *);
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
51
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
52 // in ui.cpp
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
53 void wv_configure();
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
54 void wv_about_box(void);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
55 void wv_file_info_box(char *);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
56 extern gboolean clipPreventionEnabled;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
57 extern gboolean dynBitrateEnabled;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
58 extern gboolean replaygainEnabled;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
59 extern gboolean albumReplaygainEnabled;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
60 extern gboolean openedAudio;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
61
1044
b1128efde471 [svn] - get rid of all warnings gcc 4.2.0 emits with my build configuration.
yaz
parents: 566
diff changeset
62 const gchar *wv_fmts[] = { "wv", NULL };
372
a157306caf03 [svn] - finalize the plugin-side of the extension-assist ABI
nenolod
parents: 368
diff changeset
63
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
64 InputPlugin mod = {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
65 NULL, //handle
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
66 NULL, //filename
1185
6d749f573b3b suppress warnings.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1128
diff changeset
67 (gchar *)"WavPack Audio Plugin",
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
68 wv_load_config,
1620
87a52bc00926 wavpack: I need a rewrite.
William Pitcock <nenolod@atheme.org>
parents: 1526
diff changeset
69 NULL,
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
70 wv_about_box,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
71 wv_configure,
1620
87a52bc00926 wavpack: I need a rewrite.
William Pitcock <nenolod@atheme.org>
parents: 1526
diff changeset
72 FALSE,
332
626f9f4d79a8 [svn] Remove old-style is_our_file() where a new-style is_our_fd() exists
kiyoshi
parents: 291
diff changeset
73 NULL,
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
74 NULL, //no use
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
75 wv_play,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
76 wv_stop,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
77 wv_pause,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
78 wv_seek,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
79 NULL, //set eq
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
80 wv_get_time,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
81 NULL, //get volume
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
82 NULL, //set volume
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
83 NULL, //cleanup
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
84 NULL, //obsolete
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
85 NULL, //add_vis
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
86 NULL,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
87 wv_get_song_info,
263
7e1d5cc9ef1b [svn] - fix wavpack plugin
nenolod
parents: 253
diff changeset
88 wv_file_info_box, //info box
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
89 NULL, //output
114
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
90 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
91 NULL,
ab24cfe495e0 [svn] Port to NewVFS file probe & add explicit cast to silence warning, thanks to spb.
chainsaw
parents: 247
diff changeset
92 NULL,
ab24cfe495e0 [svn] Port to NewVFS file probe & add explicit cast to silence warning, thanks to spb.
chainsaw
parents: 247
diff changeset
93 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
94 (gchar **)wv_fmts,
1526
56b0d46a02f6 wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents: 1521
diff changeset
95 NULL, // high precision seeking
56b0d46a02f6 wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents: 1521
diff changeset
96 wv_probe_for_tuple // probe for a tuple
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
97 };
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
98
233
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
99 int32_t read_bytes (void *id, void *data, int32_t bcount)
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
100 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
101 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
102 }
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
103
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
104 uint32_t get_pos (void *id)
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
105 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
106 return aud_vfs_ftell ((VFSFile *) id);
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
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
109 int set_pos_abs (void *id, uint32_t pos)
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
110 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
111 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
112 }
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
113
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
114 int set_pos_rel (void *id, int32_t delta, int mode)
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
115 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
116 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
117 }
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 int push_back_byte (void *id, int c)
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
120 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
121 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
122 }
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
123
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
124 uint32_t get_length (void *id)
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 VFSFile *file = (VFSFile *) id;
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
127 uint32_t sz = 0;
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 if (file == NULL)
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
130 return 0;
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
131
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
132 aud_vfs_fseek(file, 0, SEEK_END);
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
133 sz = aud_vfs_ftell(file);
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
134 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
135
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
136 return sz;
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
137 }
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
138
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
139 /* XXX streams?? */
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
140 int can_seek (void *id)
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
141 {
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
142 return 1;
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
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
145 int32_t write_bytes (void *id, void *data, int32_t bcount)
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
146 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
147 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
148 }
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
149
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
150 WavpackStreamReader reader = {
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
151 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
152 write_bytes
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
153 };
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
154
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
155 class WavpackDecoder
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
156 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
157 public:
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
158 InputPlugin *mod;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
159 int32_t *input;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
160 int16_t *output;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
161 int sample_rate;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
162 int num_channels;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
163 WavpackContext *ctx;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
164 char error_buff[4096]; // TODO: fixme!
233
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
165 VFSFile *wv_Input, *wvc_Input;
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
166
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
167 WavpackDecoder(InputPlugin *mod) : mod(mod)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
168 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
169 ctx = NULL;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
170 input = NULL;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
171 output = NULL;
1520
2ed7413c199a wavpack fixes
William Pitcock <nenolod@atheme-project.org>
parents: 1501
diff changeset
172 wv_Input = NULL;
2ed7413c199a wavpack fixes
William Pitcock <nenolod@atheme-project.org>
parents: 1501
diff changeset
173 wvc_Input = NULL;
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
174 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
175
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
176 ~WavpackDecoder()
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
177 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
178 if (input != NULL) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
179 free(input);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
180 input = NULL;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
181 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
182 if (output != NULL) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
183 free(output);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
184 output = NULL;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
185 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
186 if (ctx != NULL) {
1520
2ed7413c199a wavpack fixes
William Pitcock <nenolod@atheme-project.org>
parents: 1501
diff changeset
187 if (wv_Input)
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
188 aud_vfs_fclose(wv_Input);
1520
2ed7413c199a wavpack fixes
William Pitcock <nenolod@atheme-project.org>
parents: 1501
diff changeset
189
2ed7413c199a wavpack fixes
William Pitcock <nenolod@atheme-project.org>
parents: 1501
diff changeset
190 if (wvc_Input)
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
191 aud_vfs_fclose(wvc_Input);
233
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
192 g_free(ctx);
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
193 ctx = NULL;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
194 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
195 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
196
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
197 bool attach(const char *filename)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
198 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
199 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
200
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
201 char *corrFilename = g_strconcat(filename, "c", NULL);
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
202
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
203 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
204
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
205 g_free(corrFilename);
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
206
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
207 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
208
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
209 if (ctx == NULL) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
210 return false;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
211 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
212
237
f0117679cd26 [svn] - a slightly better way of doing things here
nenolod
parents: 233
diff changeset
213 return true;
f0117679cd26 [svn] - a slightly better way of doing things here
nenolod
parents: 233
diff changeset
214 }
f0117679cd26 [svn] - a slightly better way of doing things here
nenolod
parents: 233
diff changeset
215
1520
2ed7413c199a wavpack fixes
William Pitcock <nenolod@atheme-project.org>
parents: 1501
diff changeset
216 bool 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
217 {
1520
2ed7413c199a wavpack fixes
William Pitcock <nenolod@atheme-project.org>
parents: 1501
diff changeset
218 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
219
04f8c7624ea3 Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents: 1465
diff changeset
220 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
221 return false;
04f8c7624ea3 Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents: 1465
diff changeset
222
04f8c7624ea3 Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents: 1465
diff changeset
223 return true;
04f8c7624ea3 Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents: 1465
diff changeset
224 }
04f8c7624ea3 Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents: 1465
diff changeset
225
1989
1bd99632fc4d wavpack: set_params()
William Pitcock <nenolod@atheme.org>
parents: 1978
diff changeset
226 bool attach_to_play(InputPlayback *playback)
237
f0117679cd26 [svn] - a slightly better way of doing things here
nenolod
parents: 233
diff changeset
227 {
1989
1bd99632fc4d wavpack: set_params()
William Pitcock <nenolod@atheme.org>
parents: 1978
diff changeset
228 wv_Input = aud_vfs_fopen(playback->filename, "rb");
237
f0117679cd26 [svn] - a slightly better way of doing things here
nenolod
parents: 233
diff changeset
229
1989
1bd99632fc4d wavpack: set_params()
William Pitcock <nenolod@atheme.org>
parents: 1978
diff changeset
230 char *corrFilename = g_strconcat(playback->filename, "c", NULL);
237
f0117679cd26 [svn] - a slightly better way of doing things here
nenolod
parents: 233
diff changeset
231
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
232 wvc_Input = aud_vfs_fopen(corrFilename, "rb");
237
f0117679cd26 [svn] - a slightly better way of doing things here
nenolod
parents: 233
diff changeset
233
f0117679cd26 [svn] - a slightly better way of doing things here
nenolod
parents: 233
diff changeset
234 g_free(corrFilename);
f0117679cd26 [svn] - a slightly better way of doing things here
nenolod
parents: 233
diff changeset
235
f0117679cd26 [svn] - a slightly better way of doing things here
nenolod
parents: 233
diff changeset
236 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
237
1501
04f8c7624ea3 Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents: 1465
diff changeset
238 if (ctx == NULL)
237
f0117679cd26 [svn] - a slightly better way of doing things here
nenolod
parents: 233
diff changeset
239 return false;
f0117679cd26 [svn] - a slightly better way of doing things here
nenolod
parents: 233
diff changeset
240
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
241 sample_rate = WavpackGetSampleRate(ctx);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
242 num_channels = WavpackGetNumChannels(ctx);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
243 input = (int32_t *)calloc(BUFFER_SIZE, num_channels * sizeof(int32_t));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
244 output = (int16_t *)calloc(BUFFER_SIZE, num_channels * sizeof(int16_t));
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),
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
246 (int) (WavpackGetNumSamples(ctx) / sample_rate) * 1000,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
247 (int) WavpackGetAverageBitrate(ctx, num_channels),
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
248 (int) sample_rate, num_channels);
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
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
252 bool open_audio()
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
253 {
112
5755fb99ddab [svn] - make debugging notices optional
nenolod
parents: 111
diff changeset
254 return mod->output->open_audio(FMT_S16_NE, 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
1998
8f3188746b64 chase last changeset in aud
William Pitcock <nenolod@atheme.org>
parents: 1989
diff changeset
257 void process_buffer(InputPlayback *playback, size_t num_samples)
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
258 {
1501
04f8c7624ea3 Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents: 1465
diff changeset
259 /* TODO: dithering */
2001
aa8bd7b56cda make wavpack compile again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1998
diff changeset
260 for (unsigned int i = 0; i < num_samples * num_channels; i++)
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
261 output[i] = input[i];
1501
04f8c7624ea3 Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents: 1465
diff changeset
262
1998
8f3188746b64 chase last changeset in aud
William Pitcock <nenolod@atheme.org>
parents: 1989
diff changeset
263 playback->pass_audio(playback, FMT_S16_NE,
111
5745352e0c88 [svn] - hey, this compiles now. neat :P
nenolod
parents: 109
diff changeset
264 num_channels,
5745352e0c88 [svn] - hey, this compiles now. neat :P
nenolod
parents: 109
diff changeset
265 num_samples * num_channels * sizeof(int16_t),
5745352e0c88 [svn] - hey, this compiles now. neat :P
nenolod
parents: 109
diff changeset
266 output,
5745352e0c88 [svn] - hey, this compiles now. neat :P
nenolod
parents: 109
diff changeset
267 NULL);
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
268 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
269 };
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
270
1080
b51246bc3fb3 [svn] - wavpack: transition to plugin API v2
nenolod
parents: 1044
diff changeset
271 InputPlugin *wv_iplist[] = { &mod, NULL };
b51246bc3fb3 [svn] - wavpack: transition to plugin API v2
nenolod
parents: 1044
diff changeset
272
1395
761e17b23e0c added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents: 1354
diff changeset
273 DECLARE_PLUGIN(wavpack, NULL, NULL, wv_iplist, NULL, NULL, NULL, NULL,NULL);
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
274
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
275 static int
253
ab24cfe495e0 [svn] Port to NewVFS file probe & add explicit cast to silence warning, thanks to spb.
chainsaw
parents: 247
diff changeset
276 wv_is_our_fd(gchar *filename, VFSFile *file)
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
277 {
1501
04f8c7624ea3 Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents: 1465
diff changeset
278 WavpackDecoder d(&mod);
04f8c7624ea3 Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents: 1465
diff changeset
279
04f8c7624ea3 Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
William Pitcock <nenolod@atheme-project.org>
parents: 1465
diff changeset
280 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
281 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
282
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
283 return FALSE;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
284 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
285
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
286 void
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
287 load_tag(ape_tag *tag, WavpackContext *ctx)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
288 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
289 memset(tag, 0, sizeof(ape_tag));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
290 WavpackGetTagItem(ctx, "Album", tag->album, sizeof(tag->album));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
291 WavpackGetTagItem(ctx, "Artist", tag->artist, sizeof(tag->artist));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
292 WavpackGetTagItem(ctx, "Comment", tag->comment, sizeof(tag->comment));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
293 WavpackGetTagItem(ctx, "Genre", tag->genre, sizeof(tag->genre));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
294 WavpackGetTagItem(ctx, "Title", tag->title, sizeof(tag->title));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
295 WavpackGetTagItem(ctx, "Track", tag->track, sizeof(tag->track));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
296 WavpackGetTagItem(ctx, "Year", tag->year, sizeof(tag->year));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
297 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
298
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
299 static void *
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
300 end_thread()
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
301 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
302 return 0;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
303 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
304
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
305 static void *
1989
1bd99632fc4d wavpack: set_params()
William Pitcock <nenolod@atheme.org>
parents: 1978
diff changeset
306 DecodeThread(InputPlayback *playback)
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
307 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
308 ape_tag tag;
1989
1bd99632fc4d wavpack: set_params()
William Pitcock <nenolod@atheme.org>
parents: 1978
diff changeset
309 char *filename = playback->filename;
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
310 int bps_updateCounter = 0;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
311 int bps;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
312 int i;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
313 WavpackDecoder d(&mod);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
314
1989
1bd99632fc4d wavpack: set_params()
William Pitcock <nenolod@atheme.org>
parents: 1978
diff changeset
315 if (!d.attach_to_play(playback)) {
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
316 killDecodeThread = true;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
317 return end_thread();
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
318 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
319 bps = WavpackGetBytesPerSample(d.ctx) * d.num_channels;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
320 DBG("reading %s at %d rate with %d channels\n", filename, d.sample_rate, d.num_channels);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
321
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
322 if (!d.open_audio()) {
1128
ea77e4df4ce4 [svn] - clean up some debugging stuff
nenolod
parents: 1127
diff changeset
323 DBG("error opening audio channel\n");
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
324 killDecodeThread = true;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
325 AudioError = true;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
326 openedAudio = false;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
327 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
328 else {
1128
ea77e4df4ce4 [svn] - clean up some debugging stuff
nenolod
parents: 1127
diff changeset
329 DBG("opened audio channel\n");
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
330 openedAudio = true;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
331 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
332 unsigned status;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
333 char *display = generate_title(filename, d.ctx);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
334 int length = (int) (1000 * WavpackGetNumSamples(d.ctx));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
335
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
336 while (!killDecodeThread) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
337 if (isSeek != -1) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
338 DBG("seeking to position %d\n", isSeek);
253
ab24cfe495e0 [svn] Port to NewVFS file probe & add explicit cast to silence warning, thanks to spb.
chainsaw
parents: 247
diff changeset
339 WavpackSeekSample(d.ctx, (int)(isSeek * d.sample_rate));
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
340 isSeek = -1;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
341 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
342 if (paused == 0
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
343 && (mod.output->buffer_free() >=
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
344 (1152 * 2 *
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
345 (16 / 8)) << (mod.output->buffer_playing()? 1 : 0))) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
346 status =
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
347 WavpackUnpackSamples(d.ctx, d.input, BUFFER_SIZE);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
348 if (status == (unsigned) (-1)) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
349 printf("wavpack: Error decoding file.\n");
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
350 break;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
351 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
352 else if (status == 0) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
353 killDecodeThread = true;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
354 break;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
355 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
356 else {
1998
8f3188746b64 chase last changeset in aud
William Pitcock <nenolod@atheme.org>
parents: 1989
diff changeset
357 d.process_buffer(playback, status);
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
358 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
359 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
360 else {
1676
aee4ebea943a xmms_usleep() was removed, use g_usleep()
Matti Hamalainen <ccr@tnsp.org>
parents: 1620
diff changeset
361 g_usleep(10000);
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
362 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
363 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
364 return end_thread();
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
365 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
366
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
367 static void
566
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
368 wv_play(InputPlayback *data)
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
369 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
370 paused = 0;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
371 isSeek = -1;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
372 killDecodeThread = false;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
373 AudioError = false;
1354
b670d1f3c2e4 wavpack: new threading model
William Pitcock <nenolod@atheme-project.org>
parents: 1185
diff changeset
374 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
375 data->set_pb_ready(data);
1989
1bd99632fc4d wavpack: set_params()
William Pitcock <nenolod@atheme.org>
parents: 1978
diff changeset
376 DecodeThread(data);
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
377 return;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
378 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
379
1436
0ff7d08693f6 wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
380 static std::string
0ff7d08693f6 wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
381 WavpackPluginGetQualityString(WavpackContext *ctx)
0ff7d08693f6 wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
382 {
0ff7d08693f6 wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
383 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
384
0ff7d08693f6 wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
385 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
386 return "lossless";
0ff7d08693f6 wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
387
0ff7d08693f6 wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
388 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
389 return "lossy (hybrid)";
0ff7d08693f6 wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
390
0ff7d08693f6 wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
391 return "lossy";
0ff7d08693f6 wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
392 }
0ff7d08693f6 wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
393
0ff7d08693f6 wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
394 static Tuple *
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1699
diff changeset
395 aud_tuple_from_WavpackContext(const char *fn, WavpackContext *ctx)
114
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
396 {
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
397 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
398 Tuple *ti;
114
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
399 int sample_rate = WavpackGetSampleRate(ctx);
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
400
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1699
diff changeset
401 ti = aud_tuple_new_from_filename(fn);
114
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
402
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
403 load_tag(&tag, ctx);
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
404
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1699
diff changeset
405 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
406 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
407 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
408 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
409 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
410 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
411 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
412 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
413
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1699
diff changeset
414 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
415 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
416 aud_tuple_associate_int(ti, FIELD_LENGTH, NULL, (int)(WavpackGetNumSamples(ctx) / sample_rate) * 1000);
114
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
417
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
418 return ti;
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
419 }
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
420
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
421 static char *
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
422 generate_title(const char *fn, WavpackContext *ctx)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
423 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
424 static char *displaytitle = NULL;
1436
0ff7d08693f6 wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
425 Tuple *ti;
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
426
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1699
diff changeset
427 ti = aud_tuple_from_WavpackContext(fn, ctx);
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
428
2059
70b1f1fc4804 use aud_cfg in some places
William Pitcock <nenolod@atheme.org>
parents: 2001
diff changeset
429 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
430 if (!displaytitle || *displaytitle == '\0')
2e77e3fdd3c1 [svn] - make sure the tuple data is copied, not referenced (oops)
nenolod
parents: 114
diff changeset
431 displaytitle = g_strdup(fn);
114
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
432
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1699
diff changeset
433 aud_tuple_free((void *) ti);
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
434
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
435 return displaytitle;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
436 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
437
1436
0ff7d08693f6 wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
438 static Tuple *
114
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
439 wv_get_song_tuple(char *filename)
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
440 {
1436
0ff7d08693f6 wavpack: update to new tuple API, use std::string more.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
441 Tuple *ti;
233
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
442 WavpackDecoder d(&mod);
114
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
443
233
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
444 if (!d.attach(filename)) {
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
445 printf("wavpack: Error opening file: \"%s\"\n", filename);
114
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
446 return NULL;
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
447 }
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
448
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1699
diff changeset
449 ti = aud_tuple_from_WavpackContext(filename, d.ctx);
114
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
450
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
451 return ti;
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
452 }
9bb02321f986 [svn] - tuple support
nenolod
parents: 112
diff changeset
453
1526
56b0d46a02f6 wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents: 1521
diff changeset
454 static Tuple *
56b0d46a02f6 wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents: 1521
diff changeset
455 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
456 {
56b0d46a02f6 wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents: 1521
diff changeset
457 Tuple *ti;
56b0d46a02f6 wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents: 1521
diff changeset
458 WavpackDecoder d(&mod);
56b0d46a02f6 wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents: 1521
diff changeset
459
56b0d46a02f6 wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents: 1521
diff changeset
460 if (!d.attach(filename, file))
56b0d46a02f6 wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents: 1521
diff changeset
461 return NULL;
56b0d46a02f6 wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents: 1521
diff changeset
462
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1699
diff changeset
463 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
464
56b0d46a02f6 wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents: 1521
diff changeset
465 return ti;
56b0d46a02f6 wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents: 1521
diff changeset
466 }
56b0d46a02f6 wavpack: Implement InputPlugin::probe_for_tuple.
William Pitcock <nenolod@atheme-project.org>
parents: 1521
diff changeset
467
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
468 static void
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
469 wv_get_song_info(char *filename, char **title, int *length)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
470 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
471 assert(filename != NULL);
233
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
472 WavpackDecoder d(&mod);
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
473
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
474 if (!d.attach(filename)) {
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
475 printf("wavpack: Error opening file: \"%s\"\n", filename);
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
476 return;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
477 }
233
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
478
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
479 int sample_rate = WavpackGetSampleRate(d.ctx);
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
480 int num_channels = WavpackGetNumChannels(d.ctx);
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
481 DBG("reading %s at %d rate with %d channels\n", filename, sample_rate, num_channels);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
482
233
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
483 *length = (int)(WavpackGetNumSamples(d.ctx) / sample_rate) * 1000,
7b7660c9f31c [svn] - rewrite to take advantage of already existant object-oriented framework
nenolod
parents: 130
diff changeset
484 *title = generate_title(filename, d.ctx);
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
485 DBG("title for %s = %s\n", filename, *title);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
486 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
487
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
488 static int
566
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
489 wv_get_time(InputPlayback *data)
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
490 {
566
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
491 if (data->output == NULL)
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
492 return -1;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
493 if (AudioError)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
494 return -2;
566
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
495 if (killDecodeThread && !data->output->buffer_playing())
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
496 return -1;
566
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
497 return data->output->output_time();
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
498 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
499
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
500 static void
566
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
501 wv_seek(InputPlayback *data, int sec)
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
502 {
566
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
503 isSeek = sec;
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
504 data->output->flush((int) (1000 * isSeek));
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
505 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
506
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
507 static void
566
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
508 wv_pause(InputPlayback *data, short pause)
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
509 {
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
510 data->output->pause(paused = pause);
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
511 }
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
512
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
513 static void
98c4735c3c2e [svn] - update to new input plugin API
nenolod
parents: 434
diff changeset
514 wv_stop(InputPlayback *data)
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 killDecodeThread = true;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
517 if (thread_handle != 0) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
518 g_thread_join(thread_handle);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
519 if (openedAudio) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
520 mod.output->buffer_free();
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
521 mod.output->close_audio();
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
522 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
523 openedAudio = false;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
524 if (AudioError)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
525 printf("Could not open Audio\n");
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
526 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
527
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
528 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
529
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
530 static void
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
531 wv_load_config()
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
532 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
533 ConfigDb *cfg;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
534
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
535 cfg = bmp_cfg_db_open();
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
536
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
537 bmp_cfg_db_get_bool(cfg, "wavpack", "clip_prevention",
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
538 &clipPreventionEnabled);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
539 bmp_cfg_db_get_bool(cfg, "wavpack", "album_replaygain",
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
540 &albumReplaygainEnabled);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
541 bmp_cfg_db_get_bool(cfg, "wavpack", "dyn_bitrate", &dynBitrateEnabled);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
542 bmp_cfg_db_get_bool(cfg, "wavpack", "replaygain", &replaygainEnabled);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
543 bmp_cfg_db_close(cfg);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
544
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
545 openedAudio = false;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
546 }