IDScanner.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef NULLSOFT_ML_PLG_IDSCANNER_H
  2. #define NULLSOFT_ML_PLG_IDSCANNER_H
  3. #include "../gracenote/gracenote.h"
  4. #include <api/syscb/callbacks/svccb.h>
  5. #include <api/syscb/api_syscb.h>
  6. #include "../ml_local/api_mldb.h"
  7. //#include "../nu/lockfreestack.h"
  8. // Regular declarations
  9. struct ProcessItem
  10. {
  11. wchar_t *filename;
  12. ProcessItem *next;
  13. };
  14. class IDScanner : public _ICDDBMusicIDManagerEvents, public SysCallback
  15. {
  16. public:
  17. IDScanner();
  18. ~IDScanner();
  19. void ScanDatabase();
  20. bool GetStatus(long *state, long *track, long *tracks);
  21. void Kill() { killswitch=1; }
  22. void Shutdown();
  23. // Processing data for step 4
  24. //LockFreeStack<ProcessItem> process_items;
  25. // Thread functions
  26. static int MLDBFileAddedOnThread(HANDLE handle, void *user_data, intptr_t id);
  27. static int MLDBFileRemovedOnThread(HANDLE handle, void *user_data, intptr_t id);
  28. static int MLDBClearedOnThread(HANDLE handle, void *user_data, intptr_t id);
  29. static int Pass2OnThread(HANDLE handle, void *user_data, intptr_t id);
  30. int ProcessStackItems(void);
  31. enum
  32. {
  33. STATE_ERROR = -1,
  34. STATE_IDLE = 0,
  35. STATE_INITIALIZING=1,
  36. STATE_SYNC = 2,
  37. STATE_METADATA = 3,
  38. STATE_MUSICID = 4,
  39. STATE_DONE = 5,
  40. };
  41. private:
  42. // *** IUnknown Methods ***
  43. STDMETHOD(QueryInterface)(REFIID riid, PVOID *ppvObject);
  44. STDMETHOD_(ULONG, AddRef)(void);
  45. STDMETHOD_(ULONG, Release)(void);
  46. // *** IDispatch Methods ***
  47. STDMETHOD (GetIDsOfNames)(REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgdispid);
  48. STDMETHOD (GetTypeInfo)(unsigned int itinfo, LCID lcid, ITypeInfo FAR* FAR* pptinfo);
  49. STDMETHOD (GetTypeInfoCount)(unsigned int FAR * pctinfo);
  50. STDMETHOD (Invoke)(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, EXCEPINFO FAR * pexecinfo, unsigned int FAR *puArgErr);
  51. // *** Sys callback ***
  52. api_syscb *systemCallbacks;
  53. FOURCC GetEventType();
  54. int notify(int msg, intptr_t param1, intptr_t param2);
  55. static void DebugCallbackMessage(const intptr_t text, const wchar_t *message);
  56. // *** ***
  57. void Pass1();
  58. void Pass2();
  59. // *** Helper functions ***
  60. bool SetupMusicID();
  61. void CommitFileInfo(ICddbFileInfo *match);
  62. void SetGracenoteData(BSTR filename, BSTR tagId, BSTR extData); // extData can be NULL
  63. // *** Data ***
  64. ICDDBMusicIDManager3 *musicID;
  65. volatile int killswitch;
  66. volatile long filesComplete, filesTotal;
  67. volatile long state;
  68. DWORD m_dwCookie;
  69. bool syscb_registered;
  70. protected:
  71. RECVS_DISPATCH;
  72. };
  73. IConnectionPoint *GetConnectionPoint(IUnknown *punk, REFIID riid);
  74. #endif