Posted: Sat Feb 08, 2003 4:33 pm
Restored from previous forum. Originally posted by GPI.
First of all: It's done, i can use Winamp Plugin! Almost. there is only a little Problem.
First of all: the code:
The programm start and play the sound correctly, but then it crash (at the endprocedure - command).
When i don't use the procedure winamp_play() and insert the code direct, it will work without any problem.
also:
CallFunctionFast(*in_head\stop)
have no problems.
I think the callfunction doesn't work right, when a parameter is given to the callfunctionfast-command). I think, that the "Stack" does have the parameter in it (or somebody had read to many informations out of the stack, so the endprocedure-command can't read the right return-adress and the programm will crash.
Maybe it can be correct with assembler-commands, but i don't know any command...
Who can help?
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
First of all: It's done, i can use Winamp Plugin! Almost. there is only a little Problem.
First of all: the code:
Code: Select all
;***;*** Winamp-Pluginuser
;***
Procedure setinfo():EndProcedure
Procedure dsp_isactive():EndProcedure
Procedure dsp_dosamples(pointer,numsamples,bps,nch,srate)
ProcedureReturn numsamples
EndProcedure
Procedure SAVSAInit():EndProcedure
Procedure SAVSADeInit():EndProcedure
Procedure SAAddPCMData():EndProcedure
Procedure SAGetMode():EndProcedure
Procedure SAAdd():EndProcedure
Procedure VSAAddPCMData():EndProcedure
Procedure VSAGetMode():EndProcedure
Procedure VSAAdd():EndProcedure
Procedure VSASetInfo():EndProcedure
Structure out_module
version.l ;module version (OUT_VER)
*description.s ;description of module, with version string
id.l ;module id. each input module gets its own. non-nullsoft modules should be >= 65536.
hMainWindow.l ;winamp's main window (filled in by winamp)
hDllInstance.l ;DLL instance handle (filled in by winamp)
Config.l ;void (*Config)(HWND hwndParent); // configuration dialog
About.l ;void (*About)(HWND hwndParent); // about dialog
Init.l ;void (*Init)(); // called when loaded
Quit.l ;void (*Quit)(); // called when unloaded
Open.l ; Int (*Open)(int samplerate, int numchannels, int bitspersamp, int bufferlenms, int prebufferms);
; // returns >=0 on success, GetOutputTime()
SetOutputTime.l ;void (*SetOutputTime)(int time_in_ms); // seeks to point in stream (in ms). Usually you signal yoru thread to seek, which seeks and calls outMod->Flush()..
;volume stuff
SetVolume.l ;void (*SetVolume)(int volume); // from 0 to 255.. usually just call outMod->SetVolume
SetPan.l ;void (*SetPan)(int pan); // from -127 to 127.. usually just call outMod->SetPan
;in-window builtin vis stuff
SAVSAInit.l ;void (*SAVSAInit)(int maxlatency_in_ms, int srate);
; // call once in Play(). maxlatency_in_ms should be the value returned from outMod->Open()
; // call after opening audio device with max latency in ms And samplerate
SAVSADeInit.l ;void (*SAVSADeInit)(); // call in Stop()
;simple vis supplying mode
SAAddPCMData.l ;void (*SAAddPCMData)(void *PCMData, int nch, int bps, int timestamp);
; // sets the spec Data directly from PCM Data
; // quick And easy way To get vis working :)
; // needs at least 576 samples :)
;advanced vis supplying mode, only use If you're cool. Use SAAddPCMData for most stuff.
SAGetMode.l ; Int (*SAGetMode)(); // gets csa (the current type (4=ws,2=osc,1=spec))
; // use when calling SAAdd()
SAAdd.l ;void (*SAAdd)(void *data, int timestamp, int csa);
; // sets the spec data, filled in by winamp
;vis stuff (plug-in)
; simple vis supplying mode
VSAAddPCMData.l ;void (*VSAAddPCMData)(void *PCMData, int nch, int bps, int timestamp)
; // sets the vis data directly from PCM data
; // quick And easy way To get vis working :)
; // needs at least 576 samples :)
; advanced vis supplying mode, only use If you're cool. Use VSAAddPCMData for most stuff.
VSAGetMode.l ;Int (*VSAGetMode)(int *specNch, int *waveNch)
; // use to figure out what to give to VSAAdd
VSAAdd.l ;void (*VSAAdd)(void *data, int timestamp);// filled in by winamp, called by plug-in
;call this in Play() To tell the vis plug-ins the current output params.
VSASetInfo.l ;void (*VSASetInfo)(int nch, int srate);
;dsp plug-in processing:
;(filled in by winamp, called by input plug)
;returns 1 If active (which means that the number of samples returned by dsp_dosamples
;could be greater than went in.. Use it To estimate If you'll have enough room in the
;output buffer
dsp_isactive.l ;Int (*dsp_isactive)();
;returns number of samples To output. This can be as much as twice numsamples.
;be sure To allocate enough buffer For samples, then.
dsp_dosamples.l ;Int (*dsp_dosamples)(short int *samples, int numsamples, int bps, int nch, int srate);
;eq stuff
EQSet.l ;void (*EQSet)(int on, char data[10], int preamp); // 0-64 each, 31 is +0, 0 is +12, 63 is -12. Do nothing to ignore.
;info setting (filled in by winamp)
SetInfo.l ;void (*SetInfo)(int bitrate, int srate, int stereo, int synched); // if -1, changes ignored? :)
outMod.l ;Out_Module *outMod; // filled in by winamp, optionally used :)
EndStructure
Global *out_head.out_module
Global *in_head.in_module
Procedure quit_winamp()
If *in_head
CallFunctionFast(*in_head\quit)
CloseLibrary(100)
*in_head=0
EndIf
If *out_head
CallFunctionFast(*out_head\quit)
CloseLibrary(101)
*out_head=0
EndIf
EndProcedure
Procedure Init_Winamp(in_dll$,out_dll$,windowid)
;return
; 0 no error.
; -1 out_dll is no winamp-dll
; -2 can't open out_dll
; -3 in_dll is no winamp-dll
; -4 can't open in_dll
Debug in_dll$
If *out_head0 Or *in_head0
quit_winamp()
EndIf
out_DLLinstance=OpenLibrary(101, out_dll$)
If out_DLLinstance
*out_head=CallFunction(101,"winampGetOutModule")
If *out_head
*out_head\hMainWindow=WindowID()
*out_head\hDllInstance=out_DLLinstance
CallFunctionFast(*out_head\Init)
Else
CloseLibrary(101)
*out_head=0:*in_head=0
ProcedureReturn -1
EndIf
Else
*out_head=0:*in_head=0
ProcedureReturn -2
EndIf
Debug in_dll$
in_DLLinstance= OpenLibrary(100, in_dll$)
Debug in_dllinstance
If in_DLLinstance
*in_head = CallFunction(100, "winampGetInModule2" )
If *in_head
*in_head\hMainWindow=WindowID
*in_head\hDllInstance=in_DLLinstance
*in_head\outMod=*out_head
CallFunctionFast(*in_head\Init)
;dummy-routines
*in_head\SetInfo=@setinfo()
*in_head\dsp_isactive =@dsp_isactive()
*in_head\dsp_dosamples=@dsp_dosamples();----
*in_head\SAVSAInit =@SAVSAInit()
*in_head\SAVSADeInit =@SAVSADeInit() ;----
*in_head\SAAddPCMData =@SAAddPCMData()
*in_head\SAGetMode =@SAGetMode() ;----
*in_head\SAAdd =@SAAdd() ;----
*in_head\VSASetInfo =@VSASetInfo()
*in_head\VSAAddPCMData=@VSAAddPCMData()
*in_head\VSAGetMode =@VSAGetMode() ;----
*in_head\VSAAdd =@VSAAdd() ;----
Else
CallFunctionFast(*out_head\quit)
CloseLibrary(101)
CloseLibrary(100)
*out_head=0:*in_head=0
ProcedureReturn -3
EndIf
Else
CallFunctionFast(*out_head\quit)
CloseLibrary(101)
*out_head=0:*in_head=0
ProcedureReturn -4
EndIf
ProcedureReturn 0
EndProcedure
Procedure winamp_play(playfile$)
Debug CallFunctionFast(*in_head\play,@playfile$)
Endprocedure
;Small Winamp-Demo
in_dll$="in_psf"
out_dll$="out_ds"
playfile$="dark.psf"
If OpenWindow(0, 0,0,100,100,#PB_Window_ScreenCentered ,"Winamp-Plugin-Test")
ret=init_winamp("in_psf","out_ds",WindowID())
If ret=0
;***********************************************************************************
;this line will crash (but it play!):
ret= winamp_play(playfile$)
;but this line function!
ret=CallFunctionFast(*in_head\play,@playfile$)
;***********************************************************************************
titel$=Space(1000):title_len.l=0
CallFunctionFast(*in_head\GetFileInfo,@playfile$,@titel$,@title_len)
Debug playfile$+" "+titel$+" "+Str(title_len)
If ret=0
MessageRequester("Winamp-Plugin-Test", playfile$+Chr(16)+"Ok to stop", Flags)
CallFunctionFast(*in_head\stop)
Else
MessageRequester("Winamp-Plugin-Test", "Can't play:"+Str(ret), Flags)
EndIf
Else
Debug ret
EndIf
EndIf
quit_winamp()
When i don't use the procedure winamp_play() and insert the code direct, it will work without any problem.
also:
CallFunctionFast(*in_head\stop)
have no problems.
I think the callfunction doesn't work right, when a parameter is given to the callfunctionfast-command). I think, that the "Stack" does have the parameter in it (or somebody had read to many informations out of the stack, so the endprocedure-command can't read the right return-adress and the programm will crash.
Maybe it can be correct with assembler-commands, but i don't know any command...
Who can help?
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB