DAEPlay.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #ifndef NULLSOFT_DAEPLAYH
  2. #define NULLSOFT_DAEPLAYH
  3. #include "Main.h"
  4. #include "CDPlay.h"
  5. #include "../nu/AutoLock.h"
  6. #include <map>
  7. #include <winioctl.h>
  8. #include "Ntddcdrm.h"
  9. #define CD_BLOCKS_PER_SECOND 75
  10. #define DEF_SECTORS_PER_READ 8
  11. #define CDROM_RAW_BYTES_PER_SECTOR 2352
  12. #define CDROM_COOKED_BYTES_PER_SECTOR 2048
  13. using namespace Nullsoft::Utility;
  14. class DAEPlay : public C_CDPlay
  15. {
  16. public:
  17. DAEPlay();
  18. ~DAEPlay();
  19. int open(wchar_t drive, int track);
  20. int play(wchar_t drive, int track);
  21. static DWORD WINAPI threadProc(LPVOID lpParameter)
  22. {
  23. DAEPlay *wp = (DAEPlay *)lpParameter;
  24. return wp->threadProc2();
  25. }
  26. int read(char *dest, int len, int *killswitch);
  27. int threadProc2();
  28. void stop();
  29. void pause()
  30. {
  31. line.outMod->Pause(1);
  32. }
  33. void unpause()
  34. {
  35. line.outMod->Pause(0);
  36. }
  37. int getlength()
  38. {
  39. return g_playlength;
  40. }
  41. int getoutputtime()
  42. {
  43. return line.outMod->GetOutputTime();
  44. }
  45. void setoutputtime(int time_in_ms)
  46. {
  47. need_seek = time_in_ms;
  48. }
  49. void setvolume(int _a_v, int _a_p)
  50. {
  51. line.outMod->SetVolume(_a_v);
  52. line.outMod->SetPan(_a_p);
  53. }
  54. typedef std::map<int, wchar_t*> CDTextArray;
  55. CDTextArray* getCDText();
  56. enum PacketTypes {
  57. CD_TEXT_TITLE,
  58. CD_TEXT_PERFORMER,
  59. CD_TEXT_SONGWRITER,
  60. CD_TEXT_COMPOSER,
  61. CD_TEXT_ARRANGER,
  62. CD_TEXT_MESSAGES,
  63. CD_TEXT_DISC_ID,
  64. CD_TEXT_GENRE,
  65. CD_TEXT_TOC_INFO,
  66. CD_TEXT_TOC_INFO2,
  67. CD_TEXT_RESERVED_1,
  68. CD_TEXT_RESERVED_2,
  69. CD_TEXT_RESERVED_3,
  70. CD_TEXT_RESERVED_4,
  71. CD_TEXT_CODE,
  72. CD_TEXT_SIZE,
  73. CD_TEXT_NUM_PACKS
  74. };
  75. private:
  76. BYTE * data;
  77. CDTextArray* cd_text;
  78. unsigned char *sbuf;
  79. long bytes_in_sbuf;
  80. int buf_size;
  81. int g_track, g_nch, g_srate, g_bps;
  82. int killswitch;
  83. HANDLE hDrive, hThread;
  84. int need_seek;
  85. DWORD start_address, track_length, current_sector;
  86. int getTrackInfo();
  87. int fillBuffer(int kill);
  88. DWORD MSFToBlocks(UCHAR msf[4])
  89. {
  90. return (((msf[1] * (CD_BLOCKS_PER_SECOND * 60)) + (msf[2] * CD_BLOCKS_PER_SECOND) + msf[3]) - 150);
  91. }
  92. };
  93. #endif