PDA

View Full Version : Slimserver PC going into standby



bigjules
2006-03-31, 20:20
Had a shocker of a week.. so I bought a squeezebox.. love it.. cheered me up immensely

How can I prevent the PC I have slimserver running on from going into standby while its streaming music to my squeezebox?
I can wake it up again from my sqeezebox by pressing the power button.. but it keeps going to sleep again after the standby timer interval I have set in Windows Power Management.
I dont particularly want to disable power management..

Any advice?

Jules

Michaelwagner
2006-03-31, 20:31
As I understand it, Windows power management will power off your computer unless you use the keyboard or mouse.

There's no way for slimserver (or other software that runs as a server) to change that.

Squeezeboxes support Wakeup on Lan, but that's quite a different story. That wakes up the server after it's been asleep and the SB has been idle.

bigjules
2006-03-31, 21:25
I thought it was a bit more sophistocated than that.. Some applications prevent standby (eg the machine doesn't go into standby if iTunes is playing music.. ).

But you may well be right.. I thought there might be a setting somewhere that let network activity prevent standby..

Michaelwagner
2006-03-31, 22:09
Some applications prevent standby (eg the machine doesn't go into standby if iTunes is playing music.. ).
Is that true? I don't have iTunes, so I don't know.

There was some speculation a while ago on this forum that there was a windows shutdown message that slim could hook and veto. But I don't recall where that discussion went.

You could use the search tool to search for other threads that discuss standby and read what they say. Probably better than relying on my sleepy memory.

bigjules
2006-03-31, 22:57
There are windows system calls that an application can use to prevent suspend/shutdow. and events it can monitor when these occur.. But its been so many years since I did any perl coding that I don't know how they are accessed.

Most of the threads on standby seem to be about getting the PC running slimserver to wake up.

danco
2006-04-01, 00:51
I don't know if the Execute Script plugin works for Windows.

If it does, you might be able to have a script that disables Power Management when the SB is running and another that turns Power Management on again when the SB is turned off. Once the script is set up, the operation would be automatic.

bigjules
2006-04-01, 03:55
A possibility.. But I'm sure there must be a way to prevent XP from going into standby when there is network activity.. I just cant find it.

Browny
2006-04-01, 04:30
Ok - I'm not really a Perl guy, but we had a similar problem for a VB application we had at work.

The VB solution below may help to shed some light on whats needed to do it in Perl:

http://www.freevbcode.com/ShowCode.Asp?ID=2596

Or you may be able to use it in a VB Script with the Execute Script plugin...

Michaelwagner
2006-04-01, 10:21
You may be interested in this bug report:
Bug 2746: Wake on LAN - PC returns to standby after Power Save period

http://bugs.slimdevices.com/show_bug.cgi?id=2746

I appended the code reference from this thread into that bug report. Perhaps that will help.

bigjules
2006-04-01, 16:15
Cool.. thanks for finding that bug report.. I forgot to search the bug database.. will do so in future.

Thanks too for the reference to the VB script.

If I have time I'll look at writing a plugin to prevent standby in Windows. Until then.. I'll leave my computer on.

Jules

Michaelwagner
2006-04-02, 10:02
Hmm...started to post, then computer crashed.

Another code example, this time Foxpro.


you may wish to prevent Windows from shutting down under certain conditions, such as an import process not being complete. In that case, you'd bind to the WM_POWERBROADCAST message and return BROADCAST_QUERY_DENY if the shutdown should be halted.

From:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfoxtk05/html/ft05a1.asp

Khuli
2006-04-03, 01:32
A possibility.. But I'm sure there must be a way to prevent XP from going into standby when there is network activity.. I just cant find it.

I have the complete opposite problem, in that my SlimServer PC never goes into standby...

bigjules
2006-04-03, 03:21
I have the complete opposite problem, in that my SlimServer PC never goes into standby...

lol.. Thats what I expected to happen on my machine..

Michaelwagner
2006-04-03, 06:52
In the bug report, I posted URLs and some text for the relevant parts of the microsoft knowledgebase on this topic, how it works, etc.

I don't know enough about perl, and especially not about perl interfaces to windows messaging, so it'll be up to someone else to take the ball from here and work out a patch.

oktup
2006-04-03, 07:11
I have the complete opposite problem, in that my SlimServer PC never goes into standby...

Yep, see bug 2068 (http://bugs.slimdevices.com/show_bug.cgi?id=2068). I've realised that my PC is making it into Standby after the specified time, but only for about half a second - it gets woken up again almost instantly by the SB's network traffic. However, if there's no subsequent HD activity (ie I'm not playing anything on the SB), it tries to go into Standby again a few minutes later - and wakes up again straight away - and this continues, every few minutes, ad nauseum. I imagine this is pretty unhealthy for the PC (particularly the hard drives).

Hopefully the bug will be resolved soon (which reminds me, I should vote for it!) but until then, I have to work around it by preventing the PC from becoming 'inactive', if my SB is getting power but not actually being used. I've contemplated trying to use the Execute Script or PowerSave plugins to generate some HD activity when the SB is idle, but not actually done anything yet ;)

Edit - having just thought about this, does the local network traffic cease when connected to SqueezeNetwork? If so, could I amend my mappings so that Power-Off connected to SqueezeNetwork before 'powering off', and Power-On reconnected to SlimServer? Will experiment when I get home from work...

bigjules
2006-04-04, 21:41
ok.. Here's a plugin that fixed my problem..

I've never written any Perl before.. so be kind. I used the Win32::API module from CPAN to access the Windows function SetThreadExecutionState().
The plugin simply checks all clients every minute, and if any of them are playing it resets the standby timer using the Windows method above.

Thanks to everyone for their input.

Edit: Also works for SlimServer 6.5, only Win32::API is included in that release, so you only need to extract the PreventStandby/Plugin.pm file.

mortod
2006-04-09, 01:21
Can't open the ZIP - it comes back with 'The compressed (zipped)Folder is invalid or corrupted'.

mherger
2006-04-09, 01:40
> Can't open the ZIP - it comes back with 'The compressed (zipped)Folder
> is invalid or corrupted'.

Right click -> download the link (or don't use MSIE). This seems to be a
well known problem with Internet Explorer...

The plugin has been integrated into the latest nightly builds of
slimserver.

--

Michael

-----------------------------------------------------------
Help translate SlimServer by using the
StringEditor Plugin (http://www.herger.net/slim/)

mortod
2006-04-09, 10:34
OK, so have downloaded the nightly version, but rather than install I was hoping to patch the plugin into my 6.2.2 version - how do I do that ? Tried putting the plugin in the tree, but I guess there is more to do (something to do with the CPAN API?). As I am unable to download the prevent standby ZIP - please advise.

oreillymj
2006-04-09, 12:04
I made a few changes to the prevent standby plugin as it did not appear in the plugin list and also was not preventing my PC from going to standby.

When I enabled d_plugins I saw no debug info. Anyway, the entire updated plugins/PreventStandby/Plugin.pm is in this post.

http://forums.slimdevices.com/showpost.php?p=100732&postcount=10

The main problem was that the code was missing a "use Win32::API;" statement.

My PC will now wake on lan and stay awake perfectly. BTW - I had tried making this API call from a VB app using the Execute script plugin, but the thread which makes the call must stay active otherwise the PC just goes to sleep.

bigjules
2006-04-09, 15:40
The main problem was that the code was missing a "use Win32::API;" statement.



err.. the code doesn't seem to be missing the "use Win32::API"..
just take a look in the zip.

ahh.. sorry.. just realised that you meant in the plugin in the 6.2.2 and 6.5 source tree..

oreillymj
2006-04-10, 01:50
Yes, I don't have a subversion account, so I couldn't upload the changes I needed to make to the Plugin.pm in the official build. So what's in the nightlies dies during initialisation.

Hopefully Dan or someone with an acount will commit a fix today.

BTW - When fixed it works great. Good work.

bigjules
2006-04-10, 02:50
BTW - When fixed it works great. Good work.

Thanks..

One oddity I have noticed is that when my server PC wakes from suspend when I press "on" on the squeezebox, the display will not turn off. It will happily go back into suspend after the defined timeout (if I turn the squeezebox back off), but the display stays on the whole time.

If I get time I'll figure out why.. but it is probably some Windows oddity.

oreillymj
2006-04-10, 05:37
The Ssqueezebox itself never goes "off", but on my system when the PC is in standby it will display a Communication type error and then go blank.

You should check the main options page on the Player settings link.
Usually there are 3 options, set as follows :

Choose a screensaver to use when playing: "Now Playing"
Choose a screensaver to use when not playing: "None"
Choose a screensaver to use when powered off: "Date and Time"

I think that will allow the scrren to go blank when the player is idle.

bigjules
2006-04-11, 04:00
Sorry.. my message was confusing..

I meant the display on my slimserver PC.. So sequence of events:

1) Turn on server PC.
2) After 5 mins -- Display turns off
3) After 15 mins -- goes into suspend.
4) Hit "on" button on squeezebox
5) Wakes up server
6) Server resumes and display turns on
6) Play some music (lets say for 1 hour) -- Server display still on
7) Turn off squeezebox -- Server display still on
8) After 15 mins -- server goes into suspend (and server display turns off)

