Skip to content

Commit

Permalink
Fixed plug-in randomly creating waveform_in_*.dll files in music fold…
Browse files Browse the repository at this point in the history
…ers instead of in the settings cache folder due to a loading order issue
  • Loading branch information
dr0biwan committed Nov 25, 2016
1 parent 6ae3c4c commit 78f12a9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 18 deletions.
Binary file modified gen_waveseek.rc
Binary file not shown.
4 changes: 2 additions & 2 deletions installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
!define MINIMAL_VERSION "5.6.6.3507"

; common defines for a generic DrO installer :o)
!define VERSION "2.3.0"
!define ALT_VER "2_3_0"
!define VERSION "2.3.1"
!define ALT_VER "2_3_1"
!define PLUG "Waveform Seeker"
!define PLUG_ALT "Waveform_Seeker"
!define PLUG_FILE "gen_waveseek"
Expand Down
52 changes: 36 additions & 16 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
#include "api.h"
#include "gen_waveseek.h"
#include "embedwnd.h"
#ifdef WACUP_BUILD
#include "../../loader/hook/get_api_service.h"
#include "../../loader/loader/paths.h"
#endif

#define PLUGIN_VERSION "2.3.0"
#define PLUGIN_VERSION "2.3.1"

#ifdef GetPrivateProfileInt
#undef GetPrivateProfileInt
Expand Down Expand Up @@ -102,19 +106,27 @@ void PluginConfig();

void GetFilePaths()
{
// find the winamp.ini for the Winamp install being used
ini_file = (wchar_t *)SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_GETINIFILEW);
lstrcpyn(szWaveCacheDir, (wchar_t *)SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_GETINIDIRECTORYW), ARRAYSIZE(szWaveCacheDir));

// make the cache folder in the user's settings folder e.g. %APPDATA%\Winamp\Plugins\wavecache
// which will better ensure that the cache will be correctly generated though it will fallback
// to %PROGRAMFILES(x86)%\Winamp\Plugins\wavecache or %PROGRAMFILES%\Winamp\Plugins\wavecache
// as applicable to the Windows and Winamp version being used (more so with pre v5.11 clients)
PathAppend(szWaveCacheDir, L"Plugins\\wavecache");
CreateDirectory(szWaveCacheDir, NULL);

// find the correct Winamp\Plugins folder (using native api before making a good guess at it)
szDLLPath = (wchar_t *)SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_GETPLUGINDIRECTORYW);
if (!ini_file)
{
// find the winamp.ini for the Winamp install being used
#ifdef WACUP_BUILD
ini_file = (wchar_t *)get_paths()->winamp_ini_file;
lstrcpyn(szWaveCacheDir, get_paths()->settings_dir, ARRAYSIZE(szWaveCacheDir));
#else
ini_file = (wchar_t *)SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_GETINIFILEW);
lstrcpyn(szWaveCacheDir, (wchar_t *)SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_GETINIDIRECTORYW), ARRAYSIZE(szWaveCacheDir));
#endif

// make the cache folder in the user's settings folder e.g. %APPDATA%\Winamp\Plugins\wavecache
// which will better ensure that the cache will be correctly generated though it will fallback
// to %PROGRAMFILES(x86)%\Winamp\Plugins\wavecache or %PROGRAMFILES%\Winamp\Plugins\wavecache
// as applicable to the Windows and Winamp version being used (more so with pre v5.11 clients)
PathAppend(szWaveCacheDir, L"Plugins\\wavecache");
CreateDirectory(szWaveCacheDir, NULL);

// find the correct Winamp\Plugins folder (using native api before making a good guess at it)
szDLLPath = (wchar_t *)SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_GETPLUGINDIRECTORYW);
}
}

int GetFileInfo(const bool unicode, char* szFn, char szFile[MAX_PATH])
Expand Down Expand Up @@ -1216,6 +1228,11 @@ LRESULT CALLBACK WinampHookWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
}
else if (lParam == IPC_PLAYING_FILEW)
{
// we can sometimes see this message before the following
// delay load message so we need to ensure that the paths
// are setup correctly otherwise we get wrongly located
// waveseek_in_*.dll in the music folders loaded from :(
GetFilePaths();
ProcessFilePlayback((const wchar_t*)wParam, TRUE);
}
else if (lParam == delay_load)
Expand Down Expand Up @@ -1347,10 +1364,13 @@ LRESULT CALLBACK WinampHookWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l

int PluginInit()
{
/*WASABI_API_SVC = GetServiceAPIPtr();/*/
#ifdef WACUP_BUILD
WASABI_API_SVC = GetServiceAPIPtr();
#else
// load all of the required wasabi services from the winamp client
WASABI_API_SVC = reinterpret_cast<api_service*>(SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_GET_API_SERVICE));
if (WASABI_API_SVC == reinterpret_cast<api_service*>(1)) WASABI_API_SVC = NULL;/**/
if (WASABI_API_SVC == reinterpret_cast<api_service*>(1)) WASABI_API_SVC = NULL;
#endif
if (WASABI_API_SVC != NULL)
{
ServiceBuild(WASABI_API_SVC, WASABI_API_LNG, languageApiGUID);
Expand Down

0 comments on commit 78f12a9

Please sign in to comment.