Index: uisimulator/common/stubs.c =================================================================== --- uisimulator/common/stubs.c (revision 27774) +++ uisimulator/common/stubs.c (working copy) @@ -32,6 +32,7 @@ #include "power.h" #include "ata.h" /* for volume definitions */ +#include "audio.h" /* for sleep timer */ static bool storage_spinning = false; @@ -279,15 +280,36 @@ (void)pitch; } -static int sleeptime; +static bool sleeptimer_active = false; +static long sleeptimer_endtick; void set_sleep_timer(int seconds) { - sleeptime = seconds; + time_t now; + time(&now); + if (seconds) { + sleeptimer_active = true; + sleeptimer_endtick = now + seconds; + } + else { + sleeptimer_active = false; + sleeptimer_endtick = 0; + } } int get_sleep_timer(void) { - return sleeptime; + time_t now; + time(&now); + if (sleeptimer_active && (sleeptimer_endtick >= now)) + return (sleeptimer_endtick - now); + else { + if (sleeptimer_active) { + sleeptimer_active = false; + if (audio_status() == AUDIO_STATUS_PLAY) + audio_stop(); + } + return 0; + } } #ifdef HAVE_LCD_CHARCELLS