1
0

main.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. #include <windows.h>
  2. #include <shlobj.h>
  3. #include "../winamp/out.h"
  4. #define PI_VER2 "v1.2"
  5. /* #ifdef __alpha
  6. #define PI_VER PI_VER2 " (AXP)"
  7. #else
  8. #define PI_VER PI_VER2 " (x86)"
  9. #endif */
  10. int getwrittentime();
  11. int getoutputtime();
  12. int srate, numchan, bps, active;
  13. volatile int writtentime, w_offset;
  14. BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
  15. {
  16. return TRUE;
  17. }
  18. Out_Module out;
  19. static int last_pause=0;
  20. void config(HWND hwnd)
  21. {
  22. }
  23. void about(HWND hwnd)
  24. {
  25. }
  26. void init()
  27. {
  28. }
  29. void quit()
  30. {
  31. }
  32. int start_t;
  33. int open(int samplerate, int numchannels, int bitspersamp, int bufferlenms, int prebufferms)
  34. {
  35. start_t=GetTickCount();
  36. w_offset = writtentime = 0;
  37. active=1;
  38. numchan = numchannels;
  39. srate = samplerate;
  40. bps = bitspersamp;
  41. return 1;
  42. }
  43. void close()
  44. {
  45. }
  46. int write(char *buf, int len)
  47. {
  48. writtentime += len;
  49. return 0;
  50. }
  51. int canwrite()
  52. {
  53. if (last_pause) return 0;
  54. if (getwrittentime() < getoutputtime()+MulDiv(65536,1000,srate*bps*numchan/8)) return 65536;
  55. return 0;
  56. }
  57. int isplaying()
  58. {
  59. return 0;
  60. }
  61. int pause(int pause)
  62. {
  63. int t=last_pause;
  64. if (!last_pause && pause) { w_offset+=GetTickCount()-start_t; writtentime=0; }
  65. if (last_pause && !pause) { start_t=GetTickCount(); }
  66. last_pause=pause;
  67. return t;
  68. }
  69. void setvolume(int volume)
  70. {
  71. }
  72. void setpan(int pan)
  73. {
  74. }
  75. void flush(int t)
  76. {
  77. w_offset=t;
  78. start_t=GetTickCount();
  79. writtentime=0;
  80. }
  81. int getoutputtime()
  82. {
  83. if (last_pause)
  84. return w_offset;
  85. return GetTickCount()-start_t + w_offset;
  86. }
  87. int getwrittentime()
  88. {
  89. int t=srate*numchan,l;
  90. int ms=writtentime;
  91. if (t)
  92. {
  93. l=ms%t;
  94. ms /= t;
  95. ms *= 1000;
  96. ms += (l*1000)/t;
  97. ms/=(bps/8);
  98. return ms + w_offset;
  99. }
  100. else
  101. return ms;
  102. }
  103. Out_Module out = {
  104. OUT_VER,
  105. "Nullsoft NULL Output " PI_VER2
  106. ,
  107. 65,
  108. 0, // hmainwindow
  109. 0, // hdllinstance
  110. config,
  111. about,
  112. init,
  113. quit,
  114. open,
  115. close,
  116. write,
  117. canwrite,
  118. isplaying,
  119. pause,
  120. setvolume,
  121. setpan,
  122. flush,
  123. getoutputtime,
  124. getwrittentime
  125. };
  126. __declspec( dllexport ) Out_Module * winampGetOutModule()
  127. {
  128. return &out;
  129. }