summaryrefslogtreecommitdiff
path: root/apps/plugins/wav2wv.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/wav2wv.c')
-rw-r--r--apps/plugins/wav2wv.c38
1 files changed, 16 insertions, 22 deletions
diff --git a/apps/plugins/wav2wv.c b/apps/plugins/wav2wv.c
index f3e191d30d..45f99f7071 100644
--- a/apps/plugins/wav2wv.c
+++ b/apps/plugins/wav2wv.c
@@ -27,7 +27,7 @@ PLUGIN_HEADER
27 27
28#define SAMPLES_PER_BLOCK 22050 28#define SAMPLES_PER_BLOCK 22050
29 29
30static struct plugin_api* rb; 30static const struct plugin_api* rb;
31 31
32void *memset(void *s, int c, size_t n) { 32void *memset(void *s, int c, size_t n) {
33 return(rb->memset(s,c,n)); 33 return(rb->memset(s,c,n));
@@ -102,34 +102,35 @@ static void wvupdate (int32_t start_tick,
102 102
103static int32_t temp_buffer [TEMP_SAMPLES] IDATA_ATTR; 103static int32_t temp_buffer [TEMP_SAMPLES] IDATA_ATTR;
104 104
105static int wav2wv (char *filename) 105static int wav2wv(const char *infile)
106{ 106{
107 int in_fd, out_fd, num_chans, error = false, last_buttons; 107 int in_fd, out_fd, num_chans, error = false, last_buttons;
108 unsigned int32_t total_bytes_read = 0, total_bytes_written = 0; 108 unsigned int32_t total_bytes_read = 0, total_bytes_written = 0;
109 unsigned int32_t total_samples, samples_remaining; 109 unsigned int32_t total_samples, samples_remaining;
110 int32_t *input_buffer = (int32_t *) audiobuf; 110 int32_t *input_buffer = (int32_t *) audiobuf;
111 unsigned char *output_buffer = (unsigned char *)(audiobuf + 0x100000); 111 unsigned char *output_buffer = (unsigned char *)(audiobuf + 0x100000);
112 char *extension, save_a; 112 char outfile[MAX_PATH];
113 const char *inextension;
114 char *outextension;
113 WavpackConfig config; 115 WavpackConfig config;
114 WavpackContext *wpc; 116 WavpackContext *wpc;
115 int32_t start_tick; 117 int32_t start_tick;
116 118
117 rb->lcd_clear_display(); 119 rb->lcd_clear_display();
118 rb->lcd_puts_scroll(0, 0, (unsigned char *)filename); 120 rb->lcd_puts_scroll(0, 0, (unsigned char *)infile);
119#ifdef HAVE_LCD_BITMAP 121#ifdef HAVE_LCD_BITMAP
120 rb->lcd_update(); 122 rb->lcd_update();
121#endif 123#endif
122 124
123 last_buttons = rb->button_status (); 125 last_buttons = rb->button_status ();
124 start_tick = *rb->current_tick; 126 start_tick = *rb->current_tick;
125 extension = filename + rb->strlen (filename) - 3; 127 inextension = infile + rb->strlen(infile) - 3;
126 128 if (rb->strcasecmp (inextension, "wav")) {
127 if (rb->strcasecmp (extension, "wav")) {
128 rb->splash(HZ*2, "only for wav files!"); 129 rb->splash(HZ*2, "only for wav files!");
129 return 1; 130 return 1;
130 } 131 }
131 132
132 in_fd = rb->open(filename, O_RDONLY); 133 in_fd = rb->open(infile, O_RDONLY);
133 134
134 if (in_fd < 0) { 135 if (in_fd < 0) {
135 rb->splash(HZ*2, "could not open file!"); 136 rb->splash(HZ*2, "could not open file!");
@@ -171,14 +172,12 @@ static int wav2wv (char *filename)
171 } 172 }
172 173
173 WavpackAddWrapper (wpc, &raw_header, sizeof (raw_header)); 174 WavpackAddWrapper (wpc, &raw_header, sizeof (raw_header));
174 save_a = extension [1];
175 extension [1] = extension [2];
176 extension [2] = 0;
177
178 out_fd = rb->creat (filename);
179 175
180 extension [2] = extension [1]; 176 rb->strcpy(outfile, infile);
181 extension [1] = save_a; 177 outextension = outfile + rb->strlen(outfile) - 3;
178 outextension[1] = outextension[2];
179 outextension[2] = 0;
180 out_fd = rb->creat(outfile);
182 181
183 if (out_fd < 0) { 182 if (out_fd < 0) {
184 rb->splash(HZ*2, "could not create file!"); 183 rb->splash(HZ*2, "could not create file!");
@@ -278,12 +277,7 @@ static int wav2wv (char *filename)
278 rb->close (in_fd); 277 rb->close (in_fd);
279 278
280 if (error) { 279 if (error) {
281 save_a = extension [1]; 280 rb->remove (outfile);
282 extension [1] = extension [2];
283 extension [2] = 0;
284 rb->remove (filename);
285 extension [2] = extension [1];
286 extension [1] = save_a;
287 } 281 }
288 else 282 else
289 rb->splash(HZ*3, "operation successful"); 283 rb->splash(HZ*3, "operation successful");
@@ -291,7 +285,7 @@ static int wav2wv (char *filename)
291 return error; 285 return error;
292} 286}
293 287
294enum plugin_status plugin_start(struct plugin_api* api, void *parameter) 288enum plugin_status plugin_start(const struct plugin_api* api, const void *parameter)
295{ 289{
296#ifdef RB_PROFILE 290#ifdef RB_PROFILE
297 /* This doesn't start profiling or anything, it just gives the 291 /* This doesn't start profiling or anything, it just gives the