Media Foundation IMFMediaSource::CreatePresentationDescriptor invocation never ends - audio

I'm triying to use Media Foundation to play mp3 file and I have a problem getting PresentationDesctiptor using CreatePresentationDescriptor method
What am I doing:
Start MF using MFStartup
Create session using MFCreateMediaSession
Create SourceResolver using MFCreateSourceResolver
Create MediaSource using CreateObjectFromURL from SourceResolver
Create topology using MFCreateTopology
Trying to create PresentationDescriptor using CreatePresentationDescriptor from MediaSource
When I call CreatePresentationDescriptor no error/exception occurs it just stands there and does nothing. When I pause Visual Strudio it indicates that program is still waiting for method to finish. What am I doing wrong ?

I did not metion that I use C# for this (did not think this was relevant)
The problem was that when importing com interfaces in C# you need to import all methods of interface not only those that are called. Some methods can call not imported methods and cause Access Violation that is not reported to Visual Strudio debugger and as a result it seems like method is never finished invokink.

Related

Robot Framework - Use Listener to interrupt Execution

I'm currently implementing a way to manage execution of a test in robot framework using using tkinter and the builtin listeners.
I was able to make a Pause/Resume system relatively easily but I'm unable to make a Stop system.
In the RobotFramework UserGuide there is an example to insert keywords in test cases like this:
ROBOT_LISTENER_API_VERSION = 3
def start_test(test, result):
test.keywords.create(name='Log', args=['Keyword added by listener!'])
The issue is, that this is deprecated and doesn't work. I have the following error when trying to use this :
UserWarning: 'keywords' attribute is read-only and deprecated since Robot Framework 4.0. Use 'body', 'setup' or 'teardown' instead.
I don't know how to use Body setup or teardown to do what I want and I was unable to found any example similar to the deprecated one
Apparently I needed to ask the solution to find one by myself
So I just needed to make something like this :
test.setup.config(name="Fatal Error", args=["Force Quit"])
or
test.teardown.config(name="Fatal Error", args=["Force Quit"])

Does the Windows shell support multiple shell property handlers?

I was just trying out the Windows app sample for the Recipe Property Handler which is available here and I modified it to be used on .doc files instead of .recipe files:
const WCHAR c_szRecipeFileExtension[] = L".doc";
But, this seemed to overwrite the previous Office handler's properties with itself, which begs the question, does the Windows shell support multiple shell property handlers, or can you only use one at a time for a given file type? If its possible, what am I missing from the code or logic in the sample?
I couldn't find a concrete answer on MSDN for this question.
No.
But there is a variant you can use (I dont like it but I dont see any additional variant). Save previous Property handler CLSID when you register your own. And when shell request the property that you cannot process - just create instance of previous handler and pass request to them.
CoCreateInstance(SavedCLSID, nil, CLSCTX_INPROC_SERVER or CLSCTX_LOCAL_SERVER, IPropertyStore, PS)
PS.QueryInterface(IInitializeWithStream, IWS)
IWS.Initialize(Stream, Mode)
PS.GetValue(AUnknownKey)

Dynamics AX 2012 - Custom Lookup in a dialog

So, I am working on a class called DMFWriteExportData and trying to get it run in Batch.
I am at a point where I need to figure out a way to get rid of fieldControl and the reason being it does not let me Run the class on the server and throws an error because it is not supposed to be running on server? (not sure)
Error: "The method Dialog Control.control cannot be called from the server; use methods on the Dialog Field class instead."
-
public Object dialog()
{
DialogRunbase dialog = new DialogRunbase("#DMF372", this);
FormStringControl control;
dialogExecution = dialog.addFieldValue(extendedTypeStr(dMFExecutionId), executionId);
control = dialogExecution.fieldControl();
control.mandatory(true);
control.displayLength(24);
control.registerOverrideMethod(methodstr(FormStringControl, lookup), methodstr(DMFWriteExecutionParameters, executionIdLookup), this);
control.registerOverrideMethod(methodstr(FormStringControl, modified), methodstr(DMFWriteExecutionParameters, executionIdModified), this);
dialogdescription=dialog.addFieldValue(extendedTypeStr(description),DMFExecution::find(executionId).Description);
dialogdescription.enabled(false);
return dialog;
}
I am wondering:
If it is actually true that this class cannot be set to server
when using control.registerOverrideMethod
If yes, what would be the ideal solution to overcome this situation,
is there any way I can create custom lookups? I see there is method
called registerOverrideMethod in the DialogField class.
Any help would be appreciated.
Thanks,
Khosla
The reason why you cannot (and should) run the code above in batch is because it uses dialog controls that only exist on the client side. You should never run this kind of code on server. Please check runon property of your class and set it to called from.
However, I assume you are using RunBaseBatch. If you are on AX 2012, you should use the SysOperation framework instead.
When using RunBaseBatch, all code is on the same class. This way, you are mixing client side code (main method, dialog method etc) with the code that should run on server (run method). For this reason you should set the "runon" property of the class to CalledFrom, not Server.
You can solve this by using SysOperation which applies the Model View Controller (MVC) pattern that neatly sepperates the two.
For an introduction to SysOperation, check my blog here:
AX2012: SysOperation introduction