So something is keeping the display on.. but I dont know what it is.. Its definately not slimserver.. Probably just a windows power management problem.

oreillymj
2006-04-11, 05:05
Yes, probably the parameter that you are sending to SetThreadExecution state is >=2

Here are the Execution state flags as per MSDN. Anything higher than 1 would imply that the monitor should come on.

Const ES_SYSTEM_REQUIRED = &H1
Const ES_DISPLAY_REQUIRED = &H2
Const ES_USER_PRESENT = &H4
Const ES_CONTINUOUS = &H80000000

More here ...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/power/base/setthreadexecutionstate.asp

bigjules
2006-04-11, 22:27
Yes, probably the parameter that you are sending to SetThreadExecution state is >=2


In the plugin I use SetThreadExecutionState(1) .. Which shouldn't intefere with the display standby timer at all.

I rekon its a windows stuffup.. I bet if I send a WOL from anywhere, and dont use the keyboard or mouse on the machine that wakes up the same thing will happen.. will test sometime.

lnxguru
2006-04-12, 07:42
Its been awhile since I worked on windows but isn't there a power management setting under the Control Panel? Just choose "Always on".

But maybe I'm just talking out of my you-know-what.

Rich

oreillymj
2006-04-12, 12:08
Yes, I looked at your code and although my perl isn't the best, I saw the setThreadExecutionState->Call(1) and figured the call was correct.

