1
0

DSP.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include "Main.h"
  2. #include "dsp.h"
  3. static int initted=0;
  4. static HINSTANCE hLib=0;
  5. static winampDSPModule *mod=0;
  6. void dsp_init(void)
  7. {
  8. if (g_safeMode)
  9. return;
  10. wchar_t str[1024] = {0};
  11. if (initted)
  12. dsp_quit();
  13. if (!config_dspplugin_name[0])
  14. return;
  15. PathCombineW(str,DSPDIR,config_dspplugin_name);
  16. hLib = LoadLibraryW(str);
  17. if (!hLib)
  18. return;
  19. winampDSPGetHeaderType pr = (winampDSPGetHeaderType) GetProcAddress(hLib,"winampDSPGetHeader2");
  20. if (!pr || (pr(hMainWindow)->version < DSP_HDRVER && pr(hMainWindow)->version >= DSP_HDRVER+0x10) || !(mod = pr(hMainWindow)->getModule(config_dspplugin_num)))
  21. {
  22. FreeLibrary(hLib);
  23. hLib=0;
  24. return;
  25. }
  26. mod->hwndParent=hMainWindow;
  27. mod->hDllInstance=hLib;
  28. mod->Init(mod);
  29. initted=1;
  30. }
  31. void dsp_quit(void)
  32. {
  33. if (!initted)
  34. return;
  35. initted=0;
  36. if (mod)
  37. {
  38. if (!(config_no_visseh&2))
  39. {
  40. try
  41. {
  42. mod->Quit(mod);
  43. }
  44. catch(...)
  45. {
  46. }
  47. }
  48. else
  49. {
  50. mod->Quit(mod);
  51. }
  52. }
  53. FreeLibrary(hLib);
  54. hLib=0;
  55. mod=0;
  56. }
  57. int dsp_isactive(void)
  58. {
  59. return (in_mod && initted && mod);
  60. }
  61. int dsp_dosamples(short int *samples, int numsamples, int bps, int nch, int srate)
  62. {
  63. if (dsp_isactive())
  64. {
  65. if (mod)
  66. return (mod->ModifySamples(mod,samples,numsamples,bps,nch,srate));
  67. }
  68. return numsamples;
  69. }