Prevent sleep on OSX when sharing in progress

FireFly Media Server Firefly Media Server Forums Firefly Media Server Feature Requests Prevent sleep on OSX when sharing in progress

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #3013
    Anonymous
    Inactive

    I love FFMS.. it directly solves a need I have to share my iTunes lib from my Mac to my linux box.

    The one issue I have is related to sleep
    – I want my Mac to sleep when its not being used
    – I want my Mac to stay awake when there is an active sharing connection for FFMS 🙂

    As a VERY imperfect first pass I was thinking that every time a new song is accessed it could call UpdateSystemActivity()

    http://developer.apple.com/mac/library/qa/qa2004/qa1160.html

    as a way of re-starting the countdown-to-sleep timer… This fails when the sleep timeout is shorter than the song.. but unless your sleep timer is VERY short, or you load a really long audiobook.. it probably does the trick for 99% of the people, 99% of the time.

    I haven’t dug in to how to compile the code myself (its been 15 years since I compiled anything on my Mac 😉 ), and then into the source to see how the music is shared (whole file as a time, or in chunks), but if it were in chunks then I imagine it becomes a 100% solution.

    #18886
    Anonymous
    Inactive

    I’ve been programming for ~30 years.. but haven’t touched C in over 10 years, and my last real Mac programming was using Lightspeed(?) Pascal in the early 90’s. My work now is all in HDLs, and Perl/html, etc. There are probably cleaner/better ways to accomplish what I did… on the other hand, it appears to accomplish what I wanted to do. I am VERY open to (re)learning what those better ways are if anyone wants to make suggestions.

    My home network is set up such that my Mac has my music (iTunes) library.

    My HTPC (and mail/web server) is linux (ubuntu). Since Apple encrypted DAAP library sharing after iTunes version 7, I was using Firefly (mt-daapd) to serve my music (it can read iTunes).

    My linux box stays on 24/7 (as my mail/web server)… my Mac, I want to sleep (to save power) when not in use.

    The issue I had was that the act of serving music (via Firefly) was not sufficient to keep the Mac from falling asleep.

    Following up ob a generous tip (thanks BH!) I was referred to this Apple doc:

    http://developer.apple.com/mac/library/qa/qa2004/qa1160.html

    NOT being familiar with the Firefly code structure, I thought as a first approximation, if I could “poke” the OS every time a new song was started, that would be sufficient prodding to keep the Mac awake… so I hunted thru the Firefly code, and came up with this strategy (attempting to do this in a cross-platform-friendly way).

    In a non-cross-platform friendly world, the quick and dirty waste add at the top of plugin.c:

    #include

    and then at the top of the routine pi_stream I would add

    UpdateSystemActivity(OverallAct);

    Seemed simple enough… but plugin.c is not Mac-specific, so the other OSes would not like seeing Mac calls there, so to make it more cross-platform-friendly, I

    a) added (plugin.c, line 895)
    prevent_sleep();

    b) add (rend.h, line 30)
    extern void prevent_sleep(void);

    c) added (rend-osx.c, line 35)
    #include

    d) added (rend-osx.c, line 45) (message will print to the log window in the Preference panel)
    /* prevent Mac from sleeping while serving music */
    void prevent_sleep(void) {
    UpdateSystemActivity(OverallAct);
    DPRINTF(E_WARN,L_WS, “Sending keepAwaken”);
    }

    e) edit configure to add CoreServices, change line 21910 to
    LDFLAGS=”$LDFLAGS -framework CoreFoundation -framework CoreServices”

    f) will need to add a placeholder (or equivalent function) to the non OSX flavors of the rend-XXX files.
    /* placeholder to enable Mac function.. could add equivalent here for each OS if sleep is an issue */
    void prevent_sleep(void) {
    }

    Once this was done I could compile. I followed the hints from Ron in this thread; viewtopic.php?f=8&t=7353

    including installing MacPorts (http://www.macports.org/install.php) (I personally didn’t care about flac, but the id3tags lib from Fink did not work in the compile for me)

    sudo port install libid3tag sqlite3 flac

    mkdir firefly
    cd firefly
    wget http://nightlies.fireflymediaserver.org/nightlies/svn-1586/mt-daapd-svn-1586.tar.gz
    tar -xvzf mt-daapd-svn-1586.tar.gz
    cd mt-daapd-svn-1586
    ./configure –enable-flac –enable-sqlite3 –with-id3tag=/opt/local
    make

    (stop Firefly if it is running)

    cp src/mt-daapd /Library/PreferencePanes/Firefly.prefPane/Contents/Resources/Firefly Helper.app/Contents/Resources/Server/firefly
    cp src/plugins/.libs/*.so /Library/PreferencePanes/Firefly.prefPane/Contents/Resources/Firefly Helper.app/Contents/Resources/Server/plugins/
    vi ~/Library/Application Support/Firefly/firefly.conf (and change sqlite to sqlite3)

    Now restart Firefly and enjoy.

    So far in testing, my Mac will not go to sleep when serving music. When the client stops asking for songs, the Mac does go to sleep. Desired behavior accomplished.

    Based on the way I did this, your sleep timer must be no shorter than your longest song.. so I suppose if you were playing an audiobook, ripped as one long track, this might not suffice.

    Details are here for anyone that wants to duplicate, and/or Ron is welcome to pull this in (if its desired) (and/or do it in a better way), or I’d be happy to add the changes if someone would help me understand the proper way to do so (and we’d need to finish out step f) above). The other complication is that I did this against 1586, as the latest 16xx build does not work on OSX(?) (I forget why.. I saw that 1586 worked so I stuck with that).

    Again, I’m glad Firefly exists (kudos to Ron) it makes a great tool for my HTPC setup.

    PS. since the forum appears to disable direct user-to-user contact I can be reached at zimcomm at h_o_t_mail.com (remove the underscores, just trying to avoid spam)

    #18887
    Anonymous
    Inactive

    The strategy for this fight is very similar to the strategy for Firemaw. Wow~if you have Cheap wow gold buy wow power leveling aion wedding dresses wow power leveling experience of Fireman, we think it is easy for you and your members. Of course, you need more preparation, like WoW gold, items and equipments if you want to finish Blackwing Lair. wow gold If you’ve mastered him, this fight should not be much more challenging, assuming you have adequate Shadow Resist gear. Pull Ebonroc to the nearby alcove and position him so that the tanks are in a corner, facing him. Be ready for his first casts, which will Shadow of Ebonroc, wow power leveling following by Wing xqqyayaod Buffet. When the first Wing Buffet hits, start the timing for the second one, while an OT takes over and begins taunting him. As soon as a Tank is affected by Shadow of Ebonroc, the next Tank in the rotation must wedding dresses immediately Taunt Ebonroc off him. Like Firemaw, he does a Wing Wuffet every now and then. Use an OT to Taunt him away from the MT so that he does not get the Buffet (50% threat reduction). Keep Mortal Strike and Wound Poison active at all times to prevent him from aion gold healing himself. Before you enter to Blackwing Lair, you should buy some drugs with WoW money no matter how you trust your members. Saving yourself is necessary when you take a heavy damage in the combat.zdm.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Feature Requests’ is closed to new topics and replies.