Problem using SDL in a winamp plugin

A while ago I tried to port synaesthesia-2.1 to Windows and make a Winamp
plugin for it. I got it to work the first time I activate the plugin but
after that it’d fail to start up again. (I’d have to restart Winamp to use
the plugin again.)

I’ve now done some more investigation of what’s going on using SDL-1.2.
SDL_Init(SDL_INIT_WINDOW) is failing with “DirectInputCreate: Invalid
parameters”. In a normal program I can keep restarting SDL (doing a quit
followed by an init) all I want. In a Winamp plugin I can restart it in the
init function or in the quit function. I can start and stop it in the init
function and again start and stop it in the quit function. I can do
anything I want with SDL the first time the plugin is started, but I get the
error on all subsequent attempts to start it. Once one plugin that uses SDL
is started and stopped no other plugins that use SDL will work either.

I made a totally stripped down Winamp visualization plugin. The init
function just calls SDL_Init(SDL_INIT_VIDEO) and the quit function just
calls SDL_Quit(). It fails the 2nd time I run it.

What’s going on?–
Boris

A while ago I tried to port synaesthesia-2.1 to Windows and make a Winamp
plugin for it. I got it to work the first time I activate the plugin but
after that it’d fail to start up again. (I’d have to restart Winamp to use
the plugin again.)

I’ve now done some more investigation of what’s going on using SDL-1.2.
SDL_Init(SDL_INIT_WINDOW) is failing with “DirectInputCreate: Invalid
parameters”. In a normal program I can keep restarting SDL (doing a quit
followed by an init) all I want. In a Winamp plugin I can restart it in the
init function or in the quit function. I can start and stop it in the init
function and again start and stop it in the quit function. I can do
anything I want with SDL the first time the plugin is started, but I get the
error on all subsequent attempts to start it. Once one plugin that uses SDL
is started and stopped no other plugins that use SDL will work either.

I made a totally stripped down Winamp visualization plugin. The init
function just calls SDL_Init(SDL_INIT_VIDEO) and the quit function just
calls SDL_Quit(). It fails the 2nd time I run it.

What’s going on?

This sounds similar to the problems caused by SDL_Init being called without
SDL_RegisterApp() being called. That function needs to be called from the
main application in order for DirectInput to initialize properly. Is it
being called before each call to SDL_Init()?

An alternative might be to just use the windib driver, which doesn’t use
DirectInput, or to allow the video initialization to succeed even if the
input initialization fails.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment