fix leak-file-handles.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28330 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Teruaki Kawashima 2010-10-23 12:40:07 +00:00
parent 368e89e3bc
commit d46d24332f
2 changed files with 9 additions and 4 deletions

View file

@ -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);
}

View file

@ -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;
}