View Full Version : How to determine whether a certain API is supported?
13th April 2007, 14:35
Any way to determine (except testing the Winamp version number) if the given Winamp installation supports a certain API ID, e.g. ML_IPC_PLAYLIST_COUNT.
I think it's not a good style to have stuff like "if (winampVersion >= 0x0531) ..." all over the code.
A clean way to ask Winamp "do you support ML_IPC_PLAYLIST_COUNT" would be much better.
13th April 2007, 14:59
if an api is unsupported then the return value should be 1 in all cases. obviously that may cause issues for a number of apis but for some like when you get a function pointer, it's ideal for checking things.
i don't think there's much of an issue with a "if (winampVersion >= 0x0531) ..." check (or just doing as check at the start and then caching the version check results. adding in a IS_X_SUPPORTED would on the whole cause more complexity (both in the winamp core and also within plugins and it's no more different than the x>=y check).
there is the other option of just coding for a specific version of the winamp core/bundled plugins of that install (is basically what the winamp plugins do). it's just those of us naive enough to want to work on all versions that the issues like version checking arise
13th April 2007, 15:29
ML_IPC_PLAYLIST_COUNT returns 0 if unsupported, for example. But it also returns 0 if there are no playlists...
The problem with the winamp version check is simply that sometimes even we as developers don't know when a certain API was implemented :(
For the PLAYLIST stuff, I just installed 5 WA version and found out that it was introduced with 5.3. But that's no practical way.
13th April 2007, 17:11
for the case of the ml apis, i think they'll return 0 (wasn't concentrating when i was posting at work) since that's what SendMessage(..) generally returns i believe, i think it's that the main winamp SendMessage(..) handler does it differently and hence that returns 1.
the main issue is really that for a ml plugin, things have been changed a lot in 5.2x and then 5.3 (when more api's were added as part of implementation changes). generally, if uncertain then assume it's added as of 5.3 (is what i assume for the few newer ml aspects that i make use of). if ml.h had been properly versioned like wa_ipc.h is (well is for the most part) then it wouldn't be as bad - really ml.h needs to be better documented but that's been the case for a few years now *shrugs*
vBulletin® v3.8.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.