Winamp Vis Plugin problem

Windows specific forum
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by DemonHell.

Hi
I got a little problem with a winamp plugin I`m trying to write.
I got the vis SDK from the winamp site, and basically rewrote it in PB.
Only problem is, the Render routine is only called 61 times then it crashes with an Invalid Page Fault in Kernel32.dll.

I cut the plugin down to the bare bones.. just an empty Render routine that counts how many times it`s been called,(plus the empty Init() etc. needed for the routine),still the same.

Anyone successfully got a working skeleton plugin to work?

BTW.. A handy hint for other wishing to try plugins..compile as a DLL, then load the compiled dll into a hexeditor, then find the string "_winampVisGetHeader" and replace it as "winampVisGetHeader" and fill the remaining "r" with a null, cos PB always bungs an underscore infront of DLL function names..tut tut.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.
BTW.. A handy hint for other wishing to try plugins..compile as a DLL, then load the compiled dll into a hexeditor, then find the string "_winampVisGetHeader" and replace it as "winampVisGetHeader" and fill the remaining "r" with a null, cos PB always bungs an underscore infront of DLL function names..tut tut.
Nice tip, but wouldn't it be better to use a procedure name that is one character less than needed and then write the full name in the dll file. I don't know how it affects the dll file if you make the function names shorter than intended by putting a null character where it's not expected.. Just a thought..

As for your questions, i can't really tell what's wrong without taking a peek at your source code...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by DemonHell.
Nice tip, but wouldn't it be better to use a procedure name that is one character less than needed and then write the full name in the dll file
Bah..I didnt think of that, I was too busy trying to find out why the plugin bombs out after 61 calls to Render()...no matter what I try, it`s always the same amount of calls!

Anyway, here`s the source of my barebones plugin, maybe someone can spot the culprit?


Structure winampVisModule
*description.b
hwndParent.l
hDllInstance.l
sRate.l
nCh.l
latencyMs.l
delayMs.l
spectrumNch.l
waveformNch.l
spectrumData.b[1152] ;(2*576)
waveformData.b[1152] ; " "
Config.l
Init.l
Render.l
Quit.l
UserData.l
EndStructure

Structure winampVisHeader
version.l
*description.b
*getmodule.l
EndStructure

#VIS_HDRVER =$101

Declare .l getModule(which.l)
Declare Config(*this_mod.winampVisModule)
Declare Quit(*this_mod.winampVisModule)
Declare .l Init(*this_mod.winampVisModule)
Declare .l Render(*this_mod.winampVisModule)

DefType .winampVisHeader hdr
DefType .winampVisModule Mod1

HDR_Desc$="Test plugin"+Chr(0)
VM_Desc$="blah blah blah"+Chr(0)

Global hdr,Mod1,HDR_Desc$,VM_Desc$,rendercount.l

Procedure.l getModule(which.l)
If which=0
ProcedureReturn @Mod1
Else
ProcedureReturn 0
EndIf
EndProcedure

Procedure Config(*this_mod.winampVisModule)
MessageBox_(*this_mod\hwndParent,"Woohoo, the config button works!","Config",#MB_OK)
EndProcedure

Procedure Quit(*this_mod.winampVisModule)
MessageBox_(*this_mod\hwndParent,"Vis QUITTING","QUIT",#MB_OK)
CloseConsole()
EndProcedure

Procedure.l Init(*this_mod.winampVisModule)
OpenConsole()
PrintN("Init Called")
ProcedureReturn 0
EndProcedure


Procedure.l Render(*this_mod.winampVisModule)
rendercount+1
PrintN("RENDER>"+Str(rendercount))
ProcedureReturn 0
EndProcedure

;## ONLY EXPORTED FUNCTION..returns main header
;## ALSO USE IT TO SETUP ANY STRUCTURES..COZ IT BOMBS OTHERWISE!
ProcedureDLL.l winampVisGetHeader()

hdr\version=#VIS_HDRVER
hdr\description=@HDR_Desc$
hdr\getmodule=@getModule()

Mod1\description=@VM_Desc$
Mod1\latencyMs=50
Mod1\delayMs=100
Mod1\spectrumNch=2
Mod1\waveformNch=0
Mod1\Config=@Config()
Mod1\Init=@Init()
Mod1\Render=@Render()
Mod1\Quit=@Quit()

ProcedureReturn @hdr
EndProcedure
Post Reply