INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Why I Don't Use MC18.exe To Program My Remote  (Read 6898 times)

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Why I Don't Use MC18.exe To Program My Remote
« on: October 18, 2012, 10:33:17 am »

mklink c:\windows\system32\mc.exe c:\windows\system32\mc18.exe

Henceforth, always use mc.exe in your commands and shortcuts.
Logged
The opinions I express represent my own folly.

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Why I Don't Use MC18.exe To Program My Remote
« Reply #1 on: October 18, 2012, 10:59:58 am »

Like I mentioned, those tricks don't work because I use Windows Messages and have to target the actual running application executable.

If you use the launcher exclusively, then that would probably work, so long as you don't violate the other weird symlink rules on Windows.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Why I Don't Use MC18.exe To Program My Remote
« Reply #2 on: October 18, 2012, 11:26:29 am »

I realize that I didn't explain myself very well before, so maybe I should do that...  This all probably makes more sense in a separate thread, but why stop now.  If Jim feels like sorting it out, then go for it.

Why I Don't Use MC18.exe To Program My Remote:

I've found it to be slower than calling the Windows Messages directly.  The difference isn't astounding, but it is perceptible.  The difference comes down to the fact that the MC18.exe launcher is really just a wrapper for the existing Windows Messages system.

To use the launcher applet, Windows has to essentially do the following:
1. Girder calls MC18.exe /MCC something on the command line.
2. A new process is spawned and MC18.exe has to load.  Even though this process is tiny, there is still latency any time you have to spawn any new process.
3. MC18.exe calls the Windows Message (or does it internally, it doesn't matter) to direct the running Media Center 18.exe application to perform the requested command.

On the other hand, if I call the Windows Messages directly and target them at the running executable, you get to skip step #2 and they just execute.  MC responds instantly as soon as it "gets" the Windows message.  Since my remote control "application" is always loaded and running, no new application has to launch (except when I'm actually launching MC itself, for which I do use the MC18.exe applet).

The difference in practice feels much like the difference between pre-4.1 Android and iOS performance (Jelly Bean is much better on the Nexus 7, though it is still pretty bad on the ASUS Transformer Prime).

Using MC18.exe, it feels like:  Push Button - Pause - Execute
Using Windows Messages, it feels like:  Push Button - Execute

The pause is very small.  Less than a second on my HTPC, but it is there.  When you are hitting a button that cycles the display (like the Green Button command), you can very easily "get ahead" of the application with your button presses when you are using the remote, because it has to spawn a new MC18.exe and shut it down for each press of the button.  When you use Windows Messages, it leaps at your commands like it "should" (like an appliance).

So, as you can see, symlinking MC18.exe to MC.exe wouldn't work, since I don't use the launcher very much.  And you can't symlink Media Center 18.exe to Media Center.exe because the Windows Messages are looking at the names of actual, running processes on the system, not actually calling the executable itself.  If you did the symlink, the running process would still be "called" its actual name, it would just be a shortcut to load it, which wouldn't help.

What Would Help For The Future:

Two things, one decidedly more important than the other...

1. Can you guys name the real Media Center executable Media Center.exe instead of Media Center 18.exe?  This will solve 95% of my problems, because then the GML file for all of those Windows Messages wouldn't need to change.  There wouldn't be a conflict because they'd still be running from different directories.  Since I'm targeting a RUNNING application, it doesn't matter that they are in different directories (the directory path isn't in the GML, just the application name).

Of course, if you were trying to run MC17 and MC18 simultaneously and trying to target Windows Messages to one or the other but not both, then you'd have to be more prudent with your targeting, but that is an even more crazy edge-case than me.

2. Include an option in the "Custom Install" process that does essentially the symlink MrC suggested for you.  Obviously I can do this myself, so this isn't a big deal, but I think it would be nice.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Why I Don't Use MC18.exe To Program My Remote
« Reply #3 on: October 18, 2012, 11:29:33 am »

