annotate src/wavpack/libwavpack.cxx @ 109:38ce41606f10 trunk

[svn] - wavpack input plugin -- under construction
author nenolod
date Tue, 24 Oct 2006 19:03:53 -0700
parents
children 5745352e0c88
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
1 #include <assert.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
2 #include <string.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
3 #include <stdio.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
4 #include <stdlib.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
5 #include <unistd.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
6 #include <wavpack/wputils.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
7 extern "C" {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
8 #include <audacious/plugin.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
9 #include <audacious/configdb.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
10 #include <audacious/titlestring.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
11 #include <audacious/util.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
12 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
13 #include <glib.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
14 #include <gtk/gtk.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
15 #include <iconv.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
16 #include <math.h>
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
17 #include "equalizer.h"
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
18 #include "tags.h"
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
19 #ifndef M_LN10
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
20 #define M_LN10 2.3025850929940456840179914546843642
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
21 #endif
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
22
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
23 #define DBG(format, args...) fprintf(stderr, format, ## args)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
24 #define BUFFER_SIZE 256 // read buffer size, in samples
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
25
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
26 extern "C" InputPlugin * get_iplugin_info(void);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
27 static void wv_load_config();
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
28 static int wv_is_our_file(char *);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
29 static void wv_play(char *);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
30 static void wv_stop(void);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
31 static void wv_pause(short);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
32 static void wv_seek(int);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
33 static int wv_get_time(void);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
34 static void wv_get_song_info(char *, char **, int *);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
35 static char *generate_title(const char *, WavpackContext *ctx);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
36 static double isSeek;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
37 static short paused;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
38 static bool killDecodeThread;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
39 static bool AudioError;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
40 static GThread *thread_handle;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
41 static gboolean EQ_on;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
42
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
43 // in ui.cpp
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
44 void wv_configure();
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
45 void wv_about_box(void);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
46 void wv_file_info_box(char *);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
47 extern gboolean clipPreventionEnabled;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
48 extern gboolean dynBitrateEnabled;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
49 extern gboolean replaygainEnabled;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
50 extern gboolean albumReplaygainEnabled;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
51 extern gboolean openedAudio;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
52
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
53 InputPlugin mod = {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
54 NULL, //handle
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
55 NULL, //filename
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
56 NULL,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
57 wv_load_config,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
58 wv_about_box,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
59 wv_configure,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
60 wv_is_our_file,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
61 NULL, //no use
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
62 wv_play,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
63 wv_stop,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
64 wv_pause,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
65 wv_seek,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
66 NULL, //set eq
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
67 wv_get_time,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
68 NULL, //get volume
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
69 NULL, //set volume
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
70 NULL, //cleanup
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
71 NULL, //obsolete
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
72 NULL, //add_vis
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
73 NULL,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
74 NULL,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
75 wv_get_song_info,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
76 wv_file_info_box, //info box
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
77 NULL, //output
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
78 };
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
79
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
80 class WavpackDecoder
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
81 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
82 public:
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
83 InputPlugin *mod;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
84 int32_t *input;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
85 int16_t *output;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
86 int sample_rate;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
87 int num_channels;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
88 WavpackContext *ctx;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
89 char error_buff[4096]; // TODO: fixme!
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
90
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
91 WavpackDecoder(InputPlugin *mod) : mod(mod)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
92 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
93 ctx = NULL;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
94 input = NULL;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
95 output = NULL;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
96 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
97
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
98 ~WavpackDecoder()
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
99 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
100 if (input != NULL) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
101 free(input);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
102 input = NULL;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
103 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
104 if (output != NULL) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
105 free(output);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
106 output = NULL;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
107 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
108 if (ctx != NULL) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
109 WavpackCloseFile(ctx);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
110 ctx = NULL;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
111 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
112 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
113
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
114 bool attach(const char *filename)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
115 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
116 ctx = WavpackOpenFileInput(filename, error_buff, OPEN_TAGS | OPEN_WVC, 0);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
117
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
118 if (ctx == NULL) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
119 return false;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
120 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
121
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
122 sample_rate = WavpackGetSampleRate(ctx);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
123 num_channels = WavpackGetNumChannels(ctx);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
124 input = (int32_t *)calloc(BUFFER_SIZE, num_channels * sizeof(int32_t));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
125 output = (int16_t *)calloc(BUFFER_SIZE, num_channels * sizeof(int16_t));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
126 mod->set_info(generate_title(filename, ctx),
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
127 (int) (WavpackGetNumSamples(ctx) / sample_rate) * 1000,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
128 (int) WavpackGetAverageBitrate(ctx, num_channels),
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
129 (int) sample_rate, num_channels);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
130 return true;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
131 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
132
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
133 bool open_audio()
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
134 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
135 return mod->output->open_audio(FMT_S16_LE, sample_rate, num_channels);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
136 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
137
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
138 void process_buffer(size_t num_samples)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
139 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
140 for (int i = 0; i < num_samples * num_channels; i++) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
141 output[i] = input[i];
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
142 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
143 produce_audio(mod->output->get_output_time(), FMT_S16_LE,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
144 sample_rate, num_channels, output,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
145 num_samples * num_channels * sizeof(int16_t));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
146 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
147 };
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
148
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
149 extern "C" InputPlugin *
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
150 get_iplugin_info(void)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
151 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
152 mod.description =
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
153 g_strdup_printf(("Wavpack Decoder Plugin %s"), VERSION);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
154 return &mod;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
155 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
156
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
157 static int
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
158 wv_is_our_file(char *filename)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
159 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
160 char *ext;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
161
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
162 ext = strrchr(filename, '.');
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
163 if (ext) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
164 if (!strcasecmp(ext, ".wv")) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
165 return TRUE;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
166 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
167 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
168 return FALSE;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
169 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
170
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
171 void
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
172 load_tag(ape_tag *tag, WavpackContext *ctx)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
173 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
174 memset(tag, 0, sizeof(ape_tag));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
175 WavpackGetTagItem(ctx, "Album", tag->album, sizeof(tag->album));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
176 WavpackGetTagItem(ctx, "Artist", tag->artist, sizeof(tag->artist));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
177 WavpackGetTagItem(ctx, "Comment", tag->comment, sizeof(tag->comment));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
178 WavpackGetTagItem(ctx, "Genre", tag->genre, sizeof(tag->genre));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
179 WavpackGetTagItem(ctx, "Title", tag->title, sizeof(tag->title));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
180 WavpackGetTagItem(ctx, "Track", tag->track, sizeof(tag->track));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
181 WavpackGetTagItem(ctx, "Year", tag->year, sizeof(tag->year));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
182 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
183
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
184 static char *
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
185 convertUTF8toLocale(char *utf8)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
186 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
187 // note - opens a new iconv descriptor for each call
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
188 // will have to find a way to reuse the descriptor if this turns
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
189 // out to be too slow
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
190 iconv_t idesc = iconv_open("", "UTF-8");
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
191 if (idesc == (iconv_t) -1) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
192 perror("iconv_open failed");
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
193 return g_strdup(utf8);
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 size_t in_left = strlen(utf8);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
197 size_t out_left = 2 * in_left + 1;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
198 char *buf = (char *)g_malloc(out_left);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
199 char *in = utf8;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
200 char *out = buf;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
201
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
202 memset(buf, 0, out_left);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
203 size_t err = iconv(idesc, &in, &in_left, &out, &out_left);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
204 iconv_close(idesc);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
205 return buf;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
206 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
207
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
208 static void *
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
209 end_thread()
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
210 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
211 return 0;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
212 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
213
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
214 static void *
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
215 DecodeThread(void *a)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
216 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
217 ape_tag tag;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
218 char *filename = (char *) a;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
219 int bps_updateCounter = 0;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
220 int bps;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
221 int i;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
222 WavpackDecoder d(&mod);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
223
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
224 if (!d.attach(filename)) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
225 printf("wavpack: Error opening file: \"%s\"\n", filename);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
226 killDecodeThread = true;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
227 return end_thread();
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
228 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
229 bps = WavpackGetBytesPerSample(d.ctx) * d.num_channels;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
230 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
231
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
232 if (!d.open_audio()) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
233 DBG("error opening xmms audio channel\n");
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
234 killDecodeThread = true;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
235 AudioError = true;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
236 openedAudio = false;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
237 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
238 else {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
239 DBG("opened xmms audio channel\n");
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
240 openedAudio = true;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
241 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
242 unsigned status;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
243 char *display = generate_title(filename, d.ctx);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
244 int length = (int) (1000 * WavpackGetNumSamples(d.ctx));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
245
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
246 while (!killDecodeThread) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
247 if (isSeek != -1) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
248 DBG("seeking to position %d\n", isSeek);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
249 WavpackSeekSample(d.ctx, isSeek * d.sample_rate);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
250 isSeek = -1;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
251 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
252 if (paused == 0
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
253 && (mod.output->buffer_free() >=
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
254 (1152 * 2 *
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
255 (16 / 8)) << (mod.output->buffer_playing()? 1 : 0))) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
256 status =
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
257 WavpackUnpackSamples(d.ctx, d.input, BUFFER_SIZE);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
258 if (status == (unsigned) (-1)) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
259 printf("wavpack: Error decoding file.\n");
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
260 break;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
261 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
262 else if (status == 0) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
263 killDecodeThread = true;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
264 break;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
265 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
266 else {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
267 d.process_buffer(status);
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 else {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
271 xmms_usleep(10000);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
272 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
273 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
274 return end_thread();
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
275 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
276
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
277 static void
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
278 wv_play(char *filename)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
279 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
280 paused = 0;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
281 isSeek = -1;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
282 killDecodeThread = false;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
283 AudioError = false;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
284 thread_handle = g_thread_create(DecodeThread, (void *) filename, TRUE, NULL);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
285 return;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
286 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
287
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
288 static char *
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
289 generate_title(const char *fn, WavpackContext *ctx)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
290 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
291 static char *displaytitle = NULL;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
292 ape_tag tag;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
293 TitleInput *ti;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
294
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
295 ti = (TitleInput *) g_malloc0(sizeof(TitleInput));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
296 ti->__size = XMMS_TITLEINPUT_SIZE;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
297 ti->__version = XMMS_TITLEINPUT_VERSION;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
298
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
299 ti->file_name = g_strdup(g_basename(fn));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
300 ti->file_ext = "wv";
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
301
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
302 load_tag(&tag, ctx);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
303
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
304 // xmms doesn't support unicode...
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
305 ti->track_name = convertUTF8toLocale(tag.title);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
306 ti->performer = convertUTF8toLocale(tag.artist);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
307 ti->album_name = convertUTF8toLocale(tag.album);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
308 ti->date = convertUTF8toLocale(tag.year);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
309 ti->track_number = atoi(tag.track);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
310 if (ti->track_number < 0)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
311 ti->track_number = 0;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
312 ti->year = atoi(tag.year);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
313 if (ti->year < 0)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
314 ti->year = 0;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
315 ti->genre = convertUTF8toLocale(tag.genre);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
316 ti->comment = convertUTF8toLocale(tag.comment);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
317
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
318 displaytitle = xmms_get_titlestring(xmms_get_gentitle_format(), ti);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
319 if (!displaytitle || *displaytitle == '\0'
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
320 || (strlen(tag.title) == 0 && strlen(tag.artist) == 0))
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
321 displaytitle = ti->file_name;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
322 g_free(ti->track_name);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
323 g_free(ti->performer);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
324 g_free(ti->album_name);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
325 g_free(ti->genre);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
326 g_free(ti->comment);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
327 g_free(ti);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
328
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
329 return displaytitle;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
330 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
331
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
332 static void
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
333 wv_get_song_info(char *filename, char **title, int *length)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
334 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
335 assert(filename != NULL);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
336 char error_buff[4096]; // TODO: fixme!
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
337 WavpackContext *ctx = WavpackOpenFileInput(filename, error_buff, OPEN_TAGS | OPEN_WVC, 0);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
338 if (ctx == NULL) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
339 printf("wavpack: Error opening file: \"%s: %s\"\n", filename, error_buff);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
340 return;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
341 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
342 int sample_rate = WavpackGetSampleRate(ctx);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
343 int num_channels = WavpackGetNumChannels(ctx);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
344 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
345
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
346 *length = (int)(WavpackGetNumSamples(ctx) / sample_rate) * 1000,
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
347 *title = generate_title(filename, ctx);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
348 DBG("title for %s = %s\n", filename, *title);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
349 WavpackCloseFile(ctx);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
350 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
351
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
352 static int
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
353 wv_get_time(void)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
354 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
355 if (!mod.output)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
356 return -1;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
357 if (AudioError)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
358 return -2;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
359 if (killDecodeThread && !mod.output->buffer_playing())
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
360 return -1;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
361 return mod.output->output_time();
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
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
365 static void
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
366 wv_seek(int sec)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
367 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
368 isSeek = sec;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
369 mod.output->flush((int) (1000 * isSeek));
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
370 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
371
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
372 static void
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
373 wv_pause(short pause)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
374 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
375 mod.output->pause(paused = pause);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
376 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
377
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
378 static void
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
379 wv_stop(void)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
380 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
381 killDecodeThread = true;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
382 if (thread_handle != 0) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
383 g_thread_join(thread_handle);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
384 if (openedAudio) {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
385 mod.output->buffer_free();
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
386 mod.output->close_audio();
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
387 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
388 openedAudio = false;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
389 if (AudioError)
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
390 printf("Could not open Audio\n");
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
391 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
392
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
393 }
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
394
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
395 static void
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
396 wv_load_config()
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
397 {
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
398 ConfigDb *cfg;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
399
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
400 cfg = bmp_cfg_db_open();
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
401
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
402 bmp_cfg_db_get_bool(cfg, "wavpack", "clip_prevention",
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
403 &clipPreventionEnabled);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
404 bmp_cfg_db_get_bool(cfg, "wavpack", "album_replaygain",
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
405 &albumReplaygainEnabled);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
406 bmp_cfg_db_get_bool(cfg, "wavpack", "dyn_bitrate", &dynBitrateEnabled);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
407 bmp_cfg_db_get_bool(cfg, "wavpack", "replaygain", &replaygainEnabled);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
408 bmp_cfg_db_close(cfg);
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
409
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
410 openedAudio = false;
38ce41606f10 [svn] - wavpack input plugin -- under construction
nenolod
parents:
diff changeset
411 }