Unable to Retrieve IMFAudioPolicy from Media Session - c++

I have developed Win32 app based heavily on the MF_ProtectedPlayback sample here. I'm using 4 cplayer objects at a time. It works for what I need it to do.
However, I am trying to group the sessions, so that they are controlled by one volume control in control panel, as described in docs here.
My problem is that I cannot get the IMFAudioPolicy (MR_AUDIO_POLICY_SERVICE) from the session. As in the sample, I'm using the MFCreateAudioRendererActivate() method to create the renderers. Again, this all works fine. I have no problem getting other interfaces back from the session, like IMFSimpleAudioVolume.
I get the following errors:
-onecore\com\combase\dcomrem\call.cxx(4907)\combase.dll!75EB0755: (caller: 75E931D8) ReturnHr(3) tid(7e60) 80040155 Interface not registered
-Exception thrown at 0x773DA892 (KernelBase.dll) in MyApp.exe: 0x80040155: Interface not registered.
Relevant code:
HRESULT CPlayer::OnTopologyReady(IMFMediaEvent* pEvent)
{
\\ works fine
MFGetService(
m_pSession,
MR_VIDEO_RENDER_SERVICE,
__uuidof(IMFVideoDisplayControl),
(void**)&m_pVideoDisplay
);
\\ works fine
MFGetService(
m_pSession,
MR_POLICY_VOLUME_SERVICE,
__uuidof(IMFSimpleAudioVolume),
(void**)&m_pSimpleVolume
);
// winrt errors, returns null
MFGetService(
m_pSession,
MR_AUDIO_POLICY_SERVICE,
__uuidof(IMFAudioPolicy),
(void**)&m_pAudioPolicy
);
HRESULT hr = StartPlayback();
return S_OK;
}
What am I missing? Any ideas why this interface is not available? Thanks...
-jerry
edit: so it appears that what I want to do may not be possible. This problem is related to the protected processes created in PMP. Still investigating...

Related

Connecting to Mobile Network via Mobile Broadband API

I am trying to connect to a mobile network via a modem and a sim card. Every time I try to set the APN String and User Credentials in a Context via SetProvisionedContext() I get the E_INVALIDARG HRESULT.
As Parameters I used an Instance of MBN_CONTEXT, a wchar_t* in form of &std::vector<wchar_t>[0], and a ULONG*.
MBN_CONTEXT context;
std::vector<WCHAR> apnVector;
inParamAPN.GetCString(apnVector);
std::vector<WCHAR> userNameVec;
inParamUsername.GetCString(userNameVec);
std::vector<WCHAR> passwordVector;
inParamPassword.GetCString(passwordVector);
context.contextID = MBN_CONTEXT_ID_APPEND;
context.contextType = MBN_CONTEXT_TYPE_INTERNET;
context.accessString = &apnVector[0];
context.userName = &userNameVec[0];
context.password = &passwordVector[0];
context.compression = MBN_COMPRESSION_NONE;
context.authType = MBN_AUTH_PROTOCOL_PAP;
and later when I have the IMbnConnectionContext:
std::vector<WCHAR> providerVector;
InParamProvider.GetCString(providerVector);
ULONG requestID;
contextInterface->SetProvisionedContext(context, &providerVector[0], &requestID);
So my Question is: Which Parameter does the WinAPI have a Problem with, and how can I fix it?
Also any Tips of additional Sources for Information are appriciated.
All I have so far are the official MSDN and the Code Example contained in the Windows 7 SDK. Are there any further sources of Information I am not aware of? A google search didn't yield the hoped for results.
In the end I did not get it working as it should. I used the second way of connecting to a custom APN, by making a new connection profile. For this I used a XML filled with the Values I needed.
Along the way I encountered another problem with an unforseen Error Code which I described here.
Best regards,
Stefan

Windows RPC object marshalling

I'm trying to use Windows RPC for communcation between two processes (C/C++, 32bit, Win7).
I've followed the example here Instruction to RPC and successfully got RPC to work. Now I have difficulties getting the proxy / stub thing to work too.
The IDL file looks like this:
[ uuid(3cb112c0-688a-4611-83b6-31d33d87ea28), object ]
interface IDemo : IUnknown
{
HRESULT ThisIsAMethod([in, string] const char* test);
}
[ uuid(60ad6a21-ba49-483a-b0a2-faa5187b8299), version(1.0),
implicit_handle(handle_t hDemoBinding)]
interface IDemoRPC
{
void SimpleTest();
void GetDemo([out] IDemo** service);
void Shutdown();
}
I can invoke SimpleTest() remotely on the server from the client. Works just fine. But GetDemo() gives me an access violation when the server 'returns' something else than NULL.
Here's what I've done:
Build a DLL based on the generated demo_i.c, demo_p.c, dlldata.c. With REGISTER_PROXY_DLL set and a def file containing the five private entries. I've registered it with regsvr32 (the one from WOW64).
Created a DemoImpl class in the server process that extends IDemo and implements ThisIsAMethod as well as AddRef and friends.
Implemented GetDemo(IDemo** service) with a one-liner *service = new DemoImpl();
When I invoke GetDemo from the client process, the server process terminates with an access violation (0x00000014). The stacktrace shows that it happens in a separate thread deep within rpcrt4.
I would have expected that the thing returns a proxy to the client.
I have the suspicion that I'm doing something fundamentally wrong here. For one thing, I can't find an example where instances of interface-objects are created with new. There always some some magic with CoGetClassObject or something. No clue how these functions should know where to find the implementation.

