summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorThom Johansen <thomj@rockbox.org>2007-10-30 10:42:08 +0000
committerThom Johansen <thomj@rockbox.org>2007-10-30 10:42:08 +0000
commit96269486420247142989ce008ec5deb3e4a8f49c (patch)
treebef46ad8ebf3f37ad846cc7e49f0fccbbb944418 /apps/plugins
parentc436657571f668299d1848b4227e01bda7434f7f (diff)
downloadrockbox-96269486420247142989ce008ec5deb3e4a8f49c.tar.gz
rockbox-96269486420247142989ce008ec5deb3e4a8f49c.zip
Fix FS #8019, caused by memcpy() being called before "rb = api;". Be cautious of this one, it'll certainly bite us again. Gut out all the silly file selection stuff, this plugin is already a viewer. Note that mp3_encoder still is buggy and needs more work (or we need a transcoder plugin...).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15372 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/mp3_encoder.c89
1 files changed, 10 insertions, 79 deletions
diff --git a/apps/plugins/mp3_encoder.c b/apps/plugins/mp3_encoder.c
index 453c755f10..4558fdd56b 100644
--- a/apps/plugins/mp3_encoder.c
+++ b/apps/plugins/mp3_encoder.c
@@ -24,8 +24,6 @@ MEM_FUNCTION_WRAPPERS(rb);
24#define SAMPL2 576 24#define SAMPL2 576
25#define SBLIMIT 32 25#define SBLIMIT 32
26#define HTN 16 26#define HTN 16
27#define memcpy rb->memcpy
28#define memset rb->memset
29#define putlong(c, s) if(s+sz <= 32) { cc = (cc << s) | c; sz+= s; } \ 27#define putlong(c, s) if(s+sz <= 32) { cc = (cc << s) | c; sz+= s; } \
30 else { putbits(cc, sz); cc = c; sz = s; } 28 else { putbits(cc, sz); cc = c; sz = s; }
31 29
@@ -2278,43 +2276,8 @@ void compress(void)
2278 2276
2279 2277
2280int num_file; 2278int num_file;
2281char filename[12][80];
2282char mp3_name[80]; 2279char mp3_name[80];
2283 2280
2284void read_wav_files(char *dirname)
2285{
2286 DIR *dir = rb->opendir(dirname);
2287
2288 if(!dir)
2289 return;
2290
2291 while(true)
2292 {
2293 struct dirent *entry;
2294
2295 entry = rb->readdir(dir);
2296 if(!entry)
2297 break;
2298
2299 if( !(entry->attribute & ATTR_DIRECTORY) )
2300 {
2301 int slen = rb->strlen(entry->d_name);
2302
2303 /* add all wav audio files */
2304 if(!rb->strcasecmp(entry->d_name + slen - 4, ".wav"))
2305 {
2306 if(num_file >= 12)
2307 break;
2308
2309 rb->strncpy(filename[num_file], dirname, 79);
2310 slen = rb->strlen(filename[num_file]);
2311 rb->strncpy(filename[num_file++] + slen, entry->d_name, 79);
2312 }
2313 }
2314 }
2315 rb->closedir(dir);
2316}
2317
2318void get_mp3_filename(char *wav_name) 2281void get_mp3_filename(char *wav_name)
2319{ 2282{
2320 int slen = rb->strlen(wav_name); 2283 int slen = rb->strlen(wav_name);
@@ -2358,20 +2321,24 @@ void get_mp3_filename(char *wav_name)
2358 2321
2359enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 2322enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
2360{ 2323{
2361 int fil, sfil, nfil; /* for file selection */
2362 int rat, srat, nrat; /* for rate selection */ 2324 int rat, srat, nrat; /* for rate selection */
2363 int cont = 1, butt; 2325 int cont = 1, butt;
2364 long tim = 0; 2326 long tim = 0;
2365 char stg[40]; 2327 char stg[40];
2366 char* bstrg[] = {"64","80","96","112","128","160","192","224","256","320"}; 2328 static const char* bstrg[] = {
2367 int brate[] = { 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 }; 2329 "64", "80", "96", "112", "128", "160", "192", "224", "256", "320"
2330 };
2331 static const int brate[] = {
2332 64, 80, 96, 112, 128, 160, 192, 224, 256, 320
2333 };
2368 2334
2369 (void)parameter; 2335 if (parameter == NULL)
2336 return PLUGIN_ERROR;
2370 2337
2371 PLUGIN_IRAM_INIT(api) 2338 PLUGIN_IRAM_INIT(api)
2372 2339
2373#ifdef CPU_COLDFIRE 2340#ifdef CPU_COLDFIRE
2374 asm volatile ("move.l #0, %macsr"); /* integer mode */ 2341 coldfire_set_macsr(0); /* integer mode */
2375#endif 2342#endif
2376 2343
2377 rb = api; 2344 rb = api;
@@ -2382,42 +2349,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
2382#endif 2349#endif
2383 rb->button_clear_queue(); 2350 rb->button_clear_queue();
2384 2351
2385 /* check 'viewer' or 'plugin' call */
2386 if(parameter == NULL || *(char*)parameter == 0)
2387 {
2388 read_wav_files("/");
2389 read_wav_files(REC_BASE_DIR"/");
2390
2391 nfil = num_file - 1;
2392 sfil = 0; /* set first file as default */
2393
2394 while(cont && (butt = rb->button_get_w_tmo(HZ/10)) != MP3ENC_SELECT)
2395 {
2396 switch(butt)
2397 {
2398 case MP3ENC_DONE: cont = 0; break;
2399 case MP3ENC_PREV: if(sfil > 0 ) sfil--; break;
2400 case MP3ENC_NEXT: if(sfil < nfil) sfil++; break;
2401 }
2402
2403 rb->lcd_clear_display();
2404 rb->lcd_putsxy(2, 2, "-- Select WAV-File --");
2405
2406 for(fil=0; fil<=nfil; fil++)
2407 rb->lcd_putsxy(2, 12 + fil*8, filename[fil]);
2408
2409 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
2410 rb->lcd_fillrect(0, 12 + sfil*8, 127, 8);
2411 rb->lcd_set_drawmode(DRMODE_SOLID);
2412 rb->lcd_update();
2413 }
2414 }
2415 else
2416 {
2417 sfil = 0;
2418 rb->strncpy(filename[0], (char*)parameter, 79);
2419 }
2420
2421 nrat = 9; 2352 nrat = 9;
2422 srat = 4; /* set 128kBit as default */ 2353 srat = 4; /* set 128kBit as default */
2423 2354
@@ -2441,7 +2372,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
2441 rb->lcd_update(); 2372 rb->lcd_update();
2442 } 2373 }
2443 2374
2444 wav_filename = filename[sfil]; 2375 wav_filename = parameter;
2445 2376
2446 if(cont) 2377 if(cont)
2447 { 2378 {