Old 17th September 2010, 20:15   #1
mariano315
Junior Member
 
Join Date: Sep 2010
Posts: 17
Interruptions

Hi,
I'm trying to write my first plugin and I was wondering what would be the best way to detect different events, principally when a button is pressed (next, previous, play, pause, volume changed, mute, shuffled, etc). I was thinking about doing it with interruptions, but I'm not sure how to do it.
Thanks.
mariano315 is offline   Reply With Quote
Old 17th September 2010, 22:15   #2
DrO
 
Join Date: Sep 2003
Posts: 27,873
not sure what you mean by interruptions but there are specific messages or generic callback actions which can be accessed by sub-classing the main Winamp window. i've got an example which shows how to catch the different playing events though i'm not able to upload it until the start of the week. in the mean time look at the IPC_CB_* messages in wa_ipc.h (my example uses them along with a few others from what i remember to act as the basis of a now playing detection plug-in).

-daz
DrO is offline   Reply With Quote
Old 17th September 2010, 23:00   #3
mariano315
Junior Member
 
Join Date: Sep 2010
Posts: 17
ok, thanks. I look forward to the example. In the meanwhile I'll look at the messages.
mariano315 is offline   Reply With Quote
Old 19th September 2010, 15:48   #4
DrO
 
Join Date: Sep 2003
Posts: 27,873
http://nunzioweb.com/daz/gen_play_state/ shows how to detect some of the events mainly related to changes in playback though is a good basis to work from and to expand to cover other events as detailed in wa_ipc.h. also the example covers other aspects for implementing a plug-in which anyone making a new plug-in nowadays should be doing to ensure best compatibility with current Winamp clients.

-daz
DrO is offline   Reply With Quote
Old 20th September 2010, 01:03   #5
mariano315
Junior Member
 
Join Date: Sep 2010
Posts: 17
The example is really what I needed. I'll start to work on it in order to make it detect other events. Thanks a lot for it.
mariano315 is offline   Reply With Quote
Old 20th September 2010, 08:12   #6
DrO
 
Join Date: Sep 2003
Posts: 27,873
that's good to hear

-daz
DrO is offline   Reply With Quote
Old 24th September 2010, 17:57   #7
mariano315
Junior Member
 
Join Date: Sep 2010
Posts: 17
I'm getting the following error when I try to build the project:

error C2065: 'GEN_INIT_FAILURE' : undeclared identifier

and it's curious because some days ago I could build it with no problem. How may I solve it? should I add any line to gen.h?
Thanks.
mariano315 is offline   Reply With Quote
Old 24th September 2010, 18:02   #8
DrO
 
Join Date: Sep 2003
Posts: 27,873
it should be in you gen.h file though it's #define GEN_INIT_FAILURE 1 when i've experienced it, i've normally fixed it by doing a complete rebuild of the msvc solution.

-daz
DrO is offline   Reply With Quote
Old 26th September 2010, 19:28   #9
mariano315
Junior Member
 
Join Date: Sep 2010
Posts: 17
whenever IPC_PLAYINGFILE(W) is called in the callback function winamp crashes. I guess this might be because of the path returned in wParam, since I don't have much problems with others lParam used in the callback function. Any ideas of how to solve the problem? I'm using winamp v5.572 under windows 7.
mariano315 is offline   Reply With Quote
Old 27th September 2010, 09:27   #10
DrO
 
