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:
parent
474c4b5427
commit
c6db7870ef
5 changed files with 83 additions and 5 deletions
|
|
@ -1552,3 +1552,8 @@ id: LANG_SHOW_ICONS
|
||||||
desc: in settings_menu
|
desc: in settings_menu
|
||||||
eng: "Show Icons"
|
eng: "Show Icons"
|
||||||
new:
|
new:
|
||||||
|
|
||||||
|
id: LANG_DISK_FULL
|
||||||
|
desc: in recording screen
|
||||||
|
eng: "The disk is full. Press OFF to continue."
|
||||||
|
new:
|
||||||
|
|
|
||||||
|
|
@ -362,7 +362,7 @@ bool recording_screen(void)
|
||||||
timeout = current_tick + HZ/10;
|
timeout = current_tick + HZ/10;
|
||||||
|
|
||||||
seconds = mpeg_recorded_time() / HZ;
|
seconds = mpeg_recorded_time() / HZ;
|
||||||
|
|
||||||
update_countdown--;
|
update_countdown--;
|
||||||
if(update_countdown == 0 || seconds > last_seconds)
|
if(update_countdown == 0 || seconds > last_seconds)
|
||||||
{
|
{
|
||||||
|
|
@ -480,6 +480,27 @@ bool recording_screen(void)
|
||||||
lcd_update_rect(0, 8 + h*2, LCD_WIDTH, h);
|
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();
|
mpeg_init_playback();
|
||||||
|
|
|
||||||
|
|
@ -348,8 +348,13 @@ static int flush_cache(int fd)
|
||||||
|
|
||||||
rc = fat_readwrite(&(file->fatfile), 1,
|
rc = fat_readwrite(&(file->fatfile), 1,
|
||||||
file->cache, true );
|
file->cache, true );
|
||||||
if ( rc < 0 )
|
|
||||||
|
if ( rc < 0 ) {
|
||||||
|
if(file->fatfile.eof)
|
||||||
|
errno = ENOSPC;
|
||||||
|
|
||||||
return rc * 10 - 2;
|
return rc * 10 - 2;
|
||||||
|
}
|
||||||
|
|
||||||
file->dirty = false;
|
file->dirty = false;
|
||||||
|
|
||||||
|
|
@ -418,14 +423,19 @@ static int readwrite(int fd, void* buf, int count, bool write)
|
||||||
return rc * 10 - 3;
|
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;
|
sectors = count / SECTOR_SIZE;
|
||||||
if ( sectors ) {
|
if ( sectors ) {
|
||||||
int rc = fat_readwrite(&(file->fatfile), sectors, buf+nread, write );
|
int rc = fat_readwrite(&(file->fatfile), sectors, buf+nread, write );
|
||||||
if ( rc < 0 ) {
|
if ( rc < 0 ) {
|
||||||
DEBUGF("Failed read/writing %d sectors\n",sectors);
|
DEBUGF("Failed read/writing %d sectors\n",sectors);
|
||||||
errno = EIO;
|
errno = EIO;
|
||||||
file->fileoffset += nread;
|
if(write && file->fatfile.eof) {
|
||||||
|
DEBUGF("No space left on device\n");
|
||||||
|
errno = ENOSPC;
|
||||||
|
} else {
|
||||||
|
file->fileoffset += nread;
|
||||||
|
}
|
||||||
file->cacheoffset = -1;
|
file->cacheoffset = -1;
|
||||||
return nread ? nread : rc * 10 - 4;
|
return nread ? nread : rc * 10 - 4;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,8 @@ unsigned long mpeg_num_recorded_bytes(void);
|
||||||
#endif
|
#endif
|
||||||
void mpeg_get_debugdata(struct mpeg_debug *dbgdata);
|
void mpeg_get_debugdata(struct mpeg_debug *dbgdata);
|
||||||
void mpeg_set_buffer_margin(int seconds);
|
void mpeg_set_buffer_margin(int seconds);
|
||||||
|
unsigned int mpeg_error(void);
|
||||||
|
void mpeg_error_clear(void);
|
||||||
|
|
||||||
#define SOUND_VOLUME 0
|
#define SOUND_VOLUME 0
|
||||||
#define SOUND_BASS 1
|
#define SOUND_BASS 1
|
||||||
|
|
@ -120,5 +122,8 @@ void mpeg_set_buffer_margin(int seconds);
|
||||||
#define MPEG_STATUS_PLAY 1
|
#define MPEG_STATUS_PLAY 1
|
||||||
#define MPEG_STATUS_PAUSE 2
|
#define MPEG_STATUS_PAUSE 2
|
||||||
#define MPEG_STATUS_RECORD 4
|
#define MPEG_STATUS_RECORD 4
|
||||||
|
#define MPEG_STATUS_ERROR 8
|
||||||
|
|
||||||
|
#define MPEGERR_DISK_FULL 1
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
#include "errno.h"
|
||||||
#include "mp3data.h"
|
#include "mp3data.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
|
|
@ -356,6 +357,8 @@ static void set_elapsed(struct mp3entry* id3)
|
||||||
|
|
||||||
static bool paused; /* playback is paused */
|
static bool paused; /* playback is paused */
|
||||||
|
|
||||||
|
static unsigned int mpeg_errno;
|
||||||
|
|
||||||
#ifdef SIMULATOR
|
#ifdef SIMULATOR
|
||||||
static bool is_playing = false;
|
static bool is_playing = false;
|
||||||
static bool playing = false;
|
static bool playing = false;
|
||||||
|
|
@ -1952,7 +1955,20 @@ static void mpeg_thread(void)
|
||||||
writelen);
|
writelen);
|
||||||
|
|
||||||
if(rc < 0)
|
if(rc < 0)
|
||||||
panicf("rec wrt: %d", rc);
|
{
|
||||||
|
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);
|
rc = flush(mpeg_file);
|
||||||
if(rc < 0)
|
if(rc < 0)
|
||||||
|
|
@ -2224,6 +2240,8 @@ static void init_playback(void)
|
||||||
|
|
||||||
void mpeg_record(char *filename)
|
void mpeg_record(char *filename)
|
||||||
{
|
{
|
||||||
|
mpeg_errno = 0;
|
||||||
|
|
||||||
strncpy(recording_filename, filename, MAX_PATH - 1);
|
strncpy(recording_filename, filename, MAX_PATH - 1);
|
||||||
recording_filename[MAX_PATH - 1] = 0;
|
recording_filename[MAX_PATH - 1] = 0;
|
||||||
|
|
||||||
|
|
@ -2330,6 +2348,8 @@ void mpeg_play(int offset)
|
||||||
|
|
||||||
queue_post(&mpeg_queue, MPEG_PLAY, (void*)offset);
|
queue_post(&mpeg_queue, MPEG_PLAY, (void*)offset);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
mpeg_errno = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mpeg_stop(void)
|
void mpeg_stop(void)
|
||||||
|
|
@ -2343,6 +2363,7 @@ void mpeg_stop(void)
|
||||||
is_playing = false;
|
is_playing = false;
|
||||||
playing = false;
|
playing = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mpeg_pause(void)
|
void mpeg_pause(void)
|
||||||
|
|
@ -2452,9 +2473,23 @@ int mpeg_status(void)
|
||||||
if(is_recording)
|
if(is_recording)
|
||||||
ret |= MPEG_STATUS_RECORD;
|
ret |= MPEG_STATUS_RECORD;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(mpeg_errno)
|
||||||
|
ret |= MPEG_STATUS_ERROR;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int mpeg_error(void)
|
||||||
|
{
|
||||||
|
return mpeg_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mpeg_error_clear(void)
|
||||||
|
{
|
||||||
|
mpeg_errno = 0;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
#ifdef HAVE_MAS3507D
|
#ifdef HAVE_MAS3507D
|
||||||
int current_left_volume = 0; /* all values in tenth of dB */
|
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,
|
void mpeg_init(int volume, int bass, int treble, int balance, int loudness,
|
||||||
int bass_boost, int avc, int channel_config)
|
int bass_boost, int avc, int channel_config)
|
||||||
{
|
{
|
||||||
|
mpeg_errno = 0;
|
||||||
|
|
||||||
#ifdef SIMULATOR
|
#ifdef SIMULATOR
|
||||||
volume = bass = treble = balance = loudness
|
volume = bass = treble = balance = loudness
|
||||||
= bass_boost = avc = channel_config;
|
= bass_boost = avc = channel_config;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue