Old 17th December 2013, 04:19   #1
ChenJianFeng
Junior Member
 
Join Date: Dec 2013
Posts: 2
How to use winamp plugin in java?

I used JNA to map the plugin functions and variables.

This is my plugin class:

code:
public interface dsp_stereo extends Library{
dsp_stereo INSTANCE = (dsp_stereo) Native.loadLibrary("dsp_stereo", dsp_stereo.class);
public winampDSPHeader winampDSPGetHeader2();
}



This is winampDSPHeader class:

code:
public class winampDSPHeader extends Structure{
public int version;
public String description;
public static interface getModuleFunc extends Callback{
winampDSPModule invoke(int i);
}
public getModuleFunc getModule;
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[] { "version", "description", "getModule"});
}
}



This is winampDSPModule class:

code:
public class winampDSPModule extends Structure{
public String description;
public HWND hwndParent;
public HINSTANCE hDllInstance;
public static interface configFunc extends Callback{
void invoke(winampDSPModule this_mod);
}
public configFunc Config;
public static interface initFunc extends Callback{
int invoke(winampDSPModule this_mod);
}
public initFunc Init;
public static interface modifySamplesFunc extends Callback{
int invoke(winampDSPModule this_mod, short[] samples, int numsamples, int bps, int nch, int srate);
}
public modifySamplesFunc ModifySamples;
public static interface quitFunc extends Callback{
void invoke(winampDSPModule this_mod);
}
public quitFunc Quit;
public Pointer userData;

@Override
protected List getFieldOrder() {
return Arrays.asList(new String[] { "description", "hwndParent", "hDllInstance", "Config", "Init", "ModifySamples", "Quit", "userData"});
}
public winampDSPModule(){

}
}



This is my main class:

code:
public class Test{
public static void main(String[] args){
JFrame f = new JFrame();
f.setTitle("asd");
f.setVisible(true);
f.setSize(300, 400);

dsp_stereo lib = dsp_stereo.INSTANCE;
winampDSPHeader header = lib.winampDSPGetHeader2();
winampDSPModule module = header.getModule.invoke(0);
module.hwndParent = null;
module.hDllInstance = Kernel32.INSTANCE.GetModuleHandle("dsp_stereo");
module.Init.invoke(module);
}
}



The plugin appeared when i ran the code. But it is not responding when i clicked on it. Do i missed something on my code?
ChenJianFeng is offline   Reply With Quote
Old 17th December 2013, 06:38   #2
thinktink
Forum King
 
thinktink's Avatar
 
Join Date: May 2009
Location: On the streets of Kings County, CA.
Posts: 2,962
Send a message via Skype™ to thinktink
code:
module.hwndParent = null;


Quote:
Originally Posted by ChenJianFeng View Post
... But it is not responding when i clicked on it. ...
By the way you described your results and the fact you assigned NULL to the hwndParent member it appears that the Java environment you are trying to load the plugin inside of doesn't supply the Windows API and/or Winamp API emulation the DSP requires to operate properly. What are you trying to accomplish?
thinktink is online now   Reply With Quote
Old 18th December 2013, 01:36   #3
ChenJianFeng
Junior Member
 
Join Date: Dec 2013
Posts: 2
What should i have it assigned to?
ChenJianFeng is offline   Reply With Quote
Old 20th December 2013, 04:23   #4
thinktink
Forum King
 
thinktink's Avatar
 
Join Date: May 2009
Location: On the streets of Kings County, CA.
Posts: 2,962
Send a message via Skype™ to thinktink
Quote:
Originally Posted by ChenJianFeng View Post
What should i have it assigned to?
Something probably not available in the Java environment, an actual window handle generated by the Windows Operating System that supplies/implements the Winamp main window API and all other associated Winamp API's that the DSP plugin could possibly use.

And since the DSP plugin is making a window, that means that the Java environment needs to supply a window message pump and associated Windows API for the handling of that Window, which is also probably not available from the Java environment. All of which probably WAY well beyond the scope of these forums.
thinktink is online now   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > Winamp Development

Tags
java, player, plugin

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump