Quicksync not available to a service process?

Quicksync not available to a service process?

Portrait de karl_lillevold

We have been using a simple MFXInit() to test of Quicksync is available, but I now realized that when we run our program as a service, the very same MFXInit() always fails. That leads me to believe Quicksync (or any is not available to a Windows service... 

Much to my disappointment, I found this thread : http://software.intel.com/en-us/forums/topic/311956, which leads me to indicate there is no solution for this problem, with graphics drivers not available to "session 0" .. (I have no experience with Windows services - others have worked on that part in our project). Very unfortunate - we relied on Quicksync for much improved transcoding performance.

-Karl L.

39 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.
Portrait de Sergey Kostrov

>>...when we run our program as a service, the very same MFXInit() always fails...

Could you add a call to Win32 API function GetLastError just right after the call to MFXInit? What is an error code?

Also, it is Not clear how you've created that Windows service with CreateService Win32 API function.

Portrait de Tony Pabon (Intel)

Hi,
Just to clarify, the limitation of execution as a service was due to D3D9 architecture requiring a display to render (which requires a logged in user). D3D11 architecture does not have this limitation. Please make sure that your application is built with latest Media SDK, is running on a platform that supports D3D11.1 (Windows 8), and does not use any API that require a display.

When the session is initialized for hardware acceleration, if D3D11 is not available on the platform, no graphics accelerated rendering will be available.

-Tony
Portrait de karl_lillevold

Thanks for your reply, Sergey. It seemed clear from the thread I pointed to, services in session 0 do not have access to the necessary APIs (DirectX), which unfortunately QuickSync relies on. In any case, the error is MFX_ERR_UNSUPPORTED (-3). I guess my question really was more of a statement, expressing my frustration after having spent time and effort implementing a wickedly fast QuickSync based encoder, then having it blocked by this problem. 

Portrait de karl_lillevold

Thanks, Tony. I read those threads as well, but Windows 8 marketshare at 3.17% is not our target. -Karl.

Portrait de Sergey Kostrov

Karl,

A Windows Service could interact with a Desktop, could display UI ( rendering ), interact with Tray Notifications ( lots of things! ). But you need to properly initialize your Service. How did you initialize the Service with CreateService Win32 API function?

Portrait de karl_lillevold

I am not working on that part of our code, but I will ask. It's running in session 0 and has no access to the required APIs, just like the thread describes as well as Tony writes above, where he also states it is possible on Windows 8, but not Windows 7. As there was no solution posted the thread I mentioned, I am curious what you are suggesting, that the good folks at Intel do not know about?

Portrait de karl_lillevold

[deleted - duplicate post]

Portrait de karl_lillevold

Argh, I just wrote another reply, and it was lost...

I wrote that we our service is a system service running for all users, and when no one is logged on. We have a separate per user systray notification exe, as well as an explorer shell extension. These three communicate via indirect means some of which are described here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms683502(v=vs.85).aspx. I guess the service could farm out encoding jobs to the systray app, in theory, but the communication would be awkward, but most importantly it would only work when someone is logged on and the systray running.

Portrait de iliyapolak

IIRC windows services run under various accounts like local sytem ,user account or network service and these services are pinned to non-visible window station.Session Zero further restricts the services from interacting directly with the desktop.I have been able to find that this parameter "SERVICE_INTERACTIVE_PROCESS" must be present in service's registry key TYPE parameter.Service which run under user account can not be marked as a  interactive.

Portrait de Sergey Kostrov

>>...I guess the service could farm out encoding jobs to the systray app, in theory...

A set of Win32 API functions that control Windows Services and Access RIghts ( they are more than 15-year-old ) are designed for practical applications on WIndows NT-like platforms and I don't see any reasons for theoretical discussions.

Portrait de karl_lillevold

iliyapolak: Are you describing the "Allow service to interact with desktop" in the Log On tab for service properties? I tried this, and it makes no difference for Quicksync availability. I was also told "It's a deprecated option for interop with very old services".

Sergey: I agree, I am not discussing theory. My point was we cannot use a lightweight traybar app for encoding, when we need encoding services to run without a user being logged on. I am still awaiting an answer to how you are suggesting this can be solving in practice.

Portrait de karl_lillevold

[deleted - another duplicate]

Portrait de Tony Pabon (Intel)

Microsoft's solution for "graphics device" usage from a service has been the creation of D3D11 (a.k.a. DX11).  We understand this forward progress does not solve limitation in Microsoft's architecture for older platforms.

To clarify, issue on DX9-based platforms is more then just session 0 running without a user, it is 'access to graphics device acceleration' while running without a user.

-Tony

 

-Tony
Portrait de karl_lillevold

Thanks, Tony, for clarifying. I am pretty sure I understand the situation on Windows 7. It is unfortunate, but an architetural/design limitation imposed by Windows DX9. We do not have time to focus on Windows 8 at the moment, but will keep that, and Quicksync in mind, for later.

Portrait de iliyapolak

No I was referring to registry settings.Can you look at your service registry settings if the TYPE parameter is present?

Portrait de iliyapolak

I suppose that services which are "pinned" to invisble window will not have or allow an access to graphics hardware.

Portrait de karl_lillevold

Thanks, iliyapolak, but I think Tony from Intel clarified the situation well. In Windows 7 with DX9, Quicksync is not available while running without a user. In Windows 8 with DX11, Quicksync and graphics device acceleration is available.

Portrait de iliyapolak

Hi Karl,

what is the situation when DX11 is installed on Win7?

Portrait de karl_lillevold

I don't really know. I can only refer to what Tony from Intel just wrote: it requires D3D11 and Windows 8. I can only guess that Microsoft does what they usually do, and which I have been running into with their Media Foundation encoders and decoders: all the nice features require Windows 8 :( even though the basic functionality is there on Windows 7.

Portrait de iliyapolak

Sad but this is the reality when you need to deal with  Microsoft and when their newest OS is released.

Portrait de Sergey Kostrov

>>...I am still awaiting an answer to how you are suggesting this can be solving in practice...

Karl,

Windows NT Services are designed to work as the background processes and in order to help you I requested ( already twice ) a list of parameters ( arguments ) used in CreateService Win32 API function. Could you or a developer who works on these codes post it?

Portrait de karl_lillevold

Sergey: Thanks for trying to help, even when the Intel expert has posted it is impossible with Windows 7. So here you go:

CreateService(
schSCManager,
pServiceName,
pServiceName,
SERVICE_ALL_ACCESS,
dwServiceType,
dwStartType,
SERVICE_ERROR_NORMAL,
pExePath,
NULL,
NULL,
NULL,
NULL,
NULL);

Portrait de iliyapolak

@karl
Can you check the registry settings of your service?Please look for this value "SERVICE_INTERACTIVE_PROCESS".If this value is present your service will be pinned to visible window station.

Portrait de karl_lillevold

According to http://msdn.microsoft.com/en-us/library/windows/desktop/ms683502(v=vs.85).aspx : "Important  Services cannot directly interact with a user as of Windows Vista. Therefore, the techniques mentioned in the section titled Using an Interactive Service should not be used in new code."

The SERVICE_INTERACTIVE_PROCESS flag is mentioned in the Using an Interactive Service.

Portrait de iliyapolak

Here is the excerpt from the article mentioned by you

"The NoInteractiveServices value defaults to 1, which means that no service is allowed to run interactively, regardless of whether it has SERVICE_INTERACTIVE_PROCESS. When NoInteractiveServices is set to a 0, services with SERVICE_INTERACTIVE_PROCESS are allowed to run interactively."

Portrait de karl_lillevold

Before that, like I already quoted:::::: : "Important  Services cannot directly interact with a user as of Windows Vista. Therefore, the techniques mentioned in the section titled Using an Interactive Service should not be used in new code."

Anyway, the SERVICE_INTERACTIVE_PROCESS_FLAG corresponds to the same checkbox as is located in the Log On tab of a service property, which I asked you above. So now I tried both methods - setting it in the registry -> modifies the check box. Setting the check box -> modifies the registry. So to answer my own question: Yes, this flag and that checkbox is the same.

And to re-iterate: I tried that already (tried again now), and the result is the same I wrote above: "Are you describing the "Allow service to interact with desktop" in the Log On tab for service properties? I tried this, and it makes no difference for Quicksync availability. I was also told "It's a deprecated option for interop with very old services"."

Portrait de karl_lillevold

The only alternative, as I suggested above, which is possible when a user is logged on and has our systray app running, is to transmit the encoding parameters to the systray using IPC (named pipes), to have it start our encoding process. It's a little messy, and prone to errors, if for instance users log off mid-encoding, but with Quicksync's amazing encoding speed, may be worth the effort when we have time.

Suggestion to Intel: you should create something like Lucid's Virtu (http://www.lucidlogix.com/product-virtu-gpu.html) , which I use on my home system. How it works, I don't know, but it allows Quicksync to be used with a discrete graphics card installed.

This, however, would be some kind of user space process with a defined API in your SDK, which transmits the function calls via IPC to that user process, that would allow Quicksync to be used by services on Windows 7. I already applied for a patent ;) Probably not possible or viable though, just speculating on something I have only brief knowledge about.

