adding Windows support for resume-from-standby

FireFly Media Server Firefly Media Server Forums Firefly Media Server General Discussion adding Windows support for resume-from-standby

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1598
    jae_63
    Participant

    Hi,

    I’m doing some experiments with my Soundbridge M500, to create the ability to wake my music server via Wake-on-LAN. I have attained some preliminary success, but now have run into an issue which I think could be best handled via minor source code changes to Firefly.

    The problem is this: if I wake my music server (Dell Dimension 4600C; XP service pack 2) manually by pressing the power button, it wakes up all the way and my iTunes and Firefly music servers both become “visible” from the Soundbridge. However, if I wake it by sending a Wake-on-LAN message, the monitor doesn’t turn on and the music servers are not yet visible on the Soundbridge. If at this point, for example, I manually click the mouse on the groggy music server, then it wakes up the rest of the way.

    Some reading suggests that if Firefly subscribes to the Windows WM_POWERBROADCAST message (wParam PBT_APMRESUMESUSPEND), then it can wake up the rest of the way. See:
    http://www.microsoft.com/whdc/archive/gamepm.mspx
    http://www.autoitscript.com/forum/index.php?showtopic=33986

    I still have to run some independent tests to confirm this idea. But can you tell me which portions of the (SVN) Firefly source code is Windows-specific, and would be a good place to add this functionality? Is there a true Windows event-loop somewhere?

    Also, if there are any Windows giants out there, perhaps you can tell me whether you think my idea is misguided.

    Thanks …

    #11897
    rpedde
    Participant

    @jae_63 wrote:

    Hi,

    I’m doing some experiments with my Soundbridge M500, to create the ability to wake my music server via Wake-on-LAN. I have attained some preliminary success, but now have run into an issue which I think could be best handled via minor source code changes to Firefly.

    The problem is this: if I wake my music server (Dell Dimension 4600C; XP service pack 2) manually by pressing the power button, it wakes up all the way and my iTunes and Firefly music servers both become “visible” from the Soundbridge. However, if I wake it by sending a Wake-on-LAN message, the monitor doesn’t turn on and the music servers are not yet visible on the Soundbridge. If at this point, for example, I manually click the mouse on the groggy music server, then it wakes up the rest of the way.

    Some reading suggests that if Firefly subscribes to the Windows WM_POWERBROADCAST message (wParam PBT_APMRESUMESUSPEND), then it can wake up the rest of the way. See:
    http://www.microsoft.com/whdc/archive/gamepm.mspx
    http://www.autoitscript.com/forum/index.php?showtopic=33986

    I still have to run some independent tests to confirm this idea. But can you tell me which portions of the (SVN) Firefly source code is Windows-specific, and would be a good place to add this functionality? Is there a true Windows event-loop somewhere?

    Also, if there are any Windows giants out there, perhaps you can tell me whether you think my idea is misguided.

    Thanks …

    That’s all in w32-service.c or os-win32.c.

    But I’ll warn you, services don’t have the same message pump that regular windowed apps have (DefWndProc). There is a way to subscribe to power messages from a service though… I think it’s when you register the service, you use RegisterServiceCtrlHandlerEx rather than RegisterServiceCtrlHandler, and you get different messages in your dispatch handler. Not sure, but I remember looking through that stuff before.

    Anyway, that’s the place to start looking at, I think.

    Make sure you are working from 1589, though, as current svn head doesn’t compile on win32. 🙁

    — Ron

    #11898
    jae_63
    Participant

    [Apologies for the long post; questions are at the bottom]

    Thanks for your response, Ron. As I mentioned, I’m still in the experimental phase with all this (not even looking at Firefly source code yet).

    My system is behaving much like what’s described in this Microsoft KB article:
    http://support.microsoft.com/kb/815304

    But before I get involved in contacting Microsoft (and possibly paying them for a copy of their patch), I did some more experimentation and have some more questions.

    First, the fundamental problem for my system is that when it returns from standby after receive a wake-on-LAN, neither the iTunes nor Firefly libraries are visible from the Soundbridge or from a remote iTunes. Also the monitor does not come back on, although as you can see below I’ve found a workaround for that (and I have no real need to turn on the monitor). So far, the only thing that I’ve found to wake it entirely is to move the mouse (clicking is not required). However, the system is not totally dead; far from it. In particular, I can:
    (1) execute CGI scripts from a locally installed Apache web server
    (2) control it from the commercial Salling Clicker application on my Palm Treo.

    Using the web server, I’ve run a Perl Win32::OLE script which asks iTunes for the count of tunes in its library. This works fine, but does not cause iTunes to fully wake-up. Also using the web server, I tried moving the mouse using (Perl’s) Win32-GuiTest. The mouse movement works fine normally (in the non-suspended state), and is properly reflected after the monitor turns back on, but unfortunately this mouse nudging doesn’t have the same “wakeup” effect as moving the real (USB) mouse.

    Using Clicker, I move the mouse electronically, also without effect. However, using Clicker when I play an iTunes song and then pause it, this turns the monitor on; but does not cause either the iTunes or Firefly library to appear on a remote iTunes or Soundbridge.

    So … my questions are:
    (1) Is their any way (preferably via a CGI script) to “tickle” either iTunes or Firefly or Bonjour so that the iTunes or Firefly library will be listed in a remote iTunes or Soundbridge?
    (2) Can someone please explain the mechanism by which iTunes and/or Firefly “advertise their wares?” This seems to require a more active role than, say, listening to port 80 for an HTTP connection.

    Thanks in advance for any advice.

    #11899
    rpedde
    Participant

    @jae_63 wrote:

    My system is behaving much like what’s described in this Microsoft KB article:
    http://support.microsoft.com/kb/815304

    Don’t forget to check you have latest bios. Lots of those type of problems are related to BIOS as well. As well as ACPI. Sometimes there are some ACPI settings you can frob in BIOS that help.

    Of course, you’ve probably already tried all that, so…

    So … my questions are:
    (1) Is their any way (preferably via a CGI script) to “tickle” either iTunes or Firefly or Bonjour so that the iTunes or Firefly library will be listed in a remote iTunes or Soundbridge?

    Well, you could try hard-starting bonjour and firefly… something like:

    net stop “Firefly Media Server”
    net stop “Bonjour”
    net start “Bonjour”
    net start “Firefly Media Server”

    might do it, for example.

    (2) Can someone please explain the mechanism by which iTunes and/or Firefly “advertise their wares?” This seems to require a more active role than, say, listening to port 80 for an HTTP connection.

    Thanks in advance for any advice.

    Ya, it works by multicast. Firefly tells the bonjour service that it has services it wants to advertise to the network. Bonjour is really a DNS server, only multicast based.

    When iTunes starts up, it does a multicast query for services of type _daap._tcp (or _rsp._tcp, in the case of the soundbridge — they use different protocols).

    Bonjour should see the request, and reply that there is a daap service running on the machine (since firefly registered with it).

    From there, the soundbridge/iTunes queries for machine details, gets an ip address and port, and connects.

    You know, it could also be NIC driver, forgetting to re-enable multicast when it comes out of sleep. Upgrading the nic driver might be a thought, too.

    Anyway, the resolution protocol is properly called mDNS (multicast dns). I’d guess wikipedia has more a cogent description of it than I can do.

    I’d sure try the driver/bios/etc round before trying to contact microsoft, though… who knows, might even work. 🙂

    — Ron

    #11900
    jae_63
    Participant

    Thanks again for your response, Ron.

    Since it’s a Dell which is a few years old, my BIOS options are pretty limited. I guess that’s a disadvantage of buying from a PC vendor rather than a motherboard vendor. My ethernet driver is up-to-date.

    I was able to start&stop Firefly without any problems, but for some reason was unable to start&stop Bonjour (although this worked fine on my laptop). Fortunately the following solution works, using COM (rather than net start/net stop): kill iTunes if it’s running, then start a fresh iTunes. The fresh iTunes apparently tickles Bonjour in the necessary fashion.

    So I’m back in business now just using iTunes. I might pursue Firefly again at a later date.

    My script (intended to be run as a CGI script from a web server) is below for posterity; thanks again for your help!


    #!c:/Perl/bin/perl
    use strict;
    use Win32::Process::List;
    use Win32::OLE;

    my $P = Win32::Process::List->new(); # constructor
    my %list = $P->GetProcesses();
    my $isRunning = 0;
    foreach my $key ( keys %list) {
    if ($list{$key} =~ /iTunes.exe/) {
    $isRunning = 1;
    last;
    }
    }

    if ($isRunning) {
    my $iTunes = Win32::OLE->new("iTunes.Application");
    $iTunes->Quit();
    }
    sleep 1;
    my $iTunes = Win32::OLE->new("iTunes.Application");
    $iTunes->VisualsEnabled(1);

    print "Content-type: text/htmlnn";
    print "re" if ($isRunning);
    print "started iTunesn";
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.