in_linein.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. #define PLUGIN_NAME "Nullsoft LineIn Plug-in"
  2. #define PLUGIN_VERSION L"3.16"
  3. #include "main.h"
  4. #include <windows.h>
  5. #include "LineIn.h"
  6. #include <api/service/waServiceFactory.h>
  7. #include "../Agave/Language/api_language.h"
  8. #include "../winamp/wa_ipc.h"
  9. #include "resource.h"
  10. // wasabi based services for localisation support
  11. api_language *WASABI_API_LNG = 0;
  12. HINSTANCE WASABI_API_LNG_HINST = 0, WASABI_API_ORIG_HINST = 0;
  13. int lstrcmpni(const char *a, const char *b, int count)
  14. {
  15. if (!a || !b) return -1;
  16. switch (CompareStringA(LOCALE_USER_DEFAULT, NORM_IGNORECASE, a, min(lstrlenA(a),count), b, min(lstrlenA(b),count)))
  17. {
  18. case CSTR_LESS_THAN: return -1;
  19. case CSTR_GREATER_THAN: return 1;
  20. case CSTR_EQUAL: return 0;
  21. }
  22. return -1;
  23. }
  24. LineIn lineIn;
  25. int DoAboutMessageBox(HWND parent, wchar_t* title, wchar_t* message)
  26. {
  27. MSGBOXPARAMSW msgbx = {sizeof(MSGBOXPARAMSW),0};
  28. msgbx.lpszText = message;
  29. msgbx.lpszCaption = title;
  30. msgbx.lpszIcon = MAKEINTRESOURCEW(102);
  31. msgbx.hInstance = GetModuleHandle(0);
  32. msgbx.dwStyle = MB_USERICON;
  33. msgbx.hwndOwner = parent;
  34. return MessageBoxIndirectW(&msgbx);
  35. }
  36. void about(HWND hwndParent)
  37. {
  38. wchar_t message[1024] = {0}, text[1024] = {0};
  39. WASABI_API_LNGSTRINGW_BUF(IDS_NULLSOFT_LINEIN_PLUGIN_OLD,text,1024);
  40. wsprintfW(message, WASABI_API_LNGSTRINGW(IDS_ABOUT_TEXT),
  41. line.description, __DATE__);
  42. DoAboutMessageBox(hwndParent,text,message);
  43. }
  44. int init()
  45. {
  46. if (!IsWindow(line.hMainWindow))
  47. return IN_INIT_FAILURE;
  48. waServiceFactory *sf = line.service->service_getServiceByGuid(languageApiGUID);
  49. if (sf) WASABI_API_LNG = reinterpret_cast<api_language*>(sf->getInterface());
  50. // need to have this initialised before we try to do anything with localisation features
  51. WASABI_API_START_LANG(line.hDllInstance,InLineInLangGUID);
  52. static wchar_t szDescription[256];
  53. swprintf(szDescription,256,WASABI_API_LNGSTRINGW(IDS_NULLSOFT_LINEIN_PLUGIN),PLUGIN_VERSION);
  54. line.description = (char*)szDescription;
  55. return IN_INIT_SUCCESS;
  56. }
  57. void quit() {}
  58. int play(const char *fn)
  59. {
  60. line.is_seekable=0;
  61. if (!lstrcmpni(fn, "linein://", 9))
  62. {
  63. lineIn.Play();
  64. return 0;
  65. }
  66. return 1;
  67. }
  68. int isourfile(const char *fn)
  69. {
  70. if (!lstrcmpni(fn, "linein://", 9)) return 1;
  71. return 0;
  72. }
  73. void pause()
  74. {
  75. lineIn.Pause();
  76. }
  77. void unpause()
  78. {
  79. lineIn.Unpause();
  80. }
  81. int ispaused()
  82. {
  83. return lineIn.IsPaused();
  84. }
  85. void stop()
  86. {
  87. lineIn.Stop();
  88. line.SAVSADeInit();
  89. }
  90. int getlength()
  91. {
  92. return lineIn.GetLength();
  93. }
  94. int getoutputtime()
  95. {
  96. return lineIn.GetOutputTime();
  97. }
  98. void setoutputtime(int time_in_ms)
  99. {}
  100. void setvolume(int volume)
  101. {
  102. line.outMod->SetVolume(volume);
  103. }
  104. void setpan(int pan)
  105. {
  106. line.outMod->SetPan(pan);
  107. }
  108. int infoDlg(const char *fn, HWND hwnd)
  109. {
  110. return 0;
  111. }
  112. void getfileinfo(const char *filename, char *title, int *length_in_ms)
  113. {
  114. if (length_in_ms)
  115. *length_in_ms = -1000;
  116. if (title)
  117. WASABI_API_LNGSTRING_BUF(IDS_LINE_INPUT,title,GETFILEINFO_TITLE_LENGTH);
  118. }
  119. void eq_set(int on, char data[10], int preamp)
  120. {}
  121. In_Module line =
  122. {
  123. IN_VER_RET,
  124. "nullsoft(in_line.dll)",
  125. 0, // hMainWindow
  126. 0, // hDllInstance
  127. "",
  128. 0, // is_seekable
  129. //0, // uses output plugins
  130. 1, // uses output plugins
  131. about,
  132. about,
  133. init,
  134. quit,
  135. getfileinfo,
  136. infoDlg,
  137. isourfile,
  138. play,
  139. pause,
  140. unpause,
  141. ispaused,
  142. stop,
  143. getlength,
  144. getoutputtime,
  145. setoutputtime,
  146. setvolume,
  147. setpan,
  148. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  149. 0, 0, // dsp shit
  150. eq_set,
  151. NULL, // setinfo
  152. NULL // out_mod
  153. };
  154. BOOL APIENTRY DllMain(HANDLE hMod, DWORD r, void*)
  155. {
  156. if (r == DLL_PROCESS_ATTACH)
  157. DisableThreadLibraryCalls((HMODULE)hMod);
  158. return TRUE;
  159. }
  160. extern "C" __declspec( dllexport ) In_Module * winampGetInModule2()
  161. {
  162. return &line;
  163. }