OpenSL ES slCreateEngine causes error

I have an OpenSL ES function call that causes no problems in one application, but causes a problem in another application, both run on the same device.
The line is:
result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
Where result is of the type SLresult, engineObject is of the type SLObjectItf
The error I seem to get is:
05-19 11:56:27.007: ERROR/libOpenSLES(1425): slCreateEngine while another engine 0x299fa0 is active
It seems this is not logged from my code, but maybe it is caused by it? So what could cause this line to produce an error in one app, but not in the other?
As it happens to be, it was partly Android's Activity life-cycle which caused the error, but mostly my own fault. It was caused by the onCreate() and onResume() methods Android provides for an Activity. I never thought of the fact that onResume() also get's called when an Activity is started. Because of this, I never realized that I had a 2nd call to the slCreateEngine function.....
According to the docs "OpenSL ES for Android supports a single engine per application". I had a quick check of the source for OpenSL an I can see this is enforced by a global storing the current active engine.
So if you want to call slCreateEngine, you must make sure all other engines have been destroyed first. This includes the possibility of any 3rd party code you are linking in too (incase you are linking in something else that is creating an OpenSL engine object before you do).

C++ MultiThreading with visual studio express 2010 Forms Application

I am developing a Windows forms application which connects to a piece of hardware, acquires a lot of data (~1 GSample/sec), processes it, and spits it out to the screen upon a button click. I am now trying to automate the process in a loop that can be started/stopped at any time so I can monitor it whilst tweaking the input to the acquisition hardware. I thinks it's clear that I need to do this on a separate thread, but I'm having a heck of a time trying to do this in c++/cli - I have found a number of good examples using MFC, which is not supported by Express.
Specifically: My task is to press a button which is handled in Form1.h, to call a function in my main file Acquisition.cpp which contains the following code (currently an infinite loop)
void Form1::realTimeUpdate()
{
// live is a boolean variable set by a button on the form
while(live)
{
displayVariance(getVar(getQuadratures(100),nbrSamples));
}
}
I wish to execute this code in a separate thread so that the main program can listen for the user request to stop the operation. Without threading, I currently have to forcefully quit the program (or set it to run a fixed number of times) to stop it.
Is there any suggestions how I might go about running this code on a separate thread?
I've (unsuccessfully) tried a few things already:
Modifying the example given in This Microsoft Example. Problem: requires /clr:oldSyntax option which is incompatible with the other 1300 lines of code in the program.
Trying to do what I'd do in Java (Declare a global thread and start/stop it from any point in the code. Problem: Compiler won't let me declare a global System::Threading.Thread
this beautiful example. Problem: Requires MFC.
Any suggestions would be greatly appreciated!
You can use a BackgroundWorker or a Thread to handle this. You'll need to make sure that the portion of your work that updates the UI is marshaled back to the UI thread, however.
Here is a tutorial on threading in C++/CLI.
For the record, upon Reed's suggestion about using a BackgroundWorker, I sifted through the code at the bottom of this page and modified my code so that:
It created a new backgroundWorker BGWorker in which BGWorker->DoWork() called my realTimeUpdate() function.
A button on the main Form calls either RunWorkerAsync() or CancelAsync() depending on whether or not the process is running (checked by a boolean flag in my main program).
The realTimeUpdate() function is now passed a BackgroundWorker - realTimeUpdate(BackgroundWorker^ worker, DoWorkEventArgs ^ e) After each calculation is complete within the internal loop, it calls worker->ReportProgress(result) function. In the BGWorker->ProgressChanged() function a separate function, upDataUI(int) draws the result on the main form.
Thanks again for the help.

Resources