From 2bf4178018930b8af6d7082f7dd1a3302e09932b Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Sun, 13 Apr 2008 12:24:47 +0000 Subject: Make mpegplayer sleep the disk after buffering to save battery. * Add a simulator stub for ata_sleep(), and un-ifdef most calls to it. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17096 a1c6a512-1295-4272-9138-f99709370657 --- apps/buffering.c | 2 -- apps/plugin.c | 2 +- apps/plugin.h | 6 +++--- apps/plugins/clock/clock_settings.c | 2 -- apps/plugins/mpegplayer/disk_buf.c | 3 +++ uisimulator/common/stubs.c | 5 +++++ 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/buffering.c b/apps/buffering.c index 99a4a3b058..f123d8fcc3 100644 --- a/apps/buffering.c +++ b/apps/buffering.c @@ -813,11 +813,9 @@ static bool fill_buffer(void) } else { -#ifndef SIMULATOR /* only spin the disk down if the filling wasn't interrupted by an event arriving in the queue. */ ata_sleep(); -#endif return false; } } diff --git a/apps/plugin.c b/apps/plugin.c index 7a8e0e04be..a7baa6d314 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -234,8 +234,8 @@ static const struct plugin_api rockbox_api = { fdprintf, read_line, settings_parseline, -#ifndef SIMULATOR ata_sleep, +#ifndef SIMULATOR ata_disk_is_active, #endif ata_spin, diff --git a/apps/plugin.h b/apps/plugin.h index c638688753..2db38eda4c 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -120,12 +120,12 @@ #define PLUGIN_MAGIC 0x526F634B /* RocK */ /* increase this every time the api struct changes */ -#define PLUGIN_API_VERSION 107 +#define PLUGIN_API_VERSION 108 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any new function which are "waiting" at the end of the function table) */ -#define PLUGIN_MIN_API_VERSION 107 +#define PLUGIN_MIN_API_VERSION 108 /* plugin return codes */ enum plugin_status { @@ -331,8 +331,8 @@ struct plugin_api { int (*fdprintf)(int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3); int (*read_line)(int fd, char* buffer, int buffer_size); bool (*settings_parseline)(char* line, char** name, char** value); -#ifndef SIMULATOR void (*ata_sleep)(void); +#ifndef SIMULATOR bool (*ata_disk_is_active)(void); #endif void (*ata_spin)(void); diff --git a/apps/plugins/clock/clock_settings.c b/apps/plugins/clock/clock_settings.c index fddea57c34..233be6565f 100644 --- a/apps/plugins/clock/clock_settings.c +++ b/apps/plugins/clock/clock_settings.c @@ -171,9 +171,7 @@ void load_settings(void){ draw_message(display, MESSAGE_ERRLOAD, 1); display->update(); } -#ifndef SIMULATOR rb->ata_sleep(); -#endif rb->sleep(HZ); } diff --git a/apps/plugins/mpegplayer/disk_buf.c b/apps/plugins/mpegplayer/disk_buf.c index 46a060221d..7ecf51c168 100644 --- a/apps/plugins/mpegplayer/disk_buf.c +++ b/apps/plugins/mpegplayer/disk_buf.c @@ -169,6 +169,7 @@ static inline void disk_buf_buffer(void) if (!stream_get_window(&sw)) { disk_buf.state = TSTATE_DATA; + rb->ata_sleep(); break; } @@ -183,6 +184,7 @@ static inline void disk_buf_buffer(void) /* Free space is less than one page */ disk_buf.state = TSTATE_DATA; disk_buf.low_wm = DISK_BUF_LOW_WATERMARK; + rb->ata_sleep(); break; } @@ -204,6 +206,7 @@ static inline void disk_buf_buffer(void) { /* Error or end of stream */ disk_buf.state = TSTATE_EOS; + rb->ata_sleep(); break; } diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index c40d10082c..18e7a242d0 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c @@ -108,6 +108,11 @@ void ata_spin(void) { } +void ata_sleep(void) +{ + DEBUGF("ata_sleep()\n"); +} + void ata_spindown(int s) { (void)s; -- cgit v1.2.3