Join Date: Sep 2003
Posts: 27,873
well i've tried the example also as a VC6 compile and i'm not getting any crashes when that message is received (making sure it's a unicode compile).

i've not tried on 5.572 though the example was developed on 5.56 and 5.58/5.59 beta so there shouldn't be a reason for the example code as is to crash. what is the crash message you're getting as that might make it easier to work out (or what it is that you've changed in that callback for what you're trying to do).

-daz
DrO is offline   Reply With Quote
Old 1st October 2010, 18:48   #11
mariano315
Junior Member
 
Join Date: Sep 2010
Posts: 17
I updated to the last version of winamp and it's working now, thanks.
mariano315 is offline   Reply With Quote
Old 1st October 2010, 19:06   #12
DrO
 
Join Date: Sep 2003
Posts: 27,873
ah, i bet you were using a version of Winamp which doesn't support that api as unknown apis on older Winamp clients return 1.

-daz
DrO is offline   Reply With Quote
Old 18th October 2010, 02:36   #13
mariano315
Junior Member
 
Join Date: Sep 2010
Posts: 17
Serial Port

Hi,
Now I'm trying to add some serial port handling to the code. I'd like to know what should be necessary to add to gen_play_state so that it can transmit and receive data through the COM port. I'd like to do it so that my program is "interrupted" when data is received in the serial port's buffer (no using threads).
Thanks a lot.
mariano315 is offline   Reply With Quote
Old 18th October 2010, 09:09   #14
DrO
 
Join Date: Sep 2003
Posts: 27,873
i really don't know as i've never done com port stuff though i'd presume it depends on the library / code you're using to access the com port as to how to integrate it into the plug-ins code (ironically i'd have suggested having that work on a separate thread so it doesn't lockup Winamp if there's a delay but obviously it really is down to you and the code you're going to use for the com port as to how it's going to end up working). sorry there's not much i can really offer for a decent answer.

-daz
DrO is offline   Reply With Quote
Old 18th October 2010, 20:17   #15
mariano315
Junior Member
 
Join Date: Sep 2010
Posts: 17
no problem, thanks anyway.
mariano315 is offline   Reply With Quote
Old 21st October 2010, 16:23   #16
mariano315
Junior Member
 
Join Date: Sep 2010
Posts: 17
Ipc_cb_misc_volume

Hi again,
I'm trying to get informed whenever the volume is changed, so I wrote this inside the callback function:

if (message == WM_WA_IPC && lParam == IPC_CB_MISC && wParam == IPC_CB_MISC_VOLUME){

wchar_t valor_vol[1024];
int volume = IPC_GETVOLUME(plugin.hwndParent);

wsprintf(valor_vol,L"Volumen: %d",volume);
MessageBox(NULL,valor_vol,L"Volume changed", MB_OK);

}

The problem is that when the volume is changed two messageboxes appear instead of only one. If I change the volume from the clicking volume bar in the winamp window the first messagebox indicates the volume selected but immediately another messagebox appears indicating that the volumen was changed again to the previous level. If I change the volume with the mouse scroll I don't get this problem but still I get two messageboxes.
mariano315 is offline   Reply With Quote
Old 21st October 2010, 17:51   #17
DrO
 
Join Date: Sep 2003
Posts: 27,873
not too sure, i know you'll get two together when starting a track due to the volume and pan being notified but i cannot see any other reason to be getting both when just changing the volume (unless it's down to the MessageBox(..) causing a delay in the processing of the callback).

-daz
DrO is offline   Reply With Quote
Old 24th October 2010, 00:33   #18
mariano315
Junior Member
 
Join Date: Sep 2010
Posts: 17
Adding a simple GUI

Hi,
Until now I've been able to develop what I needed for my plugin. I also made a very simple Form in a different project. What I want to do and don't know how, is to integrate that Form into my plugin, I want the form to be displayed when the initialization method of the plugin is called. I don't know how to do it, as the plugin and the simple Form were made from two different projects in different ways (one compiled as a .dll and the other as a .exe). I know what I want to do is to add a very simple GUI to my plugin, but I new to all of this.
Thanks.
mariano315 is offline   Reply With Quote
Old 24th October 2010, 10:52   #19
DrO
 
Join Date: Sep 2003
Posts: 27,873
why do i get the feeling that it's a C# form in the exe... since if it was a c++ based one then you can port it into the plug-in without too much of a problem but c++/C# in the same dll isn't (easily possible) from what i understand.

if you know basic Win32 stuff (without all of the abstraction that goes on the top of things) then it's easy to add a Dialog (form) to the plug-in and just respond to the WM_COMMAND and other messages as applicable in the dialog's window proceedure.

if not i think there were some examples people have done on how to use a C# dll in a Winamp / C++ dll (uses COM interops from what i remember) but as my knowledge of C# is pretty poor (only managed 1.5 months before i had to stop learning due to other commitments then i'm possibly not the best person on such things, heh).

-daz
DrO is offline   Reply With Quote
Old 24th October 2010, 16:14   #20
mariano315
Junior Member
 
Join Date: Sep 2010
Posts: 17
thanks for the response. the exe is a C++ form (I don't know C# neither). could you explain me how to port it into the plug-in ??
I don't think my form will be responding to wm_commands as it will be used to configure some serial communication settings (that's why I want to put it in the initialization function, it will initialize some variables in the dll).
mariano315 is offline   Reply With Quote
Old 24th October 2010, 17:12   #21
DrO
 
Join Date: Sep 2003
Posts: 27,873
if it is all in c++ then you'd just need to copy it into the plug-in and just use it as you need to. most likely you can just include the source files from the exe, make a header so you can access it from within the plug-in and then call what you need to in the plug-ins init(..).

obviously if the original source code is from an exe then you'll need to disable the main function (or rename it if you're going to use it in the init(..) otherwise you'll get a load of build errors, etc).

-daz
DrO is offline   Reply With Quote
Old 26th October 2010, 19:47   #22
mariano315
Junior Member
 
Join Date: Sep 2010
Posts: 17
compiling error

I have these two lines in my code:

HWND formwm = FindWindow(NULL,L"FormWM");
this::SendMessage(formwm,WM_COMMAND,40045,0);

and I keep getting the following error:

error C2143: syntax error : missing ';' before 'SendMessage'

Please help...
mariano315 is offline   Reply With Quote
Old 31st October 2010, 02:35   #23
mariano315
Junior Member
 
Join Date: Sep 2010
Posts: 17
Adding a Thread

Hi, can anyone explain me how to add a thread to my .dll plugin and how the plugin properties should be configured in order to have it compiled properly?
Thanks.
mariano315 is offline   Reply With Quote
Old 31st October 2010, 21:21   #24
DrO
 
Join Date: Sep 2003
Posts: 27,873
for the thread thing it's down to the thread implementation you want to use. plug-ins other than the specified functions in the plug-in module are just standard Windows dlls so any threading implementation supported in the language being used should be fine to include.

-daz
DrO is offline   Reply With Quote
Old 11th November 2010, 00:23   #25
mariano315
Junior Member
 
Join Date: Sep 2010
Posts: 17
Problem with .dll

I'm having some problems with my .dll plugin. It only works under the same computer in which I compiled it, in any other computer winamp doesn't recognize it (I tried compiling it under both xp and 7 but the problem persists). But it doesn't happen only with the plugin, I also created a .exe file and the same thing happens, I can't make it run in any other computer other the one in which I compiled it.
mariano315 is offline   Reply With Quote
Old 11th November 2010, 08:30   #26
DrO
 
Join Date: Sep 2003
Posts: 27,873
use http://www.dependencywalker.com/ to check the dlls being exported by your plug-in / exe and will show ones that are missing.

if i had to guess you're probably trying to use the debug version or one with msvcrXX.dll / msvcpXX.dll dependencies. if it is due to msvcXXX then either install the related redist package for the version of MSVC being used or switch the plug-in to statically link to the c runtime library (gives a bigger dll but will be more portable across different installs).

-daz
DrO is offline   Reply With Quote
Old 15th November 2010, 20:13   #27
mariano315
Junior Member
 
Join Date: Sep 2010
Posts: 17
I'm sorry, could you explain me how to switch the plug-in to statically link to the c runtime library?
mariano315 is offline   Reply With Quote
Old 15th November 2010, 20:27   #28
DrO
 
Join Date: Sep 2003
Posts: 27,873
recent versions of MSVC place it under Project Properties -> Configuration Properties -> C/C++ -> Runtime Library -> change to 'Multi-threaded /MT'. though it's better to just run the redist package for your version of MSVC instead of shipping the crt in the plug-in which is a waste of space (even if it's only a few 100kb it adds to the compiled dll size doing it statically).