PS.  Since I already fixed my GMLs, I'm totally cool if you ignore this till MC19.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Why I Don't Use MC18.exe To Program My Remote
« Reply #4 on: October 18, 2012, 11:41:06 am »

Like I mentioned, those tricks don't work because I use Windows Messages and have to target the actual running application executable.

If you use the launcher exclusively, then that would probably work, so long as you don't violate the other weird symlink rules on Windows.

I was with you - my comment was for the other post.

I agree with you on the name change.  MC is the only app I'm running that feels it necessary to include its version number in the process name:

Logged
The opinions I express represent my own folly.

locust

  • Citizen of the Universe
  • *****
  • Posts: 699
Re: Why I Don't Use MC18.exe To Program My Remote
« Reply #5 on: October 19, 2012, 07:54:37 am »

This might be a silly question, but how to you call the Windows Messages directly.

Do you just switch C:\Windows\System32\MC18.exe in the custom commands in Media Centre for
C:\Program Files (x86)\J River\Media Center 18\Media Center 18.exe?
Logged

InflatableMouse

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3978
Re: Why I Don't Use MC18.exe To Program My Remote
« Reply #6 on: October 19, 2012, 07:58:50 am »

[offtopic] I like that screenshot MrC. Some screen capture program that does that automatically or ... ? [/offtopic]
Logged

kensn

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1362
Re: Why I Don't Use MC18.exe To Program My Remote
« Reply #7 on: October 19, 2012, 07:59:24 am »

I would like to see MC, or something of the like, to use as the process name. Would make things a bit easier.

Ken

Edit (MC was JayArrEmmCee)
Logged
If(IsEmpty([Coffee Cup]), Coffee, Drink)

Chico

  • Regular Member
  • World Citizen
  • ***
  • Posts: 136
  • Life is good!
Re: Why I Don't Use MC18.exe To Program My Remote
« Reply #8 on: October 19, 2012, 09:10:47 am »

...
I agree with you on the name change.  MC is the only app I'm running that feels it necessary to include its version number in the process name:

The problem with that may be that there are many users currently running two versions of Media Center (myself included).  The user would have to be sure that the MC call points to the correct version or be sure that there is only one version of MC installed.
Logged
JRiver Media Center... If you don't have it, I don't want to hear it!

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Why I Don't Use MC18.exe To Program My Remote
« Reply #9 on: October 19, 2012, 09:31:06 am »

The problem with that may be that there are many users currently running two versions of Media Center (myself included).  The user would have to be sure that the MC call points to the correct version or be sure that there is only one version of MC installed.

I think you misunderstand.

When you use the Automation interface of MC the "normal way" you don't call Media Center.exe at all, you use the MC18.exe launcher.  This wouldn't change (well, if they do the symlink thing, then you could use MC.exe to point to the "current" version, but the others would still be there).

Changing the name of the actual application would only impact connecting to a running instance of Media Center through an external application (like Girder).  And, it would make it better, because it would automatically work with whatever version of Media Center happened to be running at the time.

