• Status Closed
  • Percent Complete
  • Task Type Patches
  • Category Settings
  • Assigned To No-one
  • Operating System
  • Severity Low
  • Priority Very Low
  • Reported Version
  • Due in Version Undecided
  • Due Date Undecided
  • Votes 2
  • Private
Attached to Project: Rockbox
Opened by berndtnm - 2005-10-17
Last edited by torne - 2010-03-28

FS#2720 - bookmark on idle poweroff and sleep poweroff

This patch adds a few lines of code to powermgmt.c to
modify handle_auto_poweroff.

Before actually shutting down because of idle powerdown
or sleep timer, fake the pressing of the stop button,
if the user has chosen the setting YES for auto create
bookmark. This causes a bookmark to be written before
the player powers down.

I find this behavior desirable, because I often listen
to audio books. When I press pause, and wait too long
the player powers down and the only way to get to the
place where the book stopped, is to resume. If I forget
to resume the location where I stopped listening to the
book is lost. This patch fixes this problem.

Closed by  torne
2010-03-28 23:29
Reason for closing:  Fixed
Additional comments about closing:   Warning: Undefined array key "typography" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 371 Warning: Undefined array key "camelcase" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 407

Fixed by some other past commit :)

Project Manager

That is definitely not the way to do it.

The sys_poweroff() event ends up in the clean_shutdown()
function in misc.c, and you should add a
bookmark_autobookmark() call there, or in the system_flush()
function. However, it should only be done if it is an
automatic shutdown, and if the music is paused. That will
require some extra hacking in the sys_poweroff() function so
it can distinguish between manual and automatic poweroff.

I agree that my original patch was exceedingly ugly… but
it worked. Anyway, I followed Linus’ instructions and creted
another patch that modifies clean_shutdown in apps/misc.c.
The rationale of this patch is that if clean_shutdown is
called and audio_status() has the AUDIO_STATUS_PLAY bit set,
this could only have happened in the case of an idle
poweroff or sleep timer poweroff, so a bookmark is created
if the global setting for autocreatebookmark is BOOKMARK_YES
(in the other cases, user interaction is required, which is
not desirable in the case of idle poweroff or sleep timer

To make the behavor of idle poweroff and sleep timer
poweroff consistent, I had to modify firmware/powermgmt.c,
such that there is not audio_stop() call before the sleep
timer shuts down the player. I moved the this call so that
now only occurs if the player is plugged in. I think, this
is more consistent with the way the player is shut down due
to an idle poweroff.

This patch obviously does not give clean_shutdown the
ability to explicitly distinguish between auto poweroff and
manual poweroff. This information is implicitly given by the
fact that we somehow ended up in clean_shutdown and the
player is still playing.

- M

Project Manager

There are cases when the music might be playing on a manual
poweroff, like when you leave the WPS with the music paused
or playing.

On the other hand, you still want to save a bookmark in
those cases, so I guess this would work. I’ll have a look at
your patch soonish.

petur commented on 2007-08-02 19:59


This would be a very useful feature for those of us that listen to audiobooks in the car.

Could someone please be so kind to sync with svn?

Oh, god. It IS on svn, it seems I’ve reopened an accepted task.
Sorry, it’s the lack of sleep.

Marcus, when it was committed? I still do not get bookmark when my paused player turns off automatically.

torne commented on 2010-03-28 22:48

This patch wasn’t committed, but a different change was made which does indeed make bookmarks get saved on poweroff. I tested by setting bookmark on stop to yes, and idle poweroff to one minute. On playing something, then pausing and leaving the player alone, it shuts down and during shutdown the “Bookmark Saved” splash appears, and when the player is turned back on the bookmark is there.

However, if you have bookmark on stop set to “ask” it appears to screw everything up: it prompts you, but if you don’t answer the prompt the player powers off anyway, seemingly without completing the rest of the tasks in the clean shutdown procedure!

The patch above doesn’t save a bookmark in this situation; does anyone have an opinion on whether it should work that way?

torne commented on 2010-03-28 23:29

OK, I’ve fixed that in r25376 - if you have it set to “ask” it will just assume you don’t want one on idle poweroff. I’m going to close this again, as from my testing it now works as desired.


Available keyboard shortcuts


Task Details

Task Editing