APOLOGIES FOR POSTING A HALF COMPLETE MESSAGE. EUDORA MAPS C-E TO SEND MAIL
AND EMACS MAPS IT TO END OF LINE. OPPS!
Hi.
A little while ago I bought a Sony PEG-N770C and decided to write an app to
control the inbuilt MP3 player, there is a whole bunch of stuff I want to
do including a conduit that lets you pick the tunes you want to upload next
time you hotsync. However on registering on the Sony Developer site and
downloading the SDK I hit problems, the documentation is not great and the
header files are messy and inconsistent. It took me a while to work out
some of the Sonyisms and as such I thought it appropriate to comment on my
findings in the palm-dev-forum.
My development platform for the exercise is a Win32 box (Win2k Pro) running
GCC, PalmOS SDK 4.0, Sony SDK 3.0 and my editor of choice is Emacs. First
off the Sony SDK is not GCC friendly, it uses an enumerated type for the
system traps, to get anything to compile at all you need to replace the
enumerated types with #defines. A previous thread has already dealt with
this issue so I will not cover it here.
The library I wanted to use, MsaLib (Memory Sticlk Audio Library), is not
supported under Pose, so all testing has to be done on an actual device, my
device is a Sony PEG-N770c, which is the European equivalent of the
PEG-N760C, running PalmOS 4.1 I do not have access to a device that takes
the Audio Adapter accessory so if you are trying to program that from what
I have to say your mileage might vary.
The first important thing to note is that the system handles loading the
library, and initializes it at least once. Consequently you will not have
to load the library youself, you just have to call SysFindLib to grab the
reference. If you poke around in the header files like I did you will find
a #define in SonyMsaLib.h called msaLibName, commented out, do NOT
uncomment this, it is almost certainly there for legacy prurposes. The
lookup name you want is in SonySystemResource.h.
/* Msa-Lib */
#define sonySysFileCMsaLib 'SlMa' /* MS Audio */
#define sonySysFileTMsaLib sysFileTLibrary /* 'libr' */
#define sonySysLibNameMsa "Sony Msa Library"
The next point to note is that MsaLibOpen and MsaLibClose return values
other than errNone even on success. Personally I think this is fairly poor,
but that is how it is and so there! Since use of the library is not
exclusive to one app, multiple apps can hold references to the library at
once, so MsaLibOpen might not return errNone when you call it,but that
might just be because some other app holds a reference to the library too.
A cleaner solution would be to pass an UInt16* to MsaLibOpen and get it to
return a lock count, regardless of the API from Sony, you should call
MsaLibClose once for every successful call to MsaLibOpen.
How do I know if a MsaLib is available on a device? This is actually in the
docs, and in short involves a call to FtrGet, rather than try and explain
it in English here is some code to ask a device if it supports MsaLib:
Boolean AppMsaLibExists()
{
Err err;
SonySysFtrSysInfoP infoPtr;
err = FtrGet( sonySysFtrCreator, sonySysFtrNumSysInfoP, ( UInt32* )
&infoPtr );
return ( err == errNone );
}
Here are some additional code snippets to get a reference to MsaLib and
initialize it and to release MsaLib:
Boolean AppMsaLibOpen( UInt16 *msaLibRefPtr )
{
Err err;
SonySysFtrSysInfoP infoPtr;
err = FtrGet( sonySysFtrCreator, sonySysFtrNumSysInfoP, ( UInt32* )
&infoPtr );
if ( err == errNone )
{
// MsaLib is present and OK.
if ( infoPtr && ( infoPtr->libr & sonySysFtrSysInfoLibrMsa ))
{
err = SysLibFind( sonySysLibNameMsa, msaLibRefPtr );
if ( err != errNone ) return false;
err = MsaLibOpen( *msaLibRefPtr, msaLibOpenModeAlbum );
return (( err == errNone ) || ( err == msaErrAlreadyOpen ));
}
}
// MsaLib is present but something fishy is going on.
else
{
*msaLibRefPtr = 0;
return false;
}
// Failed to initialise Memory Stick Audio Library.
*msaLibRefPtr = 0;
return false;
}
Boolean
AppMsaLibClose( const UInt16 msaLibRef )
{
Err err;
err = MsaLibClose( msaLibRef, msaLibOpenModeAlbum );
return (( err == errNone ) || ( err == msaErrStillOpen ));
}
Once you have succesfully got a reference to MsaLib and initialzed it, the
rest of it is pretty self explanatory, just read the docs. As far as I can
tell you do not, and should not, unload MsaLib when you are done. I have
also succesfully managed to munge the headers from Sony to allow me to
compile my application using OnBoardC on my Clie. I hope this post helps
other people who have been battling with the poor documentation from Sony.
-haemish
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/