diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2003-06-19 12:08:22 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2003-06-19 12:08:22 +0000 |
commit | c6db7870ef001ffd7a64884b3e03d3b4cfc67b1d (patch) | |
tree | 55480a6999283da7a1932a7ed906d9dd9f757950 /firmware/mpeg.c | |
parent | 474c4b5427d4bce75ddb9217756da0173fe3ba84 (diff) |
Slightly better handling of disk-full situations
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3756 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/mpeg.c')
-rw-r--r-- | firmware/mpeg.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c index 6872ee171b..11f7e60f16 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c @@ -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) - 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); 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; |