Portrait de Sergey Kostrov

Thanks, Karl.

>>...
>>CreateService(
>>schSCManager,
>>pServiceName,
>>pServiceName,
>>SERVICE_ALL_ACCESS, - [ SergeyK ] This is what I wanted to see
>>dwServiceType
>>...

What flags do you set for dwServiceType argument?

PS: Take into account that information on MSDN ( after two updates during last a couple of years ) sometimes is Not reflecting realities (!). For example, you could read that some feature is Not available and actually that is Not correct and the feature is available, and so on.

Portrait de karl_lillevold

Sounds like we are back to the service type flag, as iliyapolak has already suggested. We have tried SERVICE_INTERACTIVE_PROCESS, as a flag to CreateService, setting it via the registry, and setting the checkbox. These three appear to be identical in their function, and for Quicksync, also tested all three variations thereof, makes zero difference.

Portrait de karl_lillevold

{{Off topic: just posted a reply, it was queued for approval. Why are some replies posted immediately, some queued for approval? This is why I ended up with duplicates...}}

Portrait de Sergey Kostrov

Karl, if your post doesn't appear after a couple of hours please post it again. Thanks in advance.

Portrait de karl_lillevold

I didn't save it, and won't retype it. I am sure it will show up.

Portrait de Sergey Kostrov

Karl, I'd like to clarify one thing.

>>>>...Could you add a call to Win32 API function GetLastError just right after the call to MFXInit? What is an error code?
>>
>>...In any case, the error is MFX_ERR_UNSUPPORTED ( -3 )...

The error code MFX_ERR_UNSUPPORTED doesn't look like an error ( it is negative! ) from GetLastError Win32 API function. It looks like the error code from MFXInit function.

GetLastError always returns positive error codes (!).

Would you be able to get the error code from GetLastError Win32 API function? This is what needs to be done:
...
MfxErrorCode = MFXInit();
LastErrorCode = GetLastError();
...

Portrait de karl_lillevold

As you know, the MFX error is MFX_ERR_UNSUPPORTED (The function cannot find the desired SDK implementation or version.)

The corresponding GetLastError is ERROR_MOD_NOT_FOUND 126 (0x7E) The specified module could not be found.

This seems like a logical match to me. When not run as a service there are no errors.

{{I am still waiting for my other reply to be approved, but the summary is that the parameter you asked about to CreateService: I tried OR-ing with the same deprecated (since Vista) SERVICE_INTERACTIVE_PROCESS flag 0x00000100 discussed above, and the effect is the same. The registry gets the flag ORed in, and the Log On Interactive check box gets marked. So three ways to set the same parameter, neither of which has any effect on the Quicksync availability - return code from MFXInit}}

Portrait de iliyapolak

>>> I tried OR-ing with the same deprecated (since Vista) SERVICE_INTERACTIVE_PROCESS flag 0x00000100 discussed above.>>>

I did not know that this flag is deprecated.My source of information did not state that clearly.

Portrait de Sergey Kostrov

>>...The corresponding GetLastError is ERROR_MOD_NOT_FOUND 126 (0x7E) The specified module could not
>>be found...

That error is related to LoadLibrary or LoadLibraryEx Win32 API functions. Could you verify with MS Depends all dependant modules?

Also, consider the following:

- Issue with User Account Control ( UAC ) attribute ( look at Visual Studio project settings )
- Problem with Policies ( take a look at UI application for setting Policies on a Windows )
- Access Rights issues for your Windows Service

Portrait de karl_lillevold

Look, guys (Sergey and iliyapolak): While I do appreciate your attempts at help, the Intel expert has stated access to Quicksync is impossible from services under Windows 7. I have done what I can to satisfy your requests for more information, but frankly, I don't see the point in continuing this exercise in futility. 

Portrait de iliyapolak

Hi Karl,

it seems that nothing can be done.

Connectez-vous pour laisser un commentaire.