Go Back   Winamp Forums > Developer Center > Winamp Development

Reply
Thread Tools Search this Thread Display Modes
Old 21st July 2007, 19:19   #1
uppe
Junior Member
 
Join Date: Jul 2007
Posts: 10
ipc_set_shuffle crash

I'm trying to prevent the user with my loaded plugin to accidentially activate playlist shuffle.

I've set it up this way. In the WndProc method I'm listening for the IPC_SET_SHUFFLE message to detect if the user has pressed the toggle shuffle button. So in that case, I'm calling a SendMessage(hwnd, WM_WA_IPC, 0, IPC_SET_SHUFFLE) to set it back to 'disabled' again.

Though this results in Winamp crashing...
Toggling IPC_SET_SHUFFLE on other messages work perfectly however. Any ideas for getting around this?

Thanks
uppe is offline   Reply With Quote
Old 21st July 2007, 19:54   #2
DrO
-
 
DrO's Avatar
 
Join Date: Sep 2003
Location: UK
Posts: 22,483
sending IPC_SET_SHUFFLE effectively re-triggers the toggle action and i'm sure if you checked the code, you end up in an endless loop and cause a stack fault. instead try using SendMessage(hwnd,WM_COMMAND,MAKEWPARAM(40023,0),0)
which should work better (though you need to ideally keep a check on the state you're already in). funnily enough i made some time back this which already does what you're trying to do)

-daz
DrO is offline   Reply With Quote
Old 21st July 2007, 20:12   #3
uppe
Junior Member
 
Join Date: Jul 2007
Posts: 10
Thanks for a quick reply. Your plugin works a lot better than mine, but I'd really want to implement the same thing in mine. I substituted my endless loop of IPC_SET_SHUFFLE's with something that looks like this:

code:

case IPC_SET_SHUFFLE:
SendMessage(hwnd,WM_COMMAND,MAKEWPARAM(40023,0),0);
break;



This has no visible effect. The playback is still random and clicking the toggle button still works properly.

You mentioned that I need to keep a check on the state, but as I can't see what MAKEWPARAM(40023,0) is accomplishing, I don't see how I should act if it's enabled or disabled.
uppe is offline   Reply With Quote
Old 21st July 2007, 22:17   #4
DrO
-
 
DrO's Avatar
 
Join Date: Sep 2003
Location: UK
Posts: 22,483
oops, i missed the part of your post saying you were waiting on IPC_SET_SHUFFLE (that's only used by other plugins and not general by winamp or from any user interactions). obviously disabling it from working with other plugins isn't a good thing to do, just user interactions

40023 is the menu id of the shuffle menu item (right-click on the shuffle button) and it is used as the internal message id for the shuffle command when you toggle it from any of the other windows (that obviously pass/implement the common keyboard handling in winamp).

here's what i have as the window proc for that plugin - it handles the keyboard accelerator and should work correctly irrespective of the skin in use (classic/modern)
code:
int shufset = 0;
LRESULT CALLBACK WinampWnd(HWND hwnd, UINT umsg, WPARAM wp, LPARAM lp){
if(umsg == WM_COMMAND && LOWORD(wp) == 40023 ||
umsg == WM_KEYDOWN && wp == 'S'){
if(!shufset){
shufset = 1;
SendMessage(hwnd,WM_COMMAND,MAKEWPARAM(40023,0),0);
}
else{
shufset = 0;
}
}
return CallWindowProc(WinampProc,hwnd,umsg,wp,lp);
}

-daz
DrO is offline   Reply With Quote
Old 21st July 2007, 23:07   #5
uppe
Junior Member
 
Join Date: Jul 2007
Posts: 10
Cool stuff. That's a lot of help for me! Is there a list of these menu id's somewhere, so I can look other stuff up as well?

I noticed however that you can invoke a random jump occasionally, for example when playback is stopped. It seems to always be working when the playback is running though. Strange. I guess there are some more secret id's I don't know about. :P

Also, I find it really confusing that the "light bulb" that tells me if the shuffle is on or off lights up, even though the shuffle isn't activated. Can this be turned off with one of these id's too? That would be *awesome*

Really appreciate your help and devotion for this SDK.
uppe is offline   Reply With Quote
Old 21st July 2007, 23:09   #6
uppe
Junior Member
 
Join Date: Jul 2007
Posts: 10
Hmm, I just found out that this is true only for the modern skin. Winamp classic is behaving just as one would expect.

So, what's up with the modern skins?
uppe is offline   Reply With Quote
Old 22nd July 2007, 14:50   #7
uppe
Junior Member
 
Join Date: Jul 2007
Posts: 10
I've figured out a sneaky solution that fixes shuffle sporadicalness when the player is stopped. I changed the WPARAM value of 'S' to 's', so Winamp never detects the S key.

code:

int shufset = 0;
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_KEYDOWN && wParam == 'S')
wParam = 's';

if (message == WM_COMMAND && LOWORD(wParam) == 40023)
{
if(!shufset)
{
shufset = 1;
SendMessage(hwnd,WM_COMMAND,MAKEWPARAM(40023,0),0);
}
else
shufset = 0;
}
return CallWindowProc( (WNDPROC)lpWndProcOld, hwnd, message, wParam, lParam);
}

uppe is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > Winamp Development

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