View Full Version : ML Capabilities

07-20-2004, 03:24 PM
Dear Fabrice
I am writng a program that captures all the capabilities of OpenML ML.
but when i write the folowing lines i receive a RUN-TIME error.
MLpv* JackType = mlPvFind( JackCap, ML_JACK_TYPE_INT32 );
printf( "Type of this jack is %s\n" ,(char *)(JackType -> value.int32));
notice that the jack is available-this is the input or output jack.
also the following lines create a RUN-TIME error:
MLpv* Version = mlPvFind( deviceCap, ML_DEVICE_VERSION_INT32 );
printf("Version of this physical device is:%s\n",Version > value.int32 );
notice that many of the capabilities are work good.as an examples when i write the following code there is no error.
MLpv* DeviceName = mlPvFind( deviceCap, ML_NAME_BYTE_ARRAY);
printf( "\nThe name for device %i is %s\n", i, DeviceName ->value.pByte );

I'm looking forward to hear your instructions.
Best regards

[ July 20, 2004: Message edited by: ehsan2004 ]

07-21-2004, 03:30 PM
Dear Ehsan,

in an MLpv list, 'value.int32' is an MLint32. You can not print it as a string. You must print it as an int -- use '%d' rather than '%s' in your printf.

Notice that the examples that do work use 'value.pByte'. This is a 'char*', so you *can* use '%s'. See the ML header files for the details on the MLpv structure.

07-23-2004, 01:27 AM
Hello Fabrice
My problem solved.thus,each type of jack has an index.as an example i think that ML_JACK_TYPE_AUDIO has index 0. but now a question about ML_PRESET_MSG_ARRAY that is part of the path logical device capabilities.I don't know that how i can use from this feature in my program-i don't know that how i can see the "param" feature of each MLpv object that is received using the ML_PRESET_MSG_ARRAY.can you write a code for me to does that.

another problem is about the following lines that produce a run-time error.
MLpv* JackFeatures = mlPvFind( JackCap, ML_JACK_FEATURES_BYTE_ARRAY );
printf( "Jack features: %d\n" ,(char *)(JackFeatures -> value.pByte));

Notice that it also happens when i use from %d, %f or %i without using the (char*).


07-27-2004, 03:25 AM
A 'value.pByte' is a 'char*'. You do not need to explicitly cast it. However, you also may *not* print it out with '%d'. You must use '%s'.

Note that you should also check if the specified capability was found -- if it wasn't found, the function will return a NULL pointer, and you will get an error trying to dereference it.

10-05-2004, 09:59 PM
for the following jack capabilities, i receive a run-time error. note that for other jack capabilities such as ML_JACK_PATH_IDS_INT64_ARRAY, i don't receive a run-time error. please suggest me.

MLpv* JackOptionParamIds = mlPvFind( JackCap, ML_OPEN_OPTION_IDS_INT64_ARRAY );
printf( "Number of optional PARAMs in this jack: %llx \n", JackOptionParamIds->length );

MLpv* JackResolution = mlPvFind( JackCap, ML_JACK_COMPONENT_SIZE_INT32 );
printf( "Maximum number of bits of resolution per component for the signal through this jack: %d\n",JackResolution -> value.int32);

MLpv* JackFeatures = mlPvFind( JackCap, ML_JACK_FEATURES_BYTE_ARRAY );
printf( "Jack features: %s\n" ,JackFeatures -> value.pByte);

10-14-2004, 12:08 AM
In responsing to my question, Fabrice wrote that:

I've looked through the message thread on the Forum -- am I correct that the
problem here is the failure of the 'mlPvFind' calls?

As I mentioned before, Ehsan, you should *always* check the return value of the
mlPvFind(), to make sure it isn't a NULL pointer. It is possible that the
property you are querying is not supported by that particular device/jack -- in
which case mlPvFind will return NULL. Thus, before using the pointer, you must
check it.

Could you please add that code to your test program and see what happens?


[ October 14, 2004: Message edited by: ehsan_kamrani ]

10-14-2004, 09:48 AM
ok. these features are not supported on my system.with the following code, as an example, i don't receive any run-time error:

JackOptionParamIds = mlPvFind( JackCap, ML_OPEN_OPTION_IDS_INT64_ARRAY );
if( JackOptionParamIds )
printf( "Number of optional PARAMs in this jack: %llx \n", JackOptionParamIds->length );