InvokeHelper() throws Access is denied exception

Community, I have quite interesting and in the same time heavy problem.
I have VB .NET application + Service + C++ application. C++ application generates some data and makes callbacks using InvokeHelper() method:
InvokeHelper(0x60030000, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
eventType, eventValue);
The first parameter is the dispid of method which should be called. Strange approach, but this is not my code and I can not change this way.
In service I have method marked by dispid attribute to get this callback from C++ application.
<DispId(&H60030000)>
Public Sub ServerEvent(ByVal vEventType As Integer, ByVal vEventValue As Object)
RaiseEvent ControlPanelStateChange(vEventType, vEventValue)
End Sub
This code works correctly if I logged on as admin. But if windows user has not administrator permissions, right after calling InvokeHelper() method the next exception occurs:
First-chance exception at 0x75B7C42D (KernelBase.dll) in application.exe: 0x80070005: Access is denied
Do you have any ideas? I have played with DCOM permissions, but result is the same.
Any help would be fantastic!
The solution of the problem is:
DCOMCNFG, right click on the My Computer and select properties -> COM Securities tab -> Access Permissions -> click Edit Defaults and add Network Service to it and give it Allow local access permission. Do the same for < Machine_name >\Users.
Then -> Launch and Activation Permissions, click Edit Defaults and add Network Service to it and give it Local launch and Local Activation permission. Do the same for < Machine_name >\Users.

ROT registration does not work with adobe 11 installed

I have code that we've been using for years with PDFs, HTML docs, and XBRL docs. The code is called from either a BHO in IE, or an Adobe plugin in Reader. It registers a moniker in the ROT, and creates a signalling event.
We've been trying to upgrade from Adobe 9 to Adobe 11, and the debugging the code, it simply fails to register the moniker in the ROT. It works if called from an Adobe 9 plugin, and if called from the BHO. But simply upgrading to Adobe 11 is enough to make it start silently failing.
The code in question is below:
void CLocatorRegistration::Register( ISourceLocator* pLocator, long nKeyFile )
{
HRESULT hr;
CComPtr<IRunningObjectTable> pROT;
CComPtr<IMoniker> pmk;
CComBSTR bstrName;
// access the ROT
pROT = GetROT();
// create the moniker
pmk = CreateMoniker( nKeyFile );
// put this object in the ROT.
_ASSERTE( !m_bRegistered );
->>hr = pROT->Register( ROTFLAGS_REGISTRATIONKEEPSALIVE, pLocator, pmk, &m_dwROTCookie );
if FAILED(hr)
throw hr;
m_bRegistered = true;
// create the event and signal it, to support notification to any callers that this object
// is now available to connect to
CreateEventName( nKeyFile, bstrName );
m_hEvent.Attach( ::CreateEvent( NULL, TRUE, FALSE, bstrName ));
::SetEvent( m_hEvent );
}
The highlighted line is the ROT registration, and the return is S_OK. Does anyone have any idea why the method would succeed, but the entry not be placed into the ROT?
The problem that I found in researching this was the fact that Adobe 11 includes a new sandboxed protected mode setting. When developing a plugin, it no longer by default has access to the OS.
For our purposes it was quite simple just to disable this setting, as this is for an internal application. There are a lot of other ways to accomplish this, but we didn't look into them because of time constraints.

Debug Assertion Failed Expression: GetInterface()!=0 error when writing to database table

Im working on a MFC project which communicates specific table on my SQL Server. But when I try to make delete query I get Debug Assertion Failed error message at runtime and also nothing is deleted when I check my table.
This is the code where I think the error is:
<pre> HRESULT hr;
hr=COLEDBTESTSetAccessor::OpenDataSource();
if(FAILED(hr))
MessageBox(NULL,"Connection Failed\n","",MB_OK);
else
MessageBox(NULL,"Connected\n","",MB_OK);
CString strString;
strString.Append("DELETE FROM PHONE_NUMBERS WHERE ID=");
CString strParam;
strParam.Format("%d",nId);
strString.Append(strParam);
MessageBox(NULL,(LPCSTR)strString,"",MB_OK);
hr=this->Open(m_session,strString); <code>
The same also happens with Update and Insert Query but the table records are updated.
Can anyone tell me where is my mistake?
Thank you. :)
I can not see from what base class you derive you class. I assume you have a Command object.
So what happens is that you already performed an operation with an Open call. But after an open you need a Close operation before you can use the command again with a new statement and Open operation.
Look at the m_spCommand member.