So I guess it is sonething to do with the Power management options you have selected in control panel.

I have monitor standby set to 5 mins, hard disks never.
WOL bring my machine on with the monitors left in standby unless I move the mouse or use the keyboard.

I was looking to see where these settings are stored found that the reg keys are in HKCU\Control Panel\Power Management or HKUsers\Control\.DEFAULT\Control Panel\Power Management.

mortod
2006-04-16, 10:31
This is a great plugin - I can't believe its such a recent innovation though as I would have thought power management quite fundamental to SB.

Just one observation though - I have my XP standby timer set to 15 minutes, and sure enough the PC normally goes into standby 15 minutes after the last touch of the keyboard. But if the PC has woken due to WOL from the SB, it then goes into standby just 2 minutes after the SB playing is stopped - not 15 minutes.

bigjules
2006-04-17, 04:27
But if the PC has woken due to WOL from the SB, it then goes into standby just 2 minutes after the SB playing is stopped - not 15 minutes.

That is pretty odd.. I wonder if it is related to my display never going into standby when I get WOL from SB..

Maybe the windows power management settings dont get restored properly when the machine wakes up from WOL..

Sounds like a problem that might be hard to track down. So I might leave it until I have more time..

(working on a plugin to skip all songs in the zapped song playlist -- taking up most of my SB time :)