-daz
DrO is offline   Reply With Quote
Old 15th November 2010, 22:20   #29
mariano315
Junior Member
 
Join Date: Sep 2010
Posts: 17
Hi DrO,
first I downloaded the redist package for MSVC 2008 SP1 but it didn't work, and then I tried changing to 'Multi-threaded /MT' but I got the following error:
Command line error D8016 : '/MT' and '/clr' command-line options are incompatible
How may I fix it?

Last edited by mariano315; 16th November 2010 at 00:04.
mariano315 is offline   Reply With Quote
Old 16th November 2010, 08:44   #30
DrO
 
Join Date: Sep 2003
Posts: 27,873
have a look through http://social.msdn.microsoft.com/for...d-0a3b0562412a as that seems to point to what's needed (this is all because of the mixed mode C++ / C# that you're doing).

so i'd guess you'd need to check the .NET install on the machine you're having issues with and to use http://www.dependencywalker.com/ to see what dlls the plug-in / associated dlls you're running are trying to reference.

-daz
DrO is offline   Reply With Quote
Old 27th December 2010, 15:25   #31
mariano315
Junior Member
 
Join Date: Sep 2010
Posts: 17
Hi!
Can you explain me how to statically link a library (libcurl.dll) in order for the application
to work without needing library files? I'm using msvc 2010.
Thanks.
mariano315 is offline   Reply With Quote
Old 28th December 2010, 08:40   #32
siam6606
Junior Member
 
Join Date: May 2010
Posts: 42
Hi,

You can download the static library here : http://curl.haxx.se/latest.cgi?curl=win32-devel-msvc
siam6606 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > Winamp Development

Tags
interruptions

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