For example, in my Girder setup at home right now, I have separate GMLs loaded and active for both MC17 and MC18.  These are essentially identical in every way except that they reference Media Center 17.exe in one case and Media Center 18.exe in the other case.  That way, my remote works no matter which version I happen to have loaded at the time (I just can't start up the old version with my remote anymore, and it requires a bunch of edits to fix it).

With this change, I wouldn't need two GMLs anymore.  It would "just work" automatically with whatever version was open at that particular moment.

The only problem would be if someone was running two different versions of MC simultaneously on a system (not installed, actually open at the same time).  I don't even know if you can do that, and if you can (maybe with portable installs or something), it is probably a bad idea most of the time.  Why would you even want to do that?

For the Launcher thing (MC17.exe and MC18.exe) it would just be a symlink.  You could use it if you wanted to, or still reference the "real" MC18.exe launcher directly, if you wanted the command to be version specific.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Why I Don't Use MC18.exe To Program My Remote
« Reply #10 on: October 19, 2012, 09:43:03 am »

This might be a silly question, but how to you call the Windows Messages directly.

Do you just switch C:\Windows\System32\MC18.exe in the custom commands in Media Centre for
C:\Program Files (x86)\J River\Media Center 18\Media Center 18.exe?

No.  It doesn't work like that at all.  Windows Messages are one way for different applications to communicate between each other through the Windows API.

I use Girder to do it, though there are other little tools you can use.

If you are writing an application, you do it using the SendMessage functions in the Windows API.    If you want to do the same thing without writing an application specifically for it, you can use a tool like SendMessage.exe from the Sage folks.

Doing that for Media Center would be silly, though, as that's essentially exactly what the MC18.exe launcher does.  It is a MC-specific wrapper for the available MC API calls.  Loading SendMessage.exe wouldn't be any quicker than loading MC18.exe (and probably slower because I trust Matt more), and the commands are harder to set up.  Using the external application can be handy for controlling a program that isn't as nice as MC and doesn't have the little launcher tool (like iTunes for example).

Girder has this capability built in.  You can send messages to any other application currently running on the system.  The reason it is faster when you are using a program like Girder is because Girder is already running, so Windows doesn't have to launch a new process and allocate memory to it, only to "destroy" the process a microsecond later after it sends its message.

Other utilities similar to Girder probably also have this function built-in (like AutoHotKey), but I haven't used them, so I'm not sure.

PS.  I should add... I don't know that they actually use SendMessage to communicate between MC18.exe and the running instance of Media Center.  In fact, I'd guess they don't.  Since they control both applications, and they implicitly trust both, they can do it a much cleaner way internally.  It doesn't matter, the principle is the same.  Loading a separate process and allocating memory to it, and then destroying it afterwards, for each command in a sequence, adds latency.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

locust

  • Citizen of the Universe
  • *****
  • Posts: 699
Re: Why I Don't Use MC18.exe To Program My Remote
« Reply #11 on: October 19, 2012, 09:57:49 am »

Oh I see

I thought you were meaning to change the MC17.exe to Media Center 18.exe in the custom runs internally in Media Center.

Would it then make a difference for users that have remote controls to have to ability to set MC17.exe to stay permanently in memory?
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Why I Don't Use MC18.exe To Program My Remote
« Reply #12 on: October 19, 2012, 10:36:03 am »

Would it then make a difference for users that have remote controls to have to ability to set MC17.exe to stay permanently in memory?

No, that wouldn't help.  I don't think the architecture of the system is set up that way at all, in the first place.  And, secondly, if you want to do that, you already can, by setting it up the way I explained above (using SendMessage instead of calling the MC18.exe applet at all).

I don't think there would be a substantial difference in latency between calling MC18.exe for a MCC command, and calling Media Center.exe directly.  It is the "Windows Part" of the sequence that creates the latency (executing a command of any kind).  It might even be slower because the Media Center.exe executable is bigger, and Windows still would be executing it and loading it, only to then connect to the running instance and shut the command down.

In other words, it is the "going out to the command line" part that slows it down.  There's no way around that other than to use direct interprocess communication.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Why I Don't Use MC18.exe To Program My Remote
« Reply #13 on: October 19, 2012, 12:16:25 pm »

[offtopic] I like that screenshot MrC. Some screen capture program that does that automatically or ... ? [/offtopic]

A capture program.
Logged
The opinions I express represent my own folly.

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Why I Don't Use MC18.exe To Program My Remote
« Reply #14 on: October 19, 2012, 01:10:20 pm »

+1000 to Snagit.  And Camtasia Studio as well.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

locust

  • Citizen of the Universe
  • *****
  • Posts: 699
Re: Why I Don't Use MC18.exe To Program My Remote
« Reply #15 on: October 19, 2012, 06:06:22 pm »

Do you know if there is any way to make MCC_SET_LIST_STYLE work in theatre view? It would be much more useful.
Logged
Pages: [1]   Go Up