summaryrefslogtreecommitdiff
path: root/firmware/mpeg.c
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2003-06-19 12:08:22 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2003-06-19 12:08:22 +0000
commitc6db7870ef001ffd7a64884b3e03d3b4cfc67b1d (patch)
tree55480a6999283da7a1932a7ed906d9dd9f757950 /firmware/mpeg.c
parent474c4b5427d4bce75ddb9217756da0173fe3ba84 (diff)
downloadrockbox-c6db7870ef001ffd7a64884b3e03d3b4cfc67b1d.tar.gz
rockbox-c6db7870ef001ffd7a64884b3e03d3b4cfc67b1d.zip
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.c39
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 @@
26#include "string.h" 26#include "string.h"
27#include <kernel.h> 27#include <kernel.h>
28#include "thread.h" 28#include "thread.h"
29#include "errno.h"
29#include "mp3data.h" 30#include "mp3data.h"
30#include "buffer.h" 31#include "buffer.h"
31#ifndef SIMULATOR 32#ifndef SIMULATOR
@@ -356,6 +357,8 @@ static void set_elapsed(struct mp3entry* id3)
356 357
357static bool paused; /* playback is paused */ 358static bool paused; /* playback is paused */
358 359
360static unsigned int mpeg_errno;
361
359#ifdef SIMULATOR 362#ifdef SIMULATOR
360static bool is_playing = false; 363static bool is_playing = false;
361static bool playing = false; 364static bool playing = false;
@@ -1952,7 +1955,20 @@ static void mpeg_thread(void)
1952 writelen); 1955 writelen);
1953 1956
1954 if(rc < 0) 1957 if(rc < 0)
1955 panicf("rec wrt: %d", rc); 1958 {
1959 if(errno == ENOSPC)
1960 {
1961 mpeg_errno = MPEGERR_DISK_FULL;
1962 demand_irq_enable(false);
1963 stop_recording();
1964 queue_post(&mpeg_queue, MPEG_STOP_DONE, 0);
1965 break;
1966 }
1967 else
1968 {
1969 panicf("rec wrt: %d", rc);
1970 }
1971 }
1956 1972
1957 rc = flush(mpeg_file); 1973 rc = flush(mpeg_file);
1958 if(rc < 0) 1974 if(rc < 0)
@@ -2224,6 +2240,8 @@ static void init_playback(void)
2224 2240
2225void mpeg_record(char *filename) 2241void mpeg_record(char *filename)
2226{ 2242{
2243 mpeg_errno = 0;
2244
2227 strncpy(recording_filename, filename, MAX_PATH - 1); 2245 strncpy(recording_filename, filename, MAX_PATH - 1);
2228 recording_filename[MAX_PATH - 1] = 0; 2246 recording_filename[MAX_PATH - 1] = 0;
2229 2247
@@ -2330,6 +2348,8 @@ void mpeg_play(int offset)
2330 2348
2331 queue_post(&mpeg_queue, MPEG_PLAY, (void*)offset); 2349 queue_post(&mpeg_queue, MPEG_PLAY, (void*)offset);
2332#endif 2350#endif
2351
2352 mpeg_errno = 0;
2333} 2353}
2334 2354
2335void mpeg_stop(void) 2355void mpeg_stop(void)
@@ -2343,6 +2363,7 @@ void mpeg_stop(void)
2343 is_playing = false; 2363 is_playing = false;
2344 playing = false; 2364 playing = false;
2345#endif 2365#endif
2366
2346} 2367}
2347 2368
2348void mpeg_pause(void) 2369void mpeg_pause(void)
@@ -2452,9 +2473,23 @@ int mpeg_status(void)
2452 if(is_recording) 2473 if(is_recording)
2453 ret |= MPEG_STATUS_RECORD; 2474 ret |= MPEG_STATUS_RECORD;
2454#endif 2475#endif
2476
2477 if(mpeg_errno)
2478 ret |= MPEG_STATUS_ERROR;
2479
2455 return ret; 2480 return ret;
2456} 2481}
2457 2482
2483unsigned int mpeg_error(void)
2484{
2485 return mpeg_errno;
2486}
2487
2488void mpeg_error_clear(void)
2489{
2490 mpeg_errno = 0;
2491}
2492
2458#ifndef SIMULATOR 2493#ifndef SIMULATOR
2459#ifdef HAVE_MAS3507D 2494#ifdef HAVE_MAS3507D
2460int current_left_volume = 0; /* all values in tenth of dB */ 2495int current_left_volume = 0; /* all values in tenth of dB */
@@ -2919,6 +2954,8 @@ static void mpeg_thread(void)
2919void mpeg_init(int volume, int bass, int treble, int balance, int loudness, 2954void mpeg_init(int volume, int bass, int treble, int balance, int loudness,
2920 int bass_boost, int avc, int channel_config) 2955 int bass_boost, int avc, int channel_config)
2921{ 2956{
2957 mpeg_errno = 0;
2958
2922#ifdef SIMULATOR 2959#ifdef SIMULATOR
2923 volume = bass = treble = balance = loudness 2960 volume = bass = treble = balance = loudness
2924 = bass_boost = avc = channel_config; 2961 = bass_boost = avc = channel_config;