aboutsummaryrefslogtreecommitdiff
path: root/Src/Winamp/DSP.cpp
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Winamp/DSP.cpp
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/Winamp/DSP.cpp')
-rw-r--r--Src/Winamp/DSP.cpp85
1 files changed, 85 insertions, 0 deletions
diff --git a/Src/Winamp/DSP.cpp b/Src/Winamp/DSP.cpp
new file mode 100644
index 00000000..88c3dc53
--- /dev/null
+++ b/Src/Winamp/DSP.cpp
@@ -0,0 +1,85 @@
+#include "Main.h"
+#include "dsp.h"
+
+static int initted=0;
+static HINSTANCE hLib=0;
+static winampDSPModule *mod=0;
+
+void dsp_init(void)
+{
+ if (g_safeMode)
+ return;
+
+ wchar_t str[1024] = {0};
+
+ if (initted)
+ dsp_quit();
+
+ if (!config_dspplugin_name[0])
+ return;
+
+ PathCombineW(str,DSPDIR,config_dspplugin_name);
+ hLib = LoadLibraryW(str);
+
+ if (!hLib)
+ return;
+
+ winampDSPGetHeaderType pr = (winampDSPGetHeaderType) GetProcAddress(hLib,"winampDSPGetHeader2");
+
+ if (!pr || (pr(hMainWindow)->version < DSP_HDRVER && pr(hMainWindow)->version >= DSP_HDRVER+0x10) || !(mod = pr(hMainWindow)->getModule(config_dspplugin_num)))
+ {
+ FreeLibrary(hLib);
+ hLib=0;
+ return;
+ }
+
+ mod->hwndParent=hMainWindow;
+ mod->hDllInstance=hLib;
+ mod->Init(mod);
+ initted=1;
+}
+
+void dsp_quit(void)
+{
+ if (!initted)
+ return;
+
+ initted=0;
+ if (mod)
+ {
+ if (!(config_no_visseh&2))
+ {
+ try
+ {
+ mod->Quit(mod);
+ }
+ catch(...)
+ {
+ }
+ }
+ else
+ {
+ mod->Quit(mod);
+ }
+ }
+
+ FreeLibrary(hLib);
+ hLib=0;
+ mod=0;
+}
+
+int dsp_isactive(void)
+{
+ return (in_mod && initted && mod);
+}
+
+int dsp_dosamples(short int *samples, int numsamples, int bps, int nch, int srate)
+{
+ if (dsp_isactive())
+ {
+ if (mod)
+ return (mod->ModifySamples(mod,samples,numsamples,bps,nch,srate));
+ }
+
+ return numsamples;
+} \ No newline at end of file