From d46d24332f3a16fa736def96a717e1648441161a Mon Sep 17 00:00:00 2001 From: Teruaki Kawashima Date: Sat, 23 Oct 2010 12:40:07 +0000 Subject: [PATCH] fix leak-file-handles. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28330 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/mp3_encoder.c | 7 +++++-- apps/plugins/wav2wv.c | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/plugins/mp3_encoder.c b/apps/plugins/mp3_encoder.c index 392fc36d31..5088187b76 100644 --- a/apps/plugins/mp3_encoder.c +++ b/apps/plugins/mp3_encoder.c @@ -2491,6 +2491,7 @@ enum plugin_status plugin_start(const void* parameter) { int rat, srat, nrat; /* for rate selection */ int cont = 1, butt; + int ret; long tim = 0; static const char* bstrg[] = { "64", "80", "96", "112", "128", "160", "192", "224", "256", "320" @@ -2544,7 +2545,8 @@ enum plugin_status plugin_start(const void* parameter) if(cont) { - if(wave_open() == 0) + ret = wave_open(); + if(ret == 0) { init_mp3_encoder_engine(true, brate[srat], cfg.samplerate); get_mp3_filename(wav_filename); @@ -2557,11 +2559,12 @@ enum plugin_status plugin_start(const void* parameter) rb->close(wavfile); rb->close(mp3file); + rb->reload_directory(); } else { rb->close(wavfile); - rb->lcd_putsxyf(0, 20, "WaveOpen failed %d", wave_open()); + rb->lcd_putsxyf(0, 20, "WaveOpen failed %d", ret); rb->lcd_update(); rb->sleep(5*HZ); } diff --git a/apps/plugins/wav2wv.c b/apps/plugins/wav2wv.c index e2db398ef7..cd27c92699 100644 --- a/apps/plugins/wav2wv.c +++ b/apps/plugins/wav2wv.c @@ -123,6 +123,7 @@ static int wav2wv(const char *infile) if (rb->read (in_fd, &raw_header, sizeof (raw_header)) != sizeof (raw_header)) { rb->splash(HZ*2, "could not read file!"); + rb->close (in_fd); return true; } @@ -135,6 +136,7 @@ static int wav2wv(const char *infile) rb->strncmp (native_header.data_ckID, "data", 4) || native_header.FormatTag != 1 || native_header.BitsPerSample != 16) { rb->splash(HZ*2, "incompatible wav file!"); + rb->close (in_fd); return true; } @@ -266,6 +268,7 @@ static int wav2wv(const char *infile) else rb->splash(HZ*3, "operation successful"); + rb->reload_directory(); return error; } @@ -290,6 +293,5 @@ enum plugin_status plugin_start(const void *parameter) #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(false); #endif - /* Return PLUGIN_USB_CONNECTED to force a file-tree refresh */ - return PLUGIN_USB_CONNECTED; + return PLUGIN_OK; }