1
0
Fork 0
forked from len0rd/rockbox

Slightly better handling of disk-full situations

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3756 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Linus Nielsen Feltzing 2003-06-19 12:08:22 +00:00
parent 474c4b5427
commit c6db7870ef
5 changed files with 83 additions and 5 deletions

View file

@ -1552,3 +1552,8 @@ id: LANG_SHOW_ICONS
desc: in settings_menu
eng: "Show Icons"
new:
id: LANG_DISK_FULL
desc: in recording screen
eng: "The disk is full. Press OFF to continue."
new:

View file

@ -480,6 +480,27 @@ bool recording_screen(void)
lcd_update_rect(0, 8 + h*2, LCD_WIDTH, h);
}
}
if(mpeg_status() & MPEG_STATUS_ERROR)
{
done = true;
}
}
if(mpeg_status() & MPEG_STATUS_ERROR)
{
status_set_playmode(STATUS_STOP);
splash(0, 0, true, str(LANG_DISK_FULL));
status_draw(true);
lcd_update();
mpeg_error_clear();
while(1)
{
button = button_get(true);
if(button == (BUTTON_OFF | BUTTON_REL))
break;
}
}
mpeg_init_playback();

View file

@ -348,8 +348,13 @@ static int flush_cache(int fd)
rc = fat_readwrite(&(file->fatfile), 1,
file->cache, true );
if ( rc < 0 )
if ( rc < 0 ) {
if(file->fatfile.eof)
errno = ENOSPC;
return rc * 10 - 2;
}
file->dirty = false;
@ -418,14 +423,19 @@ static int readwrite(int fd, void* buf, int count, bool write)
return rc * 10 - 3;
}
/* read whole sectors right into the supplied buffer */
/* read/write whole sectors right into/from the supplied buffer */
sectors = count / SECTOR_SIZE;
if ( sectors ) {
int rc = fat_readwrite(&(file->fatfile), sectors, buf+nread, write );
if ( rc < 0 ) {
DEBUGF("Failed read/writing %d sectors\n",sectors);
errno = EIO;
if(write && file->fatfile.eof) {
DEBUGF("No space left on device\n");
errno = ENOSPC;
} else {
file->fileoffset += nread;
}
file->cacheoffset = -1;
return nread ? nread : rc * 10 - 4;
}

View file

@ -95,6 +95,8 @@ unsigned long mpeg_num_recorded_bytes(void);
#endif
void mpeg_get_debugdata(struct mpeg_debug *dbgdata);
void mpeg_set_buffer_margin(int seconds);
unsigned int mpeg_error(void);
void mpeg_error_clear(void);
#define SOUND_VOLUME 0
#define SOUND_BASS 1
@ -120,5 +122,8 @@ void mpeg_set_buffer_margin(int seconds);
#define MPEG_STATUS_PLAY 1
#define MPEG_STATUS_PAUSE 2
#define MPEG_STATUS_RECORD 4
#define MPEG_STATUS_ERROR 8
#define MPEGERR_DISK_FULL 1
#endif

View file

@ -26,6 +26,7 @@
#include "string.h"
#include <kernel.h>
#include "thread.h"
#include "errno.h"
#include "mp3data.h"
#include "buffer.h"
#ifndef SIMULATOR
@ -356,6 +357,8 @@ static void set_elapsed(struct mp3entry* id3)
static bool paused; /* playback is paused */
static unsigned int mpeg_errno;
#ifdef SIMULATOR
static bool is_playing = false;
static bool playing = false;
@ -1952,7 +1955,20 @@ static void mpeg_thread(void)
writelen);
if(rc < 0)
{
if(errno == ENOSPC)
{
mpeg_errno = MPEGERR_DISK_FULL;
demand_irq_enable(false);
stop_recording();
queue_post(&mpeg_queue, MPEG_STOP_DONE, 0);
break;
}
else
{
panicf("rec wrt: %d", rc);
}
}
rc = flush(mpeg_file);
if(rc < 0)
@ -2224,6 +2240,8 @@ static void init_playback(void)
void mpeg_record(char *filename)
{
mpeg_errno = 0;
strncpy(recording_filename, filename, MAX_PATH - 1);
recording_filename[MAX_PATH - 1] = 0;
@ -2330,6 +2348,8 @@ void mpeg_play(int offset)
queue_post(&mpeg_queue, MPEG_PLAY, (void*)offset);
#endif
mpeg_errno = 0;
}
void mpeg_stop(void)
@ -2343,6 +2363,7 @@ void mpeg_stop(void)
is_playing = false;
playing = false;
#endif
}
void mpeg_pause(void)
@ -2452,9 +2473,23 @@ int mpeg_status(void)
if(is_recording)
ret |= MPEG_STATUS_RECORD;
#endif
if(mpeg_errno)
ret |= MPEG_STATUS_ERROR;
return ret;
}
unsigned int mpeg_error(void)
{
return mpeg_errno;
}
void mpeg_error_clear(void)
{
mpeg_errno = 0;
}
#ifndef SIMULATOR
#ifdef HAVE_MAS3507D
int current_left_volume = 0; /* all values in tenth of dB */
@ -2919,6 +2954,8 @@ static void mpeg_thread(void)
void mpeg_init(int volume, int bass, int treble, int balance, int loudness,
int bass_boost, int avc, int channel_config)
{
mpeg_errno = 0;
#ifdef SIMULATOR
volume = bass = treble = balance = loudness
= bass_boost = avc = channel_config;