The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: sinsi on October 29, 2007, 10:50:56 AM

Title: Program's starting priority
Post by: sinsi on October 29, 2007, 10:50:56 AM
Is there a way of starting a program in XP Home at a different priority?
I like to listen to my music when I play a game, so here's what I do:
- open "Shortcut to latest.wpl" which starts windows media player to play my mp3's
- run a program I wrote which can play/pause/skip/back WMP
- start task manager and change WMP's priority to above normal, since there are loooooong delays when playing the next song
- start a game

Now my little program can change WMP's priority if I need to, but if there is a simple box to be checked that would save poor lazy me writing some (superfluous) code.
Title: Re: Program's starting priority
Post by: Tedd on October 29, 2007, 11:10:39 AM
If task manager is available in XP Home - open it, view the process list, right-click on the chosen process -> set priority, ... bingo.
If not, I'm pretty sure there are various programs to do the same.
Title: Re: Program's starting priority
Post by: sinsi on October 29, 2007, 11:19:55 AM
Ummm...that was my step 3
Quote from: sinsi on October 29, 2007, 10:50:56 AM
- start task manager and change WMP's priority to above normal, since there are loooooong delays when playing the next song
Title: Re: Program's starting priority
Post by: Tedd on October 29, 2007, 11:23:22 AM
Oops ::)
Title: Re: Program's starting priority
Post by: Mark Jones on October 29, 2007, 01:31:34 PM
This is an interesting idea. A friend is an avid video producer, and he uses Vegas Pro -- the newer versions of that program start with REALTIME priority, which needless to say, really locks up the computer hard. Some video renderings take a day or more to complete, so this basically means that the computer is totally useless during this time (if he forgot to change vegas.exe priority beforehand.) This is frankly, a stupid design consideration IMHO, and the vendor (Sony) has no work-around for it.

Obviously task manager is able to set a thread's priority. Perhaps it is just a matter of locating the desired thread and issuing it a SetThreadPriority,hThread,intPriority command. Details explained in Win32.hlp.
Title: Re: Program's starting priority
Post by: Ehtyar on October 29, 2007, 07:38:53 PM
I use ProcessTamer (http://www.donationcoder.com/Software/Mouser/proctamer/) for this kind of thing.

Ehtyar.
Title: Re: Program's starting priority
Post by: u on October 29, 2007, 08:25:47 PM
How about solving the problem from its roots? WMP shouldn't be taking long between songs,  so why not use another player like Winamp? Simply assign hot-keys. Mine are: Numpad5 = play/pause; Ctl+Alt+PgDown = next song; Ctl+Alt+PgUp = previous song; Ctl+Alt+End = stop; Ctl+Alt+Down = volume down; Ctl+Alt+Up = volume up.
I always have winamp5 running, and continuing to play is simply done by pressing Numpad5, regardless if I'm in-game or not. Response is immediate. (though, I consider my PC a beast with its Sempron3000+ and 1GB RAM). Btw, Winamp5 has a Priority-Class setting in its options.

I think WMP takes too long between songs, because maybe on song-end it unloads the DirectShow filter for mp3 decoding, then on song-start it loads ALL filters and asks each of them "here's the file, can you read it", then opens DirectSound, then builds an audio-graph (network) of filters around it to feed DirectSound with data. There could be a codec that you've installed, which when asked "can you read this file" does a lot of processing, or is somehow missing and Windows searches for it all around. (in ControlPanel's "Sounds and Multimedia" -> Hardware, check all audio and video codecs for their Properties, to see whether some are corrupted, remove the corrupted ones). Meanwhile, WinAmp has just a few input plugins, with filename being a criterion for "can you read this file", and they're always loaded, except for the directshow plugin which is has lowest priority.
Title: Re: Program's starting priority
Post by: Mark Jones on October 30, 2007, 06:26:42 PM
Speaking of audio players which are more customizable, check out: http://www.foobar2000.org/

The engine has separate priority controls for each step of the audio rendering process, if I recall correctly. In any case though, it plays great on my system, with zero gap between songs. (Some configuration required.)

Quote from: Ehtyar on October 29, 2007, 07:38:53 PM
I use ProcessTamer (http://www.donationcoder.com/Software/Mouser/proctamer/) for this kind of thing.

Very nice program! I'll be sure to pass that info on. This is one tool which should be in everyone's toolbox. :U
Title: Re: Program's starting priority
Post by: sinsi on October 31, 2007, 11:37:40 PM
Thanks for the ideas. I didn't really consider another player (I was looking at it purely as a programming problem - how blinkered  ::)), but I am trying winamp and foobar now.
Title: Re: Program's starting priority
Post by: sinsi on November 01, 2007, 05:46:38 AM
Mark: yes, foobar2000 is the way to go. Cheers :U

Configurable global keys...fairly small memory peak (~